Added new Auth Store
This commit is contained in:
@@ -13,8 +13,9 @@ const { isHelpSlideoverOpen } = useDashboard()
|
|||||||
const supabase = useSupabaseClient()
|
const supabase = useSupabaseClient()
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
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")
|
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 = [/*{
|
const footerLinks = [/*{
|
||||||
label: 'Invite people',
|
label: 'Invite people',
|
||||||
icon: 'i-heroicons-plus',
|
icon: 'i-heroicons-plus',
|
||||||
@@ -111,36 +78,7 @@ const footerLinks = [/*{
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<UDashboardLayout class="safearea" v-if="profileStore.loaded">
|
<UDashboardLayout class="safearea" v-if="!auth.loading">
|
||||||
|
|
||||||
<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>
|
|
||||||
|
|
||||||
<UDashboardPage style="height: 90vh">
|
<UDashboardPage style="height: 90vh">
|
||||||
<UDashboardPanel grow>
|
<UDashboardPanel grow>
|
||||||
@@ -188,9 +126,7 @@ const footerLinks = [/*{
|
|||||||
<!-- ~/components/NotificationsSlideover.vue -->
|
<!-- ~/components/NotificationsSlideover.vue -->
|
||||||
<NotificationsSlideover />
|
<NotificationsSlideover />
|
||||||
|
|
||||||
<ClientOnly>
|
|
||||||
<LazyUDashboardSearch :groups="groups" hide-color-mode/>
|
|
||||||
</ClientOnly>
|
|
||||||
</UDashboardLayout>
|
</UDashboardLayout>
|
||||||
<div
|
<div
|
||||||
v-else
|
v-else
|
||||||
@@ -208,15 +144,26 @@ const footerLinks = [/*{
|
|||||||
class="w-1/3 mx-auto my-10"
|
class="w-1/3 mx-auto my-10"
|
||||||
v-else
|
v-else
|
||||||
/>
|
/>
|
||||||
<div v-if="dataStore.showProfileSelection">
|
<div v-if="!auth.activeTenant" class="w-full mx-auto text-center">
|
||||||
<ProfileSelection/>
|
<!-- 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>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
|
|
||||||
|
|
||||||
<UProgress animation="carousel" class="w-3/4 mx-auto mt-10" />
|
<UProgress animation="carousel" class="w-3/4 mx-auto mt-10" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ definePageMeta({
|
|||||||
layout: 'mobile',
|
layout: 'mobile',
|
||||||
})
|
})
|
||||||
|
|
||||||
const profileStore = useProfileStore()
|
const auth = useAuthStore()
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -68,14 +68,12 @@ const profileStore = useProfileStore()
|
|||||||
|
|
||||||
<UDivider class="my-5">Unternehmen wechseln</UDivider>
|
<UDivider class="my-5">Unternehmen wechseln</UDivider>
|
||||||
|
|
||||||
<UButton
|
<div class="w-full flex flex-row justify-between my-3" v-for="tenant in auth.tenants">
|
||||||
v-for="option in profileStore.ownProfiles"
|
<span class="text-left">{{tenant.name}}</span>
|
||||||
class="my-1"
|
<UButton
|
||||||
variant="outline"
|
@click="auth.switchTenant(tenant.id)"
|
||||||
@click="profileStore.changeProfile(option.id)"
|
>Wechseln</UButton>
|
||||||
>
|
</div>
|
||||||
{{profileStore.tenants.find(i => i.id === option.tenant).name}}
|
|
||||||
</UButton>
|
|
||||||
|
|
||||||
|
|
||||||
</UDashboardPanelContent>
|
</UDashboardPanelContent>
|
||||||
|
|||||||
Reference in New Issue
Block a user