"use client"; // Mobile Ansicht der öffentlichen Speisekarte: Tag (Standard) oder Woche, // umschaltbar ohne Seiten-Reload. Ab dem "sm"-Breakpoint übernimmt die // normale Wochentabelle (siehe app/page.tsx), diese Komponente blendet // sich dort per CSS aus. import Link from "next/link"; import { useRouter } from "next/navigation"; import { useState } from "react"; import { addDays, dishCodes, entriesFor, formatDateLong, formatPrice, mondayOf, todayISO, weekdayIndex, WEEKDAYS, WEEKDAYS_SHORT, } from "@/lib/menu"; import type { MenuEntry, Section } from "@/lib/types"; export default function PublicMobileMenu({ monday, sections, entries, }: { monday: string; sections: Section[]; entries: MenuEntry[]; }) { const router = useRouter(); const days = WEEKDAYS.map((weekday, i) => ({ weekday, short: WEEKDAYS_SHORT[i], iso: addDays(monday, i), })); const isCurrentWeek = monday === mondayOf(todayISO()); const todayIdx = isCurrentWeek ? weekdayIndex(todayISO()) : -1; const [tab, setTab] = useState<"tag" | "woche">("tag"); const [selectedIdx, setSelectedIdx] = useState(todayIdx >= 0 ? todayIdx : 0); function goToday() { const currentMonday = mondayOf(todayISO()); if (currentMonday === monday) { const idx = weekdayIndex(todayISO()); setSelectedIdx(idx >= 0 ? idx : 0); setTab("tag"); } else { router.push(`/?woche=${currentMonday}`); } } function renderDay(day: { weekday: string; iso: string }) { return (
–
) : ( items.map((e) => { const codes = dishCodes(e.dish); return ({e.dish.name} {codes && {codes}}{" "} – {formatPrice(e.dish.price)}
); }) )}