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

@@ -85,32 +85,8 @@ const setupPage = () => {
}
itemInfo.value = currentItem
}
/*const createItem = async () => {
const {data,error} = await supabase
.from("profiles")
.insert([itemInfo.value])
.select()
if(error) {
console.log(error)
} else {
mode.value = "show"
itemInfo.value = {
id: 0,
title: "",
}
toast.add({title: "Job erfolgreich erstellt"})
await dataStore.fetchJobs()
router.push(`/jobs/show/${data[0].id}`)
setupPage()
}
}*/
const editItem = async () => {
router.push(`/users/edit/${currentItem.id}`)
setupPage()
@@ -124,22 +100,7 @@ const cancelEditorCreate = () => {
}
}
const updateItem = async () => {
itemInfo.value.fullName = `${itemInfo.value.firstName} ${itemInfo.value.lastName}`
const {error} = await supabase
.from("profiles")
.update(itemInfo.value)
.eq('id',itemInfo.value.id)
if(error) {
console.log(error)
}
router.push(`/users/show/${currentItem.id}`)
toast.add({title: "Mitarbeiter erfolgreich gespeichert"})
dataStore.fetchProfiles()
}
const getDuration = (time) => {
const dez = dayjs(time.end).diff(time.start,'hour',true).toFixed(2)
@@ -295,7 +256,7 @@ setupPage()
</InputGroup>
<UButton
class="mt-5"
@click="updateItem"
@click="dataStore.updateItem('users',itemInfo)"
>
Speichern
</UButton>
@@ -463,16 +424,16 @@ setupPage()
<template #footer>
<UButton
v-if="mode == 'edit'"
@click="updateItem"
@click="dataStore.updateItem('users',{...itemInfo, fullName: `${itemInfo.firstName} ${itemInfo.lastName}`})"
>
Speichern
</UButton>
<UButton
<!-- <UButton
v-else-if="mode == 'create'"
@click="createItem"
@click="dataStore.createItem()"
>
Erstellen
</UButton>
</UButton>-->
<UButton
@click="cancelEditorCreate"
color="red"