Neue interne Route Handler unter app/api/ (dishes inkl. Bulk-Delete, sections, allergens, additives, menu-entries, dish-suggestions, settings, admin/branding) ersetzen den direkten Browser→Postgrest- Zugriff der bisherigen Supabase-Anbindung. Jede Route prüft Autorisierung selbst (lib/auth/session.ts requireRole) statt sich auf Postgres-RLS zu verlassen – ersetzt 1:1 die bisherigen Policies (öffentlich lesbar / staff+admin schreiben / nur admin für Einstellungen & Benutzer). Rezeptvorschlag-Dublettencheck (SuggestionForm) läuft jetzt zwingend serverseitig im POST-Handler, da es keinen Browser→Postgres-Pfad mehr gibt. "Passkey annehmen" (SuggestionReview) läuft transaktional (Gericht anlegen + Vorschlag löschen in einem Schritt). Logo/Favicon: neuer lokaler Dateispeicher (lib/branding.ts, Docker- Volume) statt Supabase-Storage-Bucket, ausgeliefert über app/branding/[filename]. logoUrl()/faviconUrl() liefern jetzt einfache relative Pfade statt einer fest verdrahteten Supabase-Storage-URL. DeepL-Route (api/translate) und Benutzerverwaltung (api/admin/users) laufen jetzt gegen die users-Tabelle statt Supabase Auth. Alle "use client"-Manager-Komponenten (DishManager, WeekEditor, SectionManager, CodeListManager, SuggestionForm/Review, UserManager, DesignEditor) rufen ihre jeweiligen /api/-Routen per fetch() statt den Supabase-Browser-Client zu nutzen.
99 lines
2.3 KiB
TypeScript
99 lines
2.3 KiB
TypeScript
export type Role = "admin" | "staff";
|
|
|
|
export interface Profile {
|
|
id: string;
|
|
email: string;
|
|
full_name: string;
|
|
role: Role;
|
|
password_auth_enabled: boolean;
|
|
created_at: string;
|
|
}
|
|
|
|
export interface Section {
|
|
key: string;
|
|
label: string;
|
|
label_en: string | null;
|
|
label_pl: string | null;
|
|
time_range: string;
|
|
sort: number;
|
|
}
|
|
|
|
export interface Dish {
|
|
id: string;
|
|
name: string;
|
|
name_en: string | null;
|
|
name_pl: string | null;
|
|
price: number;
|
|
allergens: string[];
|
|
additives: string[];
|
|
}
|
|
|
|
export interface MenuEntry {
|
|
id: string;
|
|
menu_date: string;
|
|
section_key: string;
|
|
position: number;
|
|
dish: Dish;
|
|
}
|
|
|
|
export interface CodeItem {
|
|
code: string;
|
|
name: string;
|
|
name_en: string | null;
|
|
name_pl: string | null;
|
|
sort: number;
|
|
}
|
|
|
|
export interface DishSuggestion {
|
|
id: string;
|
|
name: string;
|
|
description: string | null;
|
|
created_at: string;
|
|
}
|
|
|
|
/** Übersetzten Namen für die aktuelle Sprache liefern, sonst Deutsch als Fallback. */
|
|
export function localized(
|
|
item: { name?: string; label?: string; name_en?: string | null; name_pl?: string | null; label_en?: string | null; label_pl?: string | null },
|
|
locale: string
|
|
): string {
|
|
const de = item.name ?? item.label ?? "";
|
|
if (locale === "en") return item.name_en || item.label_en || de;
|
|
if (locale === "pl") return item.name_pl || item.label_pl || de;
|
|
return de;
|
|
}
|
|
|
|
// Farb-Defaults (r-hofmann.de: Blau #003388, Navy #0d315c, Orange #ff6900)
|
|
export const DEFAULT_COLORS: Record<string, string> = {
|
|
primary: "#003388",
|
|
primaryDark: "#0d315c",
|
|
accent: "#ff6900",
|
|
headerText: "#ffffff",
|
|
rowBg: "#e3e4f1",
|
|
rowBgAlt: "#f4f4fa",
|
|
addBtn: "#6da54c",
|
|
deleteBtn: "#e2371d",
|
|
};
|
|
|
|
export const COLOR_VARS: Record<string, string> = {
|
|
primary: "--c-primary",
|
|
primaryDark: "--c-primary-dark",
|
|
accent: "--c-accent",
|
|
headerText: "--c-header-text",
|
|
rowBg: "--c-row-bg",
|
|
rowBgAlt: "--c-row-bg-alt",
|
|
addBtn: "--c-add",
|
|
deleteBtn: "--c-del",
|
|
};
|
|
|
|
export function logoUrl(path: string | null | undefined): string | null {
|
|
if (!path) return null;
|
|
return `/branding/${path}`;
|
|
}
|
|
|
|
export function faviconUrl(path: string | null | undefined): string | null {
|
|
if (!path) return null;
|
|
return `/branding/${path}`;
|
|
}
|
|
|
|
export const SITE_TITLE = process.env.SITE_TITLE?.trim() || "Canteen Menu";
|