Added new Auth Store

This commit is contained in:
2025-09-24 17:50:20 +02:00
parent b57b11ca9a
commit 9894f003e3
2 changed files with 27 additions and 82 deletions

View File

@@ -13,8 +13,9 @@ const { isHelpSlideoverOpen } = useDashboard()
const supabase = useSupabaseClient()
const router = useRouter()
const route = useRoute()
const auth = useAuthStore()
profileStore.initializeData((await supabase.auth.getUser()).data.user.id)
//profileStore.initializeData((await supabase.auth.getUser()).data.user.id)
const month = dayjs().format("MM")
@@ -64,40 +65,6 @@ const actions = [
]
const groups = computed(() =>
[{
key: 'actions',
commands: actions
},{
key: "customers",
label: "Kunden",
commands: dataStore.customers.map(item => { return {id: item.id, label: item.name, to: `/customers/show/${item.id}`}})
},{
key: "vendors",
label: "Lieferanten",
commands: dataStore.vendors.map(item => { return {id: item.id, label: item.name, to: `/vendors/show/${item.id}`}})
},{
key: "contacts",
label: "Ansprechpartner",
commands: dataStore.contacts.map(item => { return {id: item.id, label: item.fullName, to: `/contacts/show/${item.id}`}})
},{
key: "products",
label: "Artikel",
commands: dataStore.products.map(item => { return {id: item.id, label: item.name, to: `/products/show/${item.id}`}})
},{
key: "tasks",
label: "Aufgaben",
commands: dataStore.tasks.map(item => { return {id: item.id, label: item.name, to: `/tasks/show/${item.id}`}})
},{
key: "plants",
label: "Objekte",
commands: dataStore.plants.map(item => { return {id: item.id, label: item.name, to: `/plants/show/${item.id}`}})
},{
key: "projects",
label: "Projekte",
commands: dataStore.projects.map(item => { return {id: item.id, label: item.name, to: `/projects/show/${item.id}`}})
}
].filter(Boolean))
const footerLinks = [/*{
label: 'Invite people',
icon: 'i-heroicons-plus',
@@ -111,36 +78,7 @@ const footerLinks = [/*{
</script>
<template>
<UDashboardLayout class="safearea" v-if="profileStore.loaded">
<UDashboardPanel :width="250" :resizable="{ min: 200, max: 300 }" collapsible>
<UDashboardNavbar style="margin-top: env(safe-area-inset-top, 10px) !important;" :class="['!border-transparent']" :ui="{ left: 'flex-1' }">
<template #left>
<ProfileDropdown class="w-full" />
</template>
</UDashboardNavbar>
<UDashboardSidebar id="sidebar">
<template #header>
<UDashboardSearchButton v-if="!useCapacitor().getIsPhone()" label="Suche..."/>
</template>
<MainNav/>
<div class="flex-1" />
<template #footer>
<div class="flex flex-col w-full">
<UDashboardSidebarLinks :links="footerLinks" />
<UDivider class="sticky bottom-0" />
<UserDropdown style="margin-bottom: env(safe-area-inset-bottom, 10px) !important;"/>
</div>
</template>
</UDashboardSidebar>
</UDashboardPanel>
<UDashboardLayout class="safearea" v-if="!auth.loading">
<UDashboardPage style="height: 90vh">
<UDashboardPanel grow>
@@ -188,9 +126,7 @@ const footerLinks = [/*{
<!-- ~/components/NotificationsSlideover.vue -->
<NotificationsSlideover />
<ClientOnly>
<LazyUDashboardSearch :groups="groups" hide-color-mode/>
</ClientOnly>
</UDashboardLayout>
<div
v-else
@@ -208,15 +144,26 @@ const footerLinks = [/*{
class="w-1/3 mx-auto my-10"
v-else
/>
<div v-if="dataStore.showProfileSelection">
<ProfileSelection/>
<div v-if="!auth.activeTenant" class="w-full mx-auto text-center">
<!-- Tenant Selection -->
<h3 class="text-center font-bold text-2xl mb-5">Kein Aktiver Mandant. Bitte wählen Sie ein Mandant.</h3>
<div class="mx-auto w-5/6 flex flex-row justify-between my-3" v-for="tenant in auth.tenants">
<span class="text-left">{{tenant.name}}</span>
<UButton
@click="auth.switchTenant(tenant.id)"
>Wählen</UButton>
</div>
<UButton
variant="outline"
color="rose"
@click="auth.logout()"
>Abmelden</UButton>
</div>
<div v-else>
<UProgress animation="carousel" class="w-3/4 mx-auto mt-10" />
</div>
</div>
</template>

View File

@@ -4,7 +4,7 @@ definePageMeta({
layout: 'mobile',
})
const profileStore = useProfileStore()
const auth = useAuthStore()
</script>
@@ -68,14 +68,12 @@ const profileStore = useProfileStore()
<UDivider class="my-5">Unternehmen wechseln</UDivider>
<UButton
v-for="option in profileStore.ownProfiles"
class="my-1"
variant="outline"
@click="profileStore.changeProfile(option.id)"
>
{{profileStore.tenants.find(i => i.id === option.tenant).name}}
</UButton>
<div class="w-full flex flex-row justify-between my-3" v-for="tenant in auth.tenants">
<span class="text-left">{{tenant.name}}</span>
<UButton
@click="auth.switchTenant(tenant.id)"
>Wechseln</UButton>
</div>
</UDashboardPanelContent>