Add per-restaurant macros toggle and public list view
Feature 1 — showMacros toggle: - Restaurant.showMacros boolean (default false) so existing menus (e.g. NOCNEX) never publish with empty macros (migration 0004; default applies to existing rows) - Editor toggle in the Palette tab, saved via the existing /settings endpoint - Read live (not from the snapshot) in the public page and /menu API so it takes effect immediately without republishing; old snapshots default off - When off, the public menu hides every macro layer: card flip + 'tap to see macros', the gallery macros, and the macro color-code legend Feature 2 — public list view: - Card/list toggle in the public menu; preference is NOT persisted (always starts on cards) - New ListRow: compact traditional rows (name + price + allergen tags); tap the name to expand image + description (accordion); tap the image to reveal macros (only when showMacros is on) i18n: viewCards/viewList (menu) and showMacros/showMacrosHint (editor) in es/en at parity. Glassmorphism, mobile-first and safe areas preserved. Existing features untouched (versioning, import, consultant, QR, i18n). Verified: build passes; 4 migrations apply in order; existing rows default false; toggling via /settings updates /menu live without republish.
This commit is contained in:
1 parent
d71ede3d00
commit
084a191061
17 files changed
+241
-28
No files matched your search
@@ -16,5 +16,8 @@ export async function GET(_req: Request, { params }: { params: { slug: string }
|
||||
if (!restaurant.publishedVersion) {
|
||||
return NextResponse.json({ error: 'not_published' }, { status: 404 });
|
||||
}
|
||||
return NextResponse.json(restaurant.publishedVersion.snapshot as unknown as MenuSnapshot);
|
||||
const snapshot = restaurant.publishedVersion.snapshot as unknown as MenuSnapshot;
|
||||
// Read showMacros live so the toggle applies without republishing.
|
||||
snapshot.restaurant.showMacros = restaurant.showMacros;
|
||||
return NextResponse.json(snapshot);
|
||||
}
|
||||
@@ -8,8 +8,9 @@ export async function PATCH(req: Request, { params }: { params: { slug: string }
|
||||
if ('error' in guard) return guard.error;
|
||||
|
||||
const body = await req.json().catch(() => null);
|
||||
const data: { ordersEnabled?: boolean; defaultLocale?: string } = {};
|
||||
const data: { ordersEnabled?: boolean; defaultLocale?: string; showMacros?: boolean } = {};
|
||||
if (typeof body?.ordersEnabled === 'boolean') data.ordersEnabled = body.ordersEnabled;
|
||||
if (typeof body?.showMacros === 'boolean') data.showMacros = body.showMacros;
|
||||
if (body?.defaultLocale === 'es' || body?.defaultLocale === 'en') {
|
||||
data.defaultLocale = body.defaultLocale;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user