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:
soroush.asadi
2026-05-27 21:34:12 +03:30
parent ef15fd6247
commit 131ecdbbe6
208 changed files with 37123 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
import { toast } from "sonner";
import { ApiClientError } from "@/lib/api/client";
export type NotifyOptions = {
description?: string;
duration?: number;
};
function baseOptions(opts?: NotifyOptions) {
return {
description: opts?.description,
duration: opts?.duration ?? 4000,
};
}
/** Toast notifications — use for transient success/error/info across the app */
export const notify = {
success(message: string, opts?: NotifyOptions) {
toast.success(message, baseOptions(opts));
},
error(message: string, opts?: NotifyOptions) {
toast.error(message, { ...baseOptions(opts), duration: opts?.duration ?? 5500 });
},
warning(message: string, opts?: NotifyOptions) {
toast.warning(message, baseOptions(opts));
},
info(message: string, opts?: NotifyOptions) {
toast.info(message, baseOptions(opts));
},
loading(message: string) {
return toast.loading(message);
},
dismiss(id?: string | number) {
toast.dismiss(id);
},
promise<T>(
promise: Promise<T>,
messages: { loading: string; success: string; error?: string }
) {
return toast.promise(promise, {
loading: messages.loading,
success: messages.success,
error: messages.error ?? messages.loading,
});
},
};
export function getErrorMessage(err: unknown, fallback: string): string {
if (err instanceof ApiClientError) return err.message;
if (err instanceof Error && err.message) return err.message;
return fallback;
}
export function notifyError(err: unknown, fallback: string) {
notify.error(getErrorMessage(err, fallback));
}