import type { Metadata } from "next";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { NutritionDiary } from "@/components/nutrition/nutrition-diary";
import { NutritionTrend } from "@/components/nutrition/nutrition-trend";
import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs";
import { getMessages } from "@/lib/i18n/server";

export const metadata: Metadata = {};

export default async function NutritionDiaryPage() {
  const session = await auth.api.getSession({ headers: await headers() });
  if (!session) return null;
  const m = getMessages((session.user as { locale?: string }).locale);

  return (
    <div className="space-y-8">
      <div>
        <h1 className="text-2xl font-bold tracking-tight">{m.nutritionDiary.title}</h1>
        <p className="text-muted-foreground mt-1">{m.nutritionDiary.subtitle}</p>
      </div>
      <Tabs defaultValue="diary" className="gap-6">
        <TabsList>
          <TabsTrigger value="diary">{m.nutritionDiary.tabDiary}</TabsTrigger>
          <TabsTrigger value="trend">{m.nutritionDiary.tabTrend}</TabsTrigger>
        </TabsList>
        <TabsContent value="diary">
          <NutritionDiary />
        </TabsContent>
        <TabsContent value="trend">
          <NutritionTrend />
        </TabsContent>
      </Tabs>
    </div>
  );
}
