Restructured Create Process Into Store
This commit is contained in:
@@ -40,26 +40,7 @@ const setupPage = () => {
|
||||
|
||||
}
|
||||
|
||||
const createItem = async () => {
|
||||
const {data,error} = await supabase
|
||||
.from("plants")
|
||||
.insert([itemInfo.value])
|
||||
.select()
|
||||
|
||||
if(error) {
|
||||
console.log(error)
|
||||
} else {
|
||||
mode.value = "show"
|
||||
itemInfo.value = {
|
||||
id: 0,
|
||||
title: "",
|
||||
}
|
||||
toast.add({title: "Anlage erfolgreich erstellt"})
|
||||
await dataStore.fetchPlants()
|
||||
router.push(`/plants/show/${data[0].id}`)
|
||||
setupPage()
|
||||
}
|
||||
}
|
||||
|
||||
const editItem = async () => {
|
||||
router.push(`/plants/edit/${currentItem.id}`)
|
||||
@@ -199,7 +180,7 @@ setupPage()
|
||||
</UButton>
|
||||
<UButton
|
||||
v-else-if="mode == 'create'"
|
||||
@click="createItem"
|
||||
@click="dataStore.createNewItem('plants', itemInfo)"
|
||||
>
|
||||
Erstellen
|
||||
</UButton>
|
||||
|
||||
Reference in New Issue
Block a user