Changes
This commit is contained in:
@@ -102,6 +102,11 @@ export const useDataStore = defineStore('data', () => {
|
||||
label: "Termine",
|
||||
labelSingle: "Termin"
|
||||
},
|
||||
profiles: {
|
||||
label: "Mitarbeiter",
|
||||
labelSingle: "Mitarbeiter",
|
||||
redirect: true
|
||||
}
|
||||
}
|
||||
|
||||
const documentTypesForCreation = ref({
|
||||
@@ -236,7 +241,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
])
|
||||
|
||||
async function initializeData (userId) {
|
||||
let profile = (await supabase.from("profiles").select().eq("id",userId).single()).data
|
||||
let profile = (await supabase.from("profiles").select().eq("user",userId).single()).data
|
||||
|
||||
currentTenant.value = profile.tenant
|
||||
|
||||
@@ -419,16 +424,23 @@ export const useDataStore = defineStore('data', () => {
|
||||
}
|
||||
|
||||
async function updateItem (dataType, data) {
|
||||
|
||||
const {tenants, ...newData} = data
|
||||
|
||||
|
||||
|
||||
|
||||
const {data:supabaseData,error: supabaseError} = await supabase
|
||||
.from(dataType)
|
||||
.update(data)
|
||||
.eq('id',data.id)
|
||||
.update(newData)
|
||||
.eq('id',newData.id)
|
||||
.select()
|
||||
|
||||
if(supabaseError) {
|
||||
console.log(supabaseError)
|
||||
} else if(supabaseData) {
|
||||
await eval(dataType + '.value[' + dataType + '.value.findIndex(i => i.id === ' + JSON.stringify(data.id) + ')] = ' + JSON.stringify(supabaseData[0]))
|
||||
if(dataType === 'profiles') await fetchProfiles()
|
||||
toast.add({title: `${dataTypes[dataType].labelSingle} gespeichert`})
|
||||
if(dataTypes[dataType].redirect) await router.push(`/${dataType}/show/${data.id}`)
|
||||
return supabaseData
|
||||
@@ -509,7 +521,7 @@ export const useDataStore = defineStore('data', () => {
|
||||
}
|
||||
|
||||
async function fetchProfiles () {
|
||||
profiles.value = (await supabase.from("profiles").select('* , tenants (id, name)')/*.eq("tenant", currentTenant.value)*/.order("fullName")).data
|
||||
profiles.value = (await supabase.from("profiles").select('* , tenants (id, name)').eq("tenant", currentTenant.value).order("fullName")).data
|
||||
}
|
||||
async function fetchBankAccounts () {
|
||||
bankAccounts.value = (await supabase.from("bankaccounts").select().eq('tenant', currentTenant.value)).data
|
||||
|
||||
Reference in New Issue
Block a user