Restructured Create Process Into Store

This commit is contained in:
2024-01-15 19:50:26 +01:00
parent f6c1f4219b
commit 9f5a142680
12 changed files with 126 additions and 233 deletions

View File

@@ -10,7 +10,13 @@ const router = useRouter()
const toast = useToast()
const id = ref(route.params.id ? route.params.id : null )
let currentItem = null
let currentItem = ref(null)
/*watch(dataStore.tasks, (oldVal,newVal) => {
console.log("OK")
console.log(dataStore.tasks)
currentItem.value = dataStore.getTaskById(Number(useRoute().params.id))
})*/
//Working
const mode = ref(route.params.mode || "show")
@@ -37,7 +43,10 @@ const setupPage = () => {
}
const createItem = async () => {
const {data,error} = await supabase
/*const {data,error} = await supabase
.from("tasks")
.insert([itemInfo.value])
.select()
@@ -50,11 +59,11 @@ const createItem = async () => {
id: 0,
title: "",
}
toast.add({title: "Aufgabe erfolgreich erstellt"})
//toast.add({title: "Aufgabe erfolgreich erstellt"})
await dataStore.fetchTasks()
router.push(`/tasks/show/${data[0].id}`)
//router.push(`/tasks/show/${data[0].id}`)
setupPage()
}
}*/
}
const editItem = async () => {
@@ -219,7 +228,7 @@ setupPage()
</UButton>
<UButton
v-else-if="mode == 'create'"
@click="createItem"
@click="dataStore.createNewItem('tasks',itemInfo)"
>
Erstellen
</UButton>