Restructured Update Process Into Store

This commit is contained in:
2024-01-15 21:54:12 +01:00
parent 9f5a142680
commit 497d768d4e
20 changed files with 176 additions and 918 deletions

View File

@@ -89,30 +89,14 @@ const totalCalculated = computed(() => {
const setState = async (newState) => {
if(mode.value === 'show') {
await updateItem({...currentVendorInvoice.value, state: newState})
await dataStore.updateItem('incomingInvoices',{...currentVendorInvoice.value, state: newState})
} else if(mode.value === 'edit') {
await updateItem({...itemInfo.value, state: newState})
await dataStore.updateItem('incomingInvoices',{...itemInfo.value, state: newState})
}
await router.push("/incominginvoices")
}
const updateItem = async (item) => {
const {error} = await supabase
.from("incomingInvoices")
.update(item)
.eq('id',item.id)
if(error) {
console.log(error)
} else {
mode.value = "show"
toast.add({title: "Eingangsrechnung erfolgreich gespeichert"})
dataStore.fetchIncomingInvoices()
//await router.push("/incominginvoices")
}
}
setupPage()
</script>
@@ -128,7 +112,7 @@ setupPage()
<div class="w-4/5">
<InputGroup class="mt-3" v-if="currentVendorInvoice">
<UButton
@click="updateItem(itemInfo)"
@click="dataStore.updateItem('incomingInvoices',itemInfo)"
v-if="mode === 'edit'"
>
Speichern