Restructured Create Process Into Store
This commit is contained in:
@@ -40,29 +40,6 @@ const setupPage = () => {
|
||||
|
||||
}
|
||||
|
||||
const createItem = async () => {
|
||||
let fullName = itemInfo.value.firstName + ' ' + itemInfo.value.lastName
|
||||
|
||||
|
||||
const {data,error} = await supabase
|
||||
.from("contacts")
|
||||
.insert([{...itemInfo.value, fullName}])
|
||||
.select()
|
||||
|
||||
if(error) {
|
||||
console.log(error)
|
||||
} else {
|
||||
mode.value = "show"
|
||||
itemInfo.value = {
|
||||
id: 0,
|
||||
}
|
||||
toast.add({title: "Kontakt erfolgreich erstellt"})
|
||||
await dataStore.fetchContacts()
|
||||
router.push(`/contacts/show/${data[0].id}`)
|
||||
setupPage()
|
||||
}
|
||||
}
|
||||
|
||||
const editCustomer = async () => {
|
||||
router.push(`/contacts/edit/${currentContact.id}`)
|
||||
setupPage()
|
||||
@@ -273,7 +250,7 @@ setupPage()
|
||||
</UButton>
|
||||
<UButton
|
||||
v-else-if="mode == 'create'"
|
||||
@click="createItem"
|
||||
@click="dataStore.createNewItem('contacts',itemInfo)"
|
||||
>
|
||||
Erstellen
|
||||
</UButton>
|
||||
|
||||
Reference in New Issue
Block a user