import type { BrowsableSourceItemView } from "@batch-cooking/shared"; import { useTranslation } from "react-i18next"; import "../recipes.scss"; /** * List of one source's browsable items (`RecipeSourcesPanel`) — same * "photo + name, click/Enter to select" row shape as `RecipeTable`, plus * an "already imported" badge in place of allergen/regime columns (a * source item has neither, it's not resolved against our catalogs until * previewed). */ export function SourceItemTable({ items, selectedExternalId, onSelect, }: { items: BrowsableSourceItemView[]; selectedExternalId: string | null; onSelect: (item: BrowsableSourceItemView) => void; }) { const { t } = useTranslation(); return (
{items.map((item) => ( onSelect(item)} onKeyDown={(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); onSelect(item); } }} tabIndex={0} aria-current={item.externalId === selectedExternalId ? "true" : undefined} > ))}
{t("recipes.table.name")}
{item.title} {item.alreadyImported && ( {t("recipes.sources.alreadyImported")} )}
); }