From 1869b5c5f9565b5e9e20697c4401a2f9ba9f2c3a Mon Sep 17 00:00:00 2001
From: Leonardo Bishop <me@leonardobishop.com>
Date: Thu, 15 Feb 2024 18:39:01 +0000
Subject: Add quest rename and delete functionality

---
 src/components/Editor/Quest/Modal/RenameQuestModal.vue | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

(limited to 'src/components/Editor/Quest/Modal/RenameQuestModal.vue')

diff --git a/src/components/Editor/Quest/Modal/RenameQuestModal.vue b/src/components/Editor/Quest/Modal/RenameQuestModal.vue
index 5b1e0ed..2ad1481 100644
--- a/src/components/Editor/Quest/Modal/RenameQuestModal.vue
+++ b/src/components/Editor/Quest/Modal/RenameQuestModal.vue
@@ -1,7 +1,8 @@
 <script setup lang="ts">
 import Modal from '@/components/Control/Modal.vue';
 import Button from '@/components/Control/Button.vue';
-import { ref } from 'vue';
+import { computed, ref } from 'vue';
+import { useSessionStore } from '@/stores/session';
 
 const model = defineModel();
 
@@ -11,7 +12,14 @@ const props = defineProps({
   questId: String,
 });
 
+const session = useSessionStore();
+
 const newQuestId = ref(props.questId);
+
+const isDuplicate = computed(() => {
+  return session.getQuestById(newQuestId.value!) !== undefined;
+});
+
 </script>
 
 <template>
@@ -26,6 +34,7 @@ const newQuestId = ref(props.questId);
           <label for="new-type">New quest ID</label>
           <input id="new-type" name="new-type" type="text" v-model="newQuestId" />
         </div>
+        <p v-if="isDuplicate" class="error-text">Name is not unique.</p>
         <p>A Quest ID must be unique, alphanumeric, and not contain any spaces.</p>
         <div id="confirm" class="control-group">
           <Button
@@ -37,6 +46,7 @@ const newQuestId = ref(props.questId);
             type="solid"
             :icon="['fas', 'fa-check']"
             :label="'Rename'"
+            :disabled="isDuplicate"
             @click="emit('update', newQuestId)"
           ></Button>
         </div>
-- 
cgit v1.2.3-70-g09d2

