Fix endcustomer package allocation and event create gating
This commit is contained in:
@@ -85,6 +85,20 @@ function resellerHasRemainingEvents(pkg: TenantPackageSummary): boolean {
|
||||
return limitMaxEvents > usedEvents;
|
||||
}
|
||||
|
||||
function endcustomerHasRemainingEvents(pkg: TenantPackageSummary): boolean {
|
||||
if (pkg.package_type !== 'endcustomer') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const linkedEvents = toNumber(pkg.linked_events_count) ?? 0;
|
||||
|
||||
return linkedEvents < 1;
|
||||
}
|
||||
|
||||
function packageHasRemainingEvents(pkg: TenantPackageSummary): boolean {
|
||||
return resellerHasRemainingEvents(pkg) || endcustomerHasRemainingEvents(pkg);
|
||||
}
|
||||
|
||||
export function MobileShell({ title, subtitle, children, activeTab, onBack, headerActions }: MobileShellProps) {
|
||||
const { events, activeEvent, selectEvent } = useEventContext();
|
||||
const { user } = useAuth();
|
||||
@@ -219,7 +233,7 @@ export function MobileShell({ title, subtitle, children, activeTab, onBack, head
|
||||
}
|
||||
|
||||
const activePackages = collectActivePackages(packagesOverview ?? null);
|
||||
return activePackages.some((pkg) => resellerHasRemainingEvents(pkg));
|
||||
return activePackages.some((pkg) => packageHasRemainingEvents(pkg));
|
||||
}, [isMember, isSuperAdmin, packagesLoading, packagesOverview]);
|
||||
|
||||
// --- CONTEXT PILL ---
|
||||
|
||||
Reference in New Issue
Block a user