import { prisma } from "@/lib/prisma"; import { getYouTubeId } from "@/lib/utils"; import { getLocale } from "next-intl/server"; import { notFound } from "next/navigation"; import { use } from "react"; export default async function Page({ params }: { params: Promise<{ slug: string }> }) { const { slug } = await params; const locale = await getLocale(); const menu = await prisma.menu.findUnique({ where: { slug: slug, }, include: { videos: { where: { isPublic: true, }, orderBy: { createdAt: 'desc', }, }, }, }); if (!menu) { notFound(); } const getLocalizedText = (json: any) => { if (!json) return ''; return json[locale] || json['id'] || json['en'] || ''; }; return (

{getLocalizedText(menu.name)}

') }}>
{menu.videos.length > 0 ? ( menu.videos.map((video) => { const youtubeId = video?.videoUrl ? getYouTubeId(video.videoUrl) : null; const embedUrl = youtubeId ? `https://www.youtube.com/embed/${youtubeId}` : video?.videoUrl; return (
{/* Video Thumbnail/Embed Placeholder */}
{youtubeId ? ( ) : (
Video format not supported or invalid URL
)}

{video.title}

{video.description && (

{video.description}

)}
) }) ) : (

Belum ada video di menu ini.

)}
); }