From a072c91cc0dc26e417c51f666e8547e08ef40942 Mon Sep 17 00:00:00 2001
From: Leonardo Bishop <me@leonardobishop.com>
Date: Tue, 12 Mar 2024 23:18:23 +0000
Subject: Add import from file system

---
 components/loader/LoaderTestDataModal.vue | 52 +++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 components/loader/LoaderTestDataModal.vue

(limited to 'components/loader/LoaderTestDataModal.vue')

diff --git a/components/loader/LoaderTestDataModal.vue b/components/loader/LoaderTestDataModal.vue
new file mode 100644
index 0000000..36d2d6d
--- /dev/null
+++ b/components/loader/LoaderTestDataModal.vue
@@ -0,0 +1,52 @@
+<script setup lang="ts">
+import { loadCategoriesFromJson, loadItemsFromJson, loadQuestsFromJson } from '~/lib/questsLoader';
+import testData from '@/data/testData.json';
+
+const session = useSessionStore();
+
+const showModal = ref(false);
+
+const open = () => {
+  showModal.value = true;
+}
+
+const confirm = () => {
+  const quests = loadQuestsFromJson(testData.quests);
+  const categories = loadCategoriesFromJson(testData.categories);
+  const items = loadItemsFromJson(testData.items);
+
+  session.setQuests(quests);
+  session.setCategories(categories);
+  session.setItems(items);
+
+  showModal.value = false;
+}
+
+defineExpose({
+  open
+})
+</script>
+
+<template>
+  <Modal v-model="showModal">
+    <template v-slot:header>
+      <h2>Import test data</h2>
+    </template>
+
+    <p>You can view a demo of the Quests editor by loading test data. This will replace your current workspace.
+      Do you want to continue?</p>
+
+    <div id="controls" class="control-group">
+      <Button :icon="['fas', 'xmark']" :label="'Cancel'" @click="showModal = false"></Button>
+      <Button type="solid" :icon="['fas', 'check']" :label="'Confirm'" @click="confirm"></Button>
+    </div>
+  </Modal>
+</template>
+
+<style scoped>
+#controls {
+  display: flex;
+  justify-content: flex-end;
+  margin-top: 1rem;
+}
+</style>
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

