Restructured Create Process Into Store
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user