8b749f432e
Every "nothing here" page had its own copy-pasted dashed-border box — icon + one muted line, inconsistent (some had a CTA, some didn't, no description text anywhere). Replaced with one shared EmptyState component: icon in a soft tinted circle, a real heading plus optional description, and primary/secondary actions (either a Link or an arbitrary action slot for things like "New Collection" that open a dialog rather than navigate). Applied to: recipes (no recipes / no search match), favorites, feed (no one followed / no new posts / trending / for-you), collections (index + detail), shopping lists, pantry, notifications, can-cook. Left the small inline "no trending"/"no recent" lines inside Explore's already-labeled sections and the notification-bell dropdown alone — different context, a full empty-state box would be heavier than the space warrants. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
109 lines
3.8 KiB
TypeScript
109 lines
3.8 KiB
TypeScript
"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 (
|
|
<div className="space-y-6">
|
|
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between">
|
|
<div>
|
|
<h1 className="text-3xl font-bold tracking-tight">{t("title")}</h1>
|
|
<p className="text-muted-foreground mt-1">{t("subtitle")}</p>
|
|
</div>
|
|
<NewShoppingListButton />
|
|
</div>
|
|
|
|
{lists.length === 0 ? (
|
|
<EmptyState
|
|
icon={ShoppingCart}
|
|
title={t("empty")}
|
|
description={t("emptyDescription")}
|
|
actionSlot={<NewShoppingListButton />}
|
|
/>
|
|
) : (
|
|
<div className="space-y-3 max-w-lg">
|
|
{lists.map((list) => (
|
|
<Link
|
|
key={list.id}
|
|
href={`/shopping-lists/${list.id}`}
|
|
className="flex items-center justify-between gap-2 rounded-xl border p-4 hover:shadow-sm transition-shadow"
|
|
>
|
|
<div className="space-y-1 min-w-0">
|
|
<h2 className="font-semibold truncate">{list.name}</h2>
|
|
<p className="text-sm text-muted-foreground">
|
|
{list.totalItems === 0
|
|
? t("listEmpty")
|
|
: t("items", { checked: list.checkedItems, total: list.totalItems })}
|
|
{list.generatedAt && ` · ${t("generated")}`}
|
|
</p>
|
|
</div>
|
|
<div className="flex items-center gap-1 shrink-0">
|
|
<div className="h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-bold">
|
|
{list.totalItems === 0 ? "—" : `${Math.round((list.checkedItems / list.totalItems) * 100)}%`}
|
|
</div>
|
|
<ShoppingListActionsMenu
|
|
listId={list.id}
|
|
name={list.name}
|
|
onRenamed={(name) =>
|
|
setLists((prev) => prev.map((l) => (l.id === list.id ? { ...l, name } : l)))
|
|
}
|
|
onDeleted={() => setLists((prev) => prev.filter((l) => l.id !== list.id))}
|
|
/>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
)}
|
|
|
|
{sharedLists.length > 0 && (
|
|
<div className="space-y-3 max-w-lg">
|
|
<h2 className="text-sm font-semibold text-muted-foreground">{t("sharedWithYou")}</h2>
|
|
{sharedLists.map((list) => (
|
|
<Link
|
|
key={list.id}
|
|
href={`/shopping-lists/${list.id}`}
|
|
className="flex items-center justify-between rounded-xl border p-4 hover:shadow-sm transition-shadow"
|
|
>
|
|
<div className="space-y-1">
|
|
<h3 className="font-semibold">{list.name}</h3>
|
|
<p className="text-sm text-muted-foreground">
|
|
{list.ownerName} · {ts(list.role)}
|
|
</p>
|
|
</div>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|