From da5fc3f113c10357f6e52b92313cc04f5653940e Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Wed, 30 Apr 2025 12:06:48 +0200 Subject: [PATCH] only show invoicing tab when module is activated --- app/Http/Middleware/HandleInertiaRequests.php | 2 ++ resources/js/Layouts/AppLayout.vue | 7 +++---- resources/js/utils/billing.ts | 8 ++++++++ resources/js/utils/permissions.ts | 4 ++++ 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 5a468ecf..f0b96ebd 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -40,6 +40,7 @@ class HandleInertiaRequests extends Middleware public function share(Request $request): array { $hasBilling = Module::has('Billing') && Module::isEnabled('Billing'); + $hasInvoicing = Module::has('Invoicing') && Module::isEnabled('Invoicing'); /** @var BillingContract $billing */ $billing = app(BillingContract::class); @@ -48,6 +49,7 @@ class HandleInertiaRequests extends Middleware return array_merge(parent::share($request), [ 'has_billing_extension' => $hasBilling, + 'has_invoicing_extension' => $hasInvoicing, 'billing' => $billing !== null && $currentOrganization !== null ? [ 'has_subscription' => $billing->hasSubscription($currentOrganization), 'has_trial' => $billing->hasTrial($currentOrganization), diff --git a/resources/js/Layouts/AppLayout.vue b/resources/js/Layouts/AppLayout.vue index b0d571df..1a70d90a 100644 --- a/resources/js/Layouts/AppLayout.vue +++ b/resources/js/Layouts/AppLayout.vue @@ -26,12 +26,12 @@ import { initializeStores, refreshStores } from '@/utils/init'; import { canManageBilling, canUpdateOrganization, - canViewClients, + canViewClients, canViewInvoices, canViewMembers, canViewProjects, canViewReport, canViewTags, } from '@/utils/permissions'; -import { isBillingActivated } from '@/utils/billing'; +import {isBillingActivated, isInvoicingActivated} from '@/utils/billing'; import type { User } from '@/types/models'; import { ArrowsRightLeftIcon } from '@heroicons/vue/16/solid'; import { fetchToken, isTokenValid } from '@/utils/session'; @@ -188,6 +188,7 @@ const page = usePage<{ :current="route().current('tags')" :href="route('tags')">
- - diff --git a/resources/js/utils/billing.ts b/resources/js/utils/billing.ts index b83ef6e1..d938a62f 100644 --- a/resources/js/utils/billing.ts +++ b/resources/js/utils/billing.ts @@ -9,6 +9,14 @@ export function isBillingActivated() { return page.props.has_billing_extension; } +export function isInvoicingActivated() { + const page = usePage<{ + has_invoicing_extension: boolean; + }>(); + + return page.props.has_invoicing_extension; +} + export function isInTrial() { const page = usePage<{ billing: { diff --git a/resources/js/utils/permissions.ts b/resources/js/utils/permissions.ts index a0b0fdc2..6adb74e8 100644 --- a/resources/js/utils/permissions.ts +++ b/resources/js/utils/permissions.ts @@ -122,3 +122,7 @@ export function canDeleteReport() { export function canViewAllTimeEntries() { return currentUserHasPermission('time-entries:view:all'); } +export function canViewInvoices() { + return currentUserHasPermission('invoices:view'); +} +