feat: admin Ingredients CRUD UI; fix "page not found" after deleting shopping list/recipe/collection (v0.85.0)
Admin > Ingredients lets admins add/edit/delete canonical ingredients and their aliases (e.g. "sel"/"sel fin"/"table salt") without touching code — previously only settable by hand in packages/db/src/seed.ts. Deleting just unlinks referencing pantry items/recipe ingredients (onDelete: set null), nothing else changes. Fixed: deleting a shopping list, recipe, or collection from its own detail page used router.push to navigate away, leaving the deleted resource's URL in browser history — one back-button press landed on a real "Page not found" screen. All three now use router.replace so the dead URL never sits in history. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { Metadata } from "next";
|
||||
import { db, ingredients, asc } from "@epicure/db";
|
||||
import { requireFullAdminPage } from "@/lib/require-admin-page";
|
||||
import { IngredientsManager } from "@/components/admin/ingredients-manager";
|
||||
|
||||
export const metadata: Metadata = {};
|
||||
|
||||
export default async function AdminIngredientsPage() {
|
||||
await requireFullAdminPage();
|
||||
|
||||
const rows = await db.select().from(ingredients).orderBy(asc(ingredients.name));
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold tracking-tight">Ingredients</h1>
|
||||
<p className="text-muted-foreground text-sm mt-1">
|
||||
Canonical ingredients and their name variants (e.g. "sel", "sel fin", "table salt") — lets pantry items and recipe ingredients written differently still be recognized as the same thing. Used by pantry add/edit, can-cook scoring, auto-deduct on cook, and shopping-list pantry-awareness.
|
||||
</p>
|
||||
</div>
|
||||
<IngredientsManager
|
||||
initialIngredients={rows.map((r) => ({
|
||||
id: r.id,
|
||||
name: r.name,
|
||||
aliases: r.aliases,
|
||||
category: r.category,
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user