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>
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
import type { LucideIcon } from "lucide-react";
|
||||
import {
|
||||
LayoutGrid,
|
||||
UtensilsCrossed,
|
||||
Users,
|
||||
Ticket,
|
||||
Package,
|
||||
BookOpen,
|
||||
UserCog,
|
||||
BarChart3,
|
||||
Calendar,
|
||||
Star,
|
||||
MessageSquare,
|
||||
Receipt,
|
||||
Settings,
|
||||
ChefHat,
|
||||
Bell,
|
||||
ListOrdered,
|
||||
Building2,
|
||||
CreditCard,
|
||||
Wallet,
|
||||
Clock,
|
||||
LifeBuoy,
|
||||
Compass,
|
||||
} from "lucide-react";
|
||||
|
||||
export type NavGroupId = "operations" | "menuSales" | "customers" | "finance" | "management";
|
||||
|
||||
export type NavItemKey =
|
||||
| "pos"
|
||||
| "tables"
|
||||
| "queue"
|
||||
| "kds"
|
||||
| "notifications"
|
||||
| "reservations"
|
||||
| "menu"
|
||||
| "inventory"
|
||||
| "coupons"
|
||||
| "crm"
|
||||
| "sms"
|
||||
| "reviews"
|
||||
| "discover"
|
||||
| "reports"
|
||||
| "expenses"
|
||||
| "shifts"
|
||||
| "taxes"
|
||||
| "hr"
|
||||
| "branches"
|
||||
| "subscription"
|
||||
| "support"
|
||||
| "settings";
|
||||
|
||||
export type NavItemDef = {
|
||||
key: NavItemKey;
|
||||
href: string;
|
||||
icon: LucideIcon;
|
||||
};
|
||||
|
||||
export type NavGroupDef = {
|
||||
id: NavGroupId;
|
||||
defaultOpen: boolean;
|
||||
items: NavItemDef[];
|
||||
};
|
||||
|
||||
export const NAV_GROUPS: NavGroupDef[] = [
|
||||
{
|
||||
id: "operations",
|
||||
defaultOpen: true,
|
||||
items: [
|
||||
{ key: "pos", href: "/pos", icon: LayoutGrid },
|
||||
{ key: "tables", href: "/tables", icon: UtensilsCrossed },
|
||||
{ key: "queue", href: "/queue", icon: ListOrdered },
|
||||
{ key: "kds", href: "/kds", icon: ChefHat },
|
||||
{ key: "notifications", href: "/notifications", icon: Bell },
|
||||
{ key: "reservations", href: "/reservations", icon: Calendar },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "menuSales",
|
||||
defaultOpen: true,
|
||||
items: [
|
||||
{ key: "menu", href: "/menu", icon: BookOpen },
|
||||
{ key: "inventory", href: "/inventory", icon: Package },
|
||||
{ key: "coupons", href: "/coupons", icon: Ticket },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "customers",
|
||||
defaultOpen: true,
|
||||
items: [
|
||||
{ key: "crm", href: "/crm", icon: Users },
|
||||
{ key: "sms", href: "/sms", icon: MessageSquare },
|
||||
{ key: "reviews", href: "/reviews", icon: Star },
|
||||
{ key: "discover", href: "/discover", icon: Compass },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "finance",
|
||||
defaultOpen: true,
|
||||
items: [
|
||||
{ key: "reports", href: "/reports", icon: BarChart3 },
|
||||
{ key: "expenses", href: "/expenses", icon: Wallet },
|
||||
{ key: "shifts", href: "/shifts", icon: Clock },
|
||||
{ key: "taxes", href: "/taxes", icon: Receipt },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "management",
|
||||
defaultOpen: true,
|
||||
items: [
|
||||
{ key: "hr", href: "/hr", icon: UserCog },
|
||||
{ key: "branches", href: "/branches", icon: Building2 },
|
||||
{ key: "subscription", href: "/subscription", icon: CreditCard },
|
||||
{ key: "settings", href: "/settings", icon: Settings },
|
||||
{ key: "support", href: "/support", icon: LifeBuoy },
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
export const NAV_GROUPS_STORAGE_KEY = "meezi:nav-groups:v3";
|
||||
|
||||
/** Branch-scoped staff only see daily operations. */
|
||||
export const BRANCH_ONLY_NAV_GROUP: NavGroupId = "operations";
|
||||
|
||||
export function findNavGroupForPath(pathname: string): NavGroupId | null {
|
||||
for (const group of NAV_GROUPS) {
|
||||
for (const item of group.items) {
|
||||
if (pathname === item.href || pathname.startsWith(`${item.href}/`)) {
|
||||
return group.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user