From 1cbea757d09e03ba9913865cb8be48173133b1c1 Mon Sep 17 00:00:00 2001 From: flfeders Date: Thu, 7 Mar 2024 10:32:47 +0100 Subject: [PATCH] Changes --- spaces/composables/useDashboard.ts | 2 +- spaces/layouts/default.vue | 6 +- spaces/pages/settings/numberRanges.vue | 3 + spaces/pages/settings/profiles/create.vue | 97 ++++++++++++++++ spaces/pages/settings/profiles/index.vue | 45 ++++++++ spaces/pages/settings/profiles/show/[id].vue | 113 +++++++++++++++++++ spaces/stores/data.js | 20 +++- 7 files changed, 280 insertions(+), 6 deletions(-) create mode 100644 spaces/pages/settings/profiles/create.vue create mode 100644 spaces/pages/settings/profiles/index.vue create mode 100644 spaces/pages/settings/profiles/show/[id].vue diff --git a/spaces/composables/useDashboard.ts b/spaces/composables/useDashboard.ts index 7fb2f6d..49242e7 100644 --- a/spaces/composables/useDashboard.ts +++ b/spaces/composables/useDashboard.ts @@ -9,7 +9,7 @@ const _useDashboard = () => { defineShortcuts({ 'g-h': () => router.push('/'), 'g-i': () => router.push('/inbox'), - 'g-u': () => router.push('/users'), + 'g-u': () => router.push('/profiles'), 'g-s': () => router.push('/settings'), '?': () => isHelpSlideoverOpen.value = true, n: () => isNotificationsSlideoverOpen.value = !isNotificationsSlideoverOpen.value diff --git a/spaces/layouts/default.vue b/spaces/layouts/default.vue index 8228420..4870a27 100644 --- a/spaces/layouts/default.vue +++ b/spaces/layouts/default.vue @@ -329,6 +329,10 @@ let links = [ label: "Nummernkreise", to: "/settings/numberRanges", icon: "i-heroicons-clipboard-document-list" + },{ + label: "Mitarbeiter", + to: "/settings/profiles", + icon: "i-heroicons-clipboard-document-list" } ] }, @@ -423,7 +427,7 @@ const footerLinks = [/*{ diff --git a/spaces/pages/settings/numberRanges.vue b/spaces/pages/settings/numberRanges.vue index 023a553..a755391 100644 --- a/spaces/pages/settings/numberRanges.vue +++ b/spaces/pages/settings/numberRanges.vue @@ -39,6 +39,9 @@ const resources = { }, invoices: { label: "Rechnungen" + }, + quotes: { + label: "Angebote" } } diff --git a/spaces/pages/settings/profiles/create.vue b/spaces/pages/settings/profiles/create.vue new file mode 100644 index 0000000..f6b0912 --- /dev/null +++ b/spaces/pages/settings/profiles/create.vue @@ -0,0 +1,97 @@ + + + + + \ No newline at end of file diff --git a/spaces/pages/settings/profiles/index.vue b/spaces/pages/settings/profiles/index.vue new file mode 100644 index 0000000..e119793 --- /dev/null +++ b/spaces/pages/settings/profiles/index.vue @@ -0,0 +1,45 @@ + + + + + \ No newline at end of file diff --git a/spaces/pages/settings/profiles/show/[id].vue b/spaces/pages/settings/profiles/show/[id].vue new file mode 100644 index 0000000..c8ecfbd --- /dev/null +++ b/spaces/pages/settings/profiles/show/[id].vue @@ -0,0 +1,113 @@ + + + + + \ No newline at end of file diff --git a/spaces/stores/data.js b/spaces/stores/data.js index 7b61fd4..afefeea 100644 --- a/spaces/stores/data.js +++ b/spaces/stores/data.js @@ -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