feat : word edition

This commit is contained in:
2024-12-29 20:40:06 +01:00
parent 6d5f92e273
commit 29ffc556ec
4 changed files with 125 additions and 44 deletions
+25 -4
View File
@@ -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<WordResponseDTO>(config.public.endpoint + `/words/` + id + "/enable", {
const data = await $fetch<WordResponseDTO>(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<WordResponseDTO>(config.public.endpoint + `/words/` + id + "/disable", {
const data = await $fetch<WordResponseDTO>(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<WordResponseDTO>(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<WordResponseDTO>(config.public.endpoint + `/words/`+word.id, {
credentials: "include",
method: "DELETE"
})
delete this.words[word.id]
}
},
});