)}
{
setIngredients((prev) => {
const exists = prev.some((i) => i.id === saved.id);
const next = exists ? prev.map((i) => (i.id === saved.id ? saved : i)) : [...prev, saved];
return next.sort((a, b) => a.name.localeCompare(b.name));
});
}}
/>
!open && setConfirmId(null)}>
Delete this ingredient?
{pendingDelete ? `"${pendingDelete.name}" and its aliases will no longer be recognized as a match. Pantry items and recipe ingredients already linked to it just lose that link — nothing is deleted.` : ""}
Cancel {
if (confirmId) void handleDelete(confirmId);
setConfirmId(null);
}}
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
>
Delete