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,72 @@
|
||||
import type { NextConfig } from "next";
|
||||
import createNextIntlPlugin from "next-intl/plugin";
|
||||
import withPWAInit from "@ducanh2912/next-pwa";
|
||||
|
||||
const withNextIntl = createNextIntlPlugin("./src/i18n/request.ts");
|
||||
|
||||
const withPWA = withPWAInit({
|
||||
dest: "public",
|
||||
cacheOnFrontEndNav: true,
|
||||
aggressiveFrontEndNavCaching: true,
|
||||
reloadOnOnline: true,
|
||||
disable: process.env.NODE_ENV === "development",
|
||||
workboxOptions: {
|
||||
disableDevLogs: true,
|
||||
runtimeCaching: [
|
||||
// App shell: cache-first, very long TTL
|
||||
{
|
||||
urlPattern: /\/_next\/static\//,
|
||||
handler: "CacheFirst",
|
||||
options: {
|
||||
cacheName: "static-assets",
|
||||
expiration: { maxEntries: 200, maxAgeSeconds: 30 * 24 * 60 * 60 },
|
||||
},
|
||||
},
|
||||
// API: NetworkFirst — show cached data when offline
|
||||
{
|
||||
urlPattern: /\/api\//,
|
||||
handler: "NetworkFirst",
|
||||
options: {
|
||||
cacheName: "api-data",
|
||||
networkTimeoutSeconds: 5,
|
||||
expiration: { maxEntries: 300, maxAgeSeconds: 10 * 60 },
|
||||
},
|
||||
},
|
||||
// Menu images & media
|
||||
{
|
||||
urlPattern: /\.(?:png|jpg|jpeg|svg|gif|webp|ico)$/,
|
||||
handler: "StaleWhileRevalidate",
|
||||
options: {
|
||||
cacheName: "media-cache",
|
||||
expiration: { maxEntries: 300, maxAgeSeconds: 7 * 24 * 60 * 60 },
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const adminWebOrigin =
|
||||
process.env.ADMIN_WEB_ORIGIN ?? "http://localhost:3102";
|
||||
|
||||
const nextConfig: NextConfig = {
|
||||
output: "standalone",
|
||||
experimental: {
|
||||
optimizePackageImports: ["recharts", "lucide-react"],
|
||||
},
|
||||
async redirects() {
|
||||
return [
|
||||
{
|
||||
source: "/:locale(fa|ar|en)/admin",
|
||||
destination: `${adminWebOrigin}/:locale/admin`,
|
||||
permanent: false,
|
||||
},
|
||||
{
|
||||
source: "/:locale(fa|ar|en)/admin/:path*",
|
||||
destination: `${adminWebOrigin}/:locale/admin/:path*`,
|
||||
permanent: false,
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
||||
export default withPWA(withNextIntl(nextConfig));
|
||||
Reference in New Issue
Block a user