import type { Metadata } from "next";
import RestaurantDemo from "../components/RestaurantDemo";
import RegisterServiceWorker from "./RegisterServiceWorker";

// The manifest is linked from this page only, so the install prompt reaches
// waiters and never guests who open the menu from a QR code.
export const metadata: Metadata = {
  title: "Moji stolovi",
  manifest: "/manifest.webmanifest",
  appleWebApp: {
    capable: true,
    title: "Moji stolovi",
    statusBarStyle: "black-translucent",
  },
  icons: {
    icon: "/icon-192.png",
    apple: "/apple-touch-icon.png",
  },
};

export const viewport = {
  themeColor: "#153e35",
  width: "device-width",
  initialScale: 1,
  viewportFit: "cover" as const,
};

export default async function WaiterPage({ searchParams }: { searchParams: Promise<{ restaurant?: string }> }) {
  const { restaurant } = await searchParams;
  const slug = restaurant && /^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(restaurant) ? restaurant : "bistro-dunav";
  return <>
    <RegisterServiceWorker />
    <RestaurantDemo initialSurface="waiter" initialSlug={slug} />
  </>;
}
