From 084a191061a52f28f9acc0f58bd22dfa8aecae3b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jorem=20Ju=C3=A1rez?=
Date: Mon, 15 Jun 2026 14:32:44 -0600
Subject: [PATCH] Add per-restaurant macros toggle and public list view
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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.
---
messages/en.json | 8 +-
messages/es.json | 8 +-
.../0004_restaurant_show_macros/migration.sql | 2 +
prisma/schema.prisma | 2 +
src/app/[slug]/editor/page.tsx | 1 +
src/app/[slug]/page.tsx | 7 +-
src/app/api/[slug]/menu/route.ts | 5 +-
src/app/api/[slug]/settings/route.ts | 3 +-
src/components/editor/Editor.tsx | 8 +-
src/components/editor/PaletteTab.tsx | 30 ++++++
src/components/editor/types.ts | 1 +
src/components/public/DishCard.tsx | 41 ++++---
src/components/public/Gallery.tsx | 4 +-
src/components/public/ListRow.tsx | 101 ++++++++++++++++++
src/components/public/PublicMenu.tsx | 46 +++++++-
src/lib/menu.ts | 1 +
src/lib/types.ts | 1 +
17 files changed, 241 insertions(+), 28 deletions(-)
create mode 100644 prisma/migrations/0004_restaurant_show_macros/migration.sql
create mode 100644 src/components/public/ListRow.tsx
diff --git a/messages/en.json b/messages/en.json
index 719d78c..2fa5f67 100644
--- a/messages/en.json
+++ b/messages/en.json
@@ -27,7 +27,9 @@
"waiterCalled": "The waiter is on the way",
"orderSent": "Your order was sent",
"macroLegend": "Macro color code",
- "tapToFlip": "Tap to see macros"
+ "tapToFlip": "Tap to see macros",
+ "viewCards": "Cards",
+ "viewList": "List"
},
"macros": {
"protein": "Protein",
@@ -85,7 +87,9 @@
"publicLink": "Public link",
"copyLink": "Copy link",
"copied": "Copied",
- "paletteHint": "This does not affect the macro color code"
+ "paletteHint": "This does not affect the macro color code",
+ "showMacros": "Show macros on the menu",
+ "showMacrosHint": "When off, the public menu shows no macro layer at all."
},
"qr": {
"templates": "Templates",
diff --git a/messages/es.json b/messages/es.json
index e14b6ff..5fd9a1e 100644
--- a/messages/es.json
+++ b/messages/es.json
@@ -27,7 +27,9 @@
"waiterCalled": "El mesero va en camino",
"orderSent": "Tu orden fue enviada",
"macroLegend": "Código de color de macros",
- "tapToFlip": "Toca para ver macros"
+ "tapToFlip": "Toca para ver macros",
+ "viewCards": "Tarjetas",
+ "viewList": "Lista"
},
"macros": {
"protein": "Proteína",
@@ -85,7 +87,9 @@
"publicLink": "Link público",
"copyLink": "Copiar link",
"copied": "Copiado",
- "paletteHint": "Esto no afecta el código de color de macros"
+ "paletteHint": "Esto no afecta el código de color de macros",
+ "showMacros": "Mostrar macros en el menú",
+ "showMacrosHint": "Si está apagado, el menú público no muestra ninguna capa de macros."
},
"qr": {
"templates": "Plantillas",
diff --git a/prisma/migrations/0004_restaurant_show_macros/migration.sql b/prisma/migrations/0004_restaurant_show_macros/migration.sql
new file mode 100644
index 0000000..40ca7d1
--- /dev/null
+++ b/prisma/migrations/0004_restaurant_show_macros/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "Restaurant" ADD COLUMN "showMacros" BOOLEAN NOT NULL DEFAULT false;
diff --git a/prisma/schema.prisma b/prisma/schema.prisma
index dba2ca8..ff5cdd5 100644
--- a/prisma/schema.prisma
+++ b/prisma/schema.prisma
@@ -20,6 +20,8 @@ model Restaurant {
palette Json @default("{}")
qrConfig Json @default("{}") // artistic QR styling (qr-code-styling config)
ordersEnabled Boolean @default(false)
+ showMacros Boolean @default(false) // when false, the public menu hides all macro layers
+
defaultLocale String @default("es")
active Boolean @default(true)
publishedVersionId String? @unique
diff --git a/src/app/[slug]/editor/page.tsx b/src/app/[slug]/editor/page.tsx
index 9c8faa1..d25e179 100644
--- a/src/app/[slug]/editor/page.tsx
+++ b/src/app/[slug]/editor/page.tsx
@@ -37,6 +37,7 @@ export default async function EditorPage({
slug: restaurant.slug,
name: restaurant.name,
ordersEnabled: restaurant.ordersEnabled,
+ showMacros: restaurant.showMacros,
defaultLocale: restaurant.defaultLocale as 'es' | 'en',
palette: (restaurant.palette as Palette) ?? {},
qrConfig: (restaurant.qrConfig as QrConfig) ?? {},
diff --git a/src/app/[slug]/page.tsx b/src/app/[slug]/page.tsx
index 5081bee..5269be9 100644
--- a/src/app/[slug]/page.tsx
+++ b/src/app/[slug]/page.tsx
@@ -21,11 +21,16 @@ async function getPublishedMenu(slug: string): Promise {
palette: (restaurant.palette as MenuSnapshot['restaurant']['palette']) ?? {},
ordersEnabled: restaurant.ordersEnabled,
defaultLocale: restaurant.defaultLocale as 'es' | 'en',
+ showMacros: restaurant.showMacros,
},
sections: [],
};
}
- return restaurant.publishedVersion.snapshot as unknown as MenuSnapshot;
+ const snapshot = restaurant.publishedVersion.snapshot as unknown as MenuSnapshot;
+ // showMacros is read live (not from the snapshot) so toggling it takes effect
+ // immediately without republishing — and old snapshots without the flag default off.
+ snapshot.restaurant.showMacros = restaurant.showMacros;
+ return snapshot;
}
export default async function PublicMenuPage({ params }: { params: { slug: string } }) {
diff --git a/src/app/api/[slug]/menu/route.ts b/src/app/api/[slug]/menu/route.ts
index 3d7d57a..7721636 100644
--- a/src/app/api/[slug]/menu/route.ts
+++ b/src/app/api/[slug]/menu/route.ts
@@ -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);
}
diff --git a/src/app/api/[slug]/settings/route.ts b/src/app/api/[slug]/settings/route.ts
index ecad385..12d93c9 100644
--- a/src/app/api/[slug]/settings/route.ts
+++ b/src/app/api/[slug]/settings/route.ts
@@ -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;
}
diff --git a/src/components/editor/Editor.tsx b/src/components/editor/Editor.tsx
index facf47d..d7c2ad8 100644
--- a/src/components/editor/Editor.tsx
+++ b/src/components/editor/Editor.tsx
@@ -49,7 +49,13 @@ export default function Editor({ data, baseUrl }: { data: EditorData; baseUrl: s
onRestored={(name) => setPublishedName(name)}
/>
)}
- {tab === 'palette' && }
+ {tab === 'palette' && (
+
+ )}
{tab === 'orders' && (
⚠️ {t('paletteHint')}
+ {/* Show-macros toggle (controls whether the public menu exposes any macro layer) */}
+
+
+
{t('showMacros')}
+
{t('showMacrosHint')}
+
+
+
+