"use client"; import Link from "next/link"; import Image from "next/image"; import { useTranslations, useLocale } from "next-intl"; import { Flame, ChefHat, History } from "lucide-react"; import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs"; import { getPublicUrl } from "@/lib/storage"; export type HistoryEntry = { id: string; recipeId: string; recipeTitle: string; cookedAt: string; servings: number | null; }; export type HistoryData = { totalCooked: number; streak: number; lastCooked: { recipeId: string; recipeTitle: string; cookedAt: string } | null; recentEntries: HistoryEntry[]; }; export type PhotoItem = { id: string; recipeId: string; recipeTitle: string; photoKey: string; createdAt: string; }; export type PhotosData = { items: PhotoItem[]; page: number; totalPages: number; total: number; }; function StatCard({ label, value }: { label: string; value: React.ReactNode }) { return (

{label}

{value}

); } export function ProfileTabs({ username, defaultTab, recipesContent, history, photos, }: { username: string; defaultTab: string; recipesContent: React.ReactNode; history: HistoryData; photos: PhotosData; }) { const t = useTranslations("profilePage"); const locale = useLocale(); return ( {t("tabRecipes")} {t("tabHistory")} {t("tabPhotos")} {recipesContent}
{history.totalCooked} } /> {t("streakDays", { count: history.streak })} } /> {history.lastCooked.recipeTitle} ) : ( {t("noneYet")} ) } />
{history.recentEntries.length > 0 ? (

{t("recentActivity")}

{history.recentEntries.map((entry) => ( {entry.recipeTitle} {new Date(entry.cookedAt).toLocaleDateString(locale)} ))}
) : (

{t("noHistoryYet")}

)}
{photos.items.length > 0 ? (
{photos.items.map((photo) => (
{photo.recipeTitle}

{photo.recipeTitle}

))}
{photos.totalPages > 1 && (
{photos.page > 1 && ( {t("previous")} )} {t("pageOf", { page: photos.page, total: photos.totalPages })} {photos.page < photos.totalPages && ( {t("next")} )}
)}
) : (

{t("noPhotosYet")}

)}
); }