"use client"; import { useState } from "react"; import { useTranslations } from "next-intl"; import Link from "next/link"; import { ShoppingCart } from "lucide-react"; import { NewShoppingListButton } from "@/components/meal-plan/new-shopping-list-button"; import { ShoppingListActionsMenu } from "@/components/shopping-lists/shopping-list-actions-menu"; import { EmptyState } from "@/components/shared/empty-state"; type ShoppingListItem = { id: string; name: string; generatedAt: string | null; totalItems: number; checkedItems: number; }; type SharedListItem = { id: string; name: string; ownerName: string; role: "viewer" | "editor"; }; type Props = { lists: ShoppingListItem[]; sharedLists?: SharedListItem[]; }; export function ShoppingListsPageContent({ lists: initialLists, sharedLists = [] }: Props) { const t = useTranslations("shoppingLists"); const ts = useTranslations("shareDialog"); const [lists, setLists] = useState(initialLists); return (

{t("title")}

{t("subtitle")}

{lists.length === 0 ? ( } /> ) : (
{lists.map((list) => (

{list.name}

{list.totalItems === 0 ? t("listEmpty") : t("items", { checked: list.checkedItems, total: list.totalItems })} {list.generatedAt && ` · ${t("generated")}`}

{list.totalItems === 0 ? "—" : `${Math.round((list.checkedItems / list.totalItems) * 100)}%`}
setLists((prev) => prev.map((l) => (l.id === list.id ? { ...l, name } : l))) } onDeleted={() => setLists((prev) => prev.filter((l) => l.id !== list.id))} />
))}
)} {sharedLists.length > 0 && (

{t("sharedWithYou")}

{sharedLists.map((list) => (

{list.name}

{list.ownerName} · {ts(list.role)}

))}
)}
); }