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