mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-23 05:04:09 +00:00
Add frontend handling for users without a company
Make setSelectedCompany null-safe and clear stale localStorage. Conditionally initialize company store state in bootstrap. Add router guard to redirect no-company users to NoCompanyView while allowing super admins through. Hide sidebar when no company. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,12 +6,15 @@
|
||||
|
||||
<SiteHeader />
|
||||
|
||||
<SiteSidebar />
|
||||
<SiteSidebar v-if="hasCompany" />
|
||||
|
||||
<ExchangeRateBulkUpdateModal />
|
||||
|
||||
<main
|
||||
class="h-screen h-screen-ios overflow-y-auto md:pl-56 xl:pl-64 min-h-0"
|
||||
:class="[
|
||||
'h-screen h-screen-ios overflow-y-auto min-h-0',
|
||||
hasCompany ? 'md:pl-56 xl:pl-64' : '',
|
||||
]"
|
||||
>
|
||||
<div class="pt-16 pb-16">
|
||||
<router-view />
|
||||
@@ -51,8 +54,19 @@ const isAppLoaded = computed(() => {
|
||||
return globalStore.isAppLoaded
|
||||
})
|
||||
|
||||
const hasCompany = computed(() => {
|
||||
return !!companyStore.selectedCompany || !!userStore.currentUser?.is_super_admin
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
globalStore.bootstrap().then((res) => {
|
||||
if (!res.data.current_company && !res.data.current_user.is_super_admin) {
|
||||
if (route.name !== 'no.company') {
|
||||
router.push({ name: 'no.company' })
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (route.meta.ability && !userStore.hasAbilities(route.meta.ability)) {
|
||||
router.push({ name: 'account.settings' })
|
||||
} else if (route.meta.isSuperAdmin && !userStore.currentUser.is_super_admin) {
|
||||
|
||||
Reference in New Issue
Block a user