From 29ffc556ec6924dd0f792979aed55f03eeeacc3b Mon Sep 17 00:00:00 2001 From: legonzaur Date: Sun, 29 Dec 2024 20:40:06 +0100 Subject: [PATCH] feat : word edition --- components/word.vue | 84 ++++++++++++++++++++++++++++----------------- netcode/events | 2 +- pages/words.vue | 54 +++++++++++++++++++++++++---- store/word.store.ts | 29 +++++++++++++--- 4 files changed, 125 insertions(+), 44 deletions(-) diff --git a/components/word.vue b/components/word.vue index e4927c0..f4d9a0f 100644 --- a/components/word.vue +++ b/components/word.vue @@ -1,56 +1,76 @@ \ No newline at end of file + diff --git a/netcode/events b/netcode/events index fff2abf..72935ba 160000 --- a/netcode/events +++ b/netcode/events @@ -1 +1 @@ -Subproject commit fff2abf0a1585fb48ce1d1609b471b45d4acd9a6 +Subproject commit 72935ba3f59fa8b5399207937f28cc686e5239f6 diff --git a/pages/words.vue b/pages/words.vue index d635d30..c5aacb8 100644 --- a/pages/words.vue +++ b/pages/words.vue @@ -1,10 +1,38 @@ \ No newline at end of file + diff --git a/store/word.store.ts b/store/word.store.ts index 34bb2e6..06d743e 100644 --- a/store/word.store.ts +++ b/store/word.store.ts @@ -19,21 +19,42 @@ export const useWordStore = defineStore("word", { } return data }, - async enableWord(id: number) { + async enableWord(word: WordResponseDTO) { const config = useRuntimeConfig(); - const data = await $fetch(config.public.endpoint + `/words/` + id + "/enable", { + const data = await $fetch(config.public.endpoint + `/words/` + word.id + "/enable", { credentials: "include", method: "PUT" }) + word.enabled = true return data }, - async disableWord(id: number) { + async disableWord(word: WordResponseDTO) { const config = useRuntimeConfig(); - const data = await $fetch(config.public.endpoint + `/words/` + id + "/disable", { + const data = await $fetch(config.public.endpoint + `/words/` + word.id + "/disable", { credentials: "include", method: "PUT" }) + word.enabled = false return data + }, + + async createWord(value: string) { + const config = useRuntimeConfig(); + const data = await $fetch(config.public.endpoint + `/words/`, { + credentials: "include", + body: { value }, + method: "POST" + }) + this.words[data.id] = data + return data + }, + async deleteWord(word: WordResponseDTO){ + const config = useRuntimeConfig(); + const data = await $fetch(config.public.endpoint + `/words/`+word.id, { + credentials: "include", + method: "DELETE" + }) + delete this.words[word.id] } }, }); \ No newline at end of file