Files
meezi/web/dashboard/src/lib/auth-permissions.ts
T
soroush.asadi 131ecdbbe6 feat(dashboard): Next.js 16 merchant panel with offline POS and PWA
Complete merchant dashboard upgrade:

Next.js 16 compatibility:
- Fix params/searchParams typed as Promise<{}> throughout App Router
- Replace middleware.ts with proxy.ts (Next.js 16 convention)
- Remove unused @ts-expect-error directives caught by stricter TS
- Cast dynamic next-intl t() keys to fix TranslateArgs type errors

Offline POS:
- IndexedDB queue (meezi_pos_offline) for orders created while offline
- Zustand sync store tracking queueCount, isSyncing, isOnline
- useOfflineSync hook: auto-syncs on reconnect/visibility-change
- SyncStatusIndicator chip in topbar (amber=offline, blue=syncing)
- submitOrderToApi falls back to local order on network failure
- Local orders skip payment flow; sync on reconnect

PWA (installable):
- @ducanh2912/next-pwa with Workbox runtime caching rules
- Web App Manifest (manifest.ts) — RTL/Farsi, theme #0F6E56
- PWA icons: 192px, 512px, maskable 512px
- next.config.ts replaces next.config.mjs

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-05-27 21:34:12 +03:30

39 lines
1.0 KiB
TypeScript

import { BRANCH_ONLY_NAV_GROUP, type NavGroupId } from "@/lib/sidebar-nav";
/** Cafe owner (HQ) — billing, taxes, branches. */
export function isCafeOwner(role: string | undefined): boolean {
return role === "Owner";
}
/** Logged in as a branch-scoped employee (JWT branchId). */
export function isBranchAccount(branchId: string | null | undefined): boolean {
return !!branchId;
}
export const OWNER_ONLY_NAV_KEYS = ["subscription", "taxes", "branches"] as const;
export function canSeeNavGroup(
groupId: NavGroupId,
role: string | undefined,
branchId: string | null | undefined
): boolean {
if (isBranchAccount(branchId) && groupId !== BRANCH_ONLY_NAV_GROUP) {
return false;
}
return true;
}
export function canSeeNavItem(
key: string,
role: string | undefined,
branchId: string | null | undefined
): boolean {
if ((OWNER_ONLY_NAV_KEYS as readonly string[]).includes(key) && !isCafeOwner(role)) {
return false;
}
if (key === "branches" && isBranchAccount(branchId)) {
return false;
}
return true;
}