Files
Epicure/apps/web/app/(app)/recipes/can-cook/page.tsx
T
Arnaud 93936eae10 feat: pantry notes/categories, ingredient-alias matching, cook-log edit/delete, fork-list popover (v0.83.0)
Pantry: notes + category fields (collapsible grouping like the shopping list), a "Merge duplicates" cleanup action, and fixed quantity display precision (was showing raw decimal(10,4) strings like "0.3333 kg" everywhere — pantry, shopping list, print views, Markdown exports).

Ingredient-alias matching: the ingredients table (canonical name + aliases) existed but was never populated or used. Seeded ~10 bilingual EN/FR staples and wired resolution into pantry add/edit, can-cook scoring, auto-deduct-on-cook, and shopping-list pantry-awareness, so "sel"/"sel fin"/"table salt" are recognized as the same ingredient.

Cook log: entries from "Mark cooked" can now be edited and deleted (previously log-only, no fix-a-mistake path). The "Cooked N times" text is a hover tooltip listing every date and opens a full manage sheet on click.

Also: the "Forked by N others" backlink is now a click-to-open popover instead of an always-inline list.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 15:13:33 +02:00

46 lines
1.5 KiB
TypeScript

import type { Metadata } from "next";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { db, recipes, pantryItems } from "@epicure/db";
import { eq } from "@epicure/db";
import { getPublicUrl } from "@/lib/storage";
import { CanCookContent } from "@/components/recipe/can-cook-content";
import { scoreRecipesAgainstPantry } from "@/lib/pantry-match";
import { loadIngredientAliasIndex } from "@/lib/ingredient-match";
export const metadata: Metadata = {};
export default async function CanCookPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) return null;
const [userRecipes, pantry, aliasIndex] = await Promise.all([
db.query.recipes.findMany({
where: eq(recipes.authorId, session.user.id),
with: {
ingredients: true,
photos: true,
},
}),
db.query.pantryItems.findMany({
where: eq(pantryItems.userId, session.user.id),
}),
loadIngredientAliasIndex(),
]);
const scored = scoreRecipesAgainstPantry(userRecipes, pantry, aliasIndex).map((s) => {
const cover = s.recipe.photos?.find((p) => p.isCover) ?? s.recipe.photos?.[0];
return {
...s,
recipe: {
id: s.recipe.id,
title: s.recipe.title,
description: s.recipe.description,
photos: cover ? [{ url: getPublicUrl(cover.storageKey) }] : [],
},
};
});
return <CanCookContent pantryCount={pantry.length} scored={scored} />;
}