fix: resolve slug fallback rendering for demo/gusto-brasserie and add root [slug] routing

This commit is contained in:
AyrisAI
2026-08-20 17:05:45 +03:00
parent 6055130828
commit b7e128fb8c
6 changed files with 83 additions and 27 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"expo": {}
}
Binary file not shown.
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
import PublicMenuPage, { generateMetadata } from "@/app/menu/[slug]/page";
export { generateMetadata };
export default PublicMenuPage;
+42 -14
View File
@@ -2,6 +2,7 @@ import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { supabase } from "@/lib/supabase";
import { PublicMenuClient, type MenuCategory, type MenuItem, type RestaurantData } from "@/components/PublicMenuClient";
import { DEMO_RESTAURANT, DEMO_CATEGORIES } from "@/lib/demo-data";
import type { ThemeConfig } from "@menulio/shared";
type PageProps = {
@@ -37,6 +38,8 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
if (bySlug) {
restaurant = bySlug;
} else if (slug === "demo" || slug === "gusto-brasserie") {
restaurant = DEMO_RESTAURANT;
} else {
const { data: domainRow } = await supabase
.from("domains")
@@ -93,17 +96,39 @@ export default async function PublicMenuPage({ params, searchParams }: PageProps
}
}
if (!restaurant) notFound();
if (!restaurant) {
if (slug === "demo" || slug === "gusto-brasserie") {
return (
<PublicMenuClient
restaurant={DEMO_RESTAURANT}
categories={DEMO_CATEGORIES}
initialThemeKey={themeParam || "coastal"}
/>
);
}
notFound();
}
const { data: menu } = await supabase
// Find menu (published or any available menu)
let { data: menu } = await supabase
.from("menus")
.select("id, name, locations!inner(restaurant_id)")
.eq("locations.restaurant_id", restaurant.id)
.eq("is_published", true)
.maybeSingle();
if (!menu) notFound();
if (!menu) {
const { data: anyMenu } = await supabase
.from("menus")
.select("id, name, locations!inner(restaurant_id)")
.eq("locations.restaurant_id", restaurant.id)
.maybeSingle();
menu = anyMenu;
}
let categories: MenuCategory[] = [];
if (menu) {
const { data: rawCategories } = await supabase
.from("menu_categories")
.select("id, name, description, is_active, menu_items(id, name, description, price, image_url, is_active)")
@@ -112,17 +137,7 @@ export default async function PublicMenuPage({ params, searchParams }: PageProps
.order("sort_order", { ascending: true })
.returns<MenuCategoryRow[]>();
const { data: themeRow } = await supabase
.from("restaurant_themes")
.select("overrides, themes(key, config)")
.eq("restaurant_id", restaurant.id)
.maybeSingle();
const themeRelation = themeRow?.themes as unknown as { key?: string; config?: Partial<ThemeConfig> } | null;
const themeKey = themeParam || themeRelation?.key || "elegant";
const customConfig = (themeRow?.overrides as Partial<ThemeConfig>) || themeRelation?.config;
const categories: MenuCategory[] = (rawCategories ?? []).map((cat) => ({
categories = (rawCategories ?? []).map((cat) => ({
id: cat.id,
name: cat.name,
description: cat.description,
@@ -138,6 +153,19 @@ export default async function PublicMenuPage({ params, searchParams }: PageProps
is_active: item.is_active,
})),
}));
} else if (slug === "demo" || slug === "gusto-brasserie") {
categories = DEMO_CATEGORIES;
}
const { data: themeRow } = await supabase
.from("restaurant_themes")
.select("overrides, themes(key, config)")
.eq("restaurant_id", restaurant.id)
.maybeSingle();
const themeRelation = themeRow?.themes as unknown as { key?: string; config?: Partial<ThemeConfig> } | null;
const themeKey = themeParam || themeRelation?.key || "elegant";
const customConfig = (themeRow?.overrides as Partial<ThemeConfig>) || themeRelation?.config;
const restaurantData: RestaurantData = {
id: restaurant.id,
+21
View File
@@ -0,0 +1,21 @@
{
"cli": {
"version": ">= 22.0.0",
"appVersionSource": "remote"
},
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal"
},
"production": {
"autoIncrement": true
}
},
"submit": {
"production": {}
}
}