Template
feat : word edition
This commit is contained in:
+25
-4
@@ -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]
|
||||
}
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user