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>
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { formatQuantity, hasQuantity } from "@/lib/fractions";
|
||||
|
||||
type PantryMarkdownInput = {
|
||||
items: Array<{ rawName: string; quantity: string | null; unit: string | null; expiresAt: string | null }>;
|
||||
};
|
||||
@@ -6,7 +8,7 @@ export function pantryToMarkdown(pantry: PantryMarkdownInput): string {
|
||||
const lines: string[] = ["# Pantry", ""];
|
||||
|
||||
for (const item of pantry.items) {
|
||||
const qty = [item.quantity, item.unit].filter(Boolean).join(" ");
|
||||
const qty = [hasQuantity(item.quantity) ? formatQuantity(parseFloat(item.quantity!)) : null, item.unit].filter(Boolean).join(" ");
|
||||
const expiry = item.expiresAt ? ` (expires ${new Date(item.expiresAt).toLocaleDateString()})` : "";
|
||||
lines.push(`- ${qty ? `${qty} ` : ""}${item.rawName}${expiry}`);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { formatQuantity, hasQuantity } from "@/lib/fractions";
|
||||
|
||||
type ShoppingListMarkdownInput = {
|
||||
name: string;
|
||||
items: Array<{ rawName: string; quantity: string | null; unit: string | null; aisle: string | null; checked: boolean }>;
|
||||
@@ -17,7 +19,7 @@ export function shoppingListToMarkdown(list: ShoppingListMarkdownInput): string
|
||||
for (const [aisle, items] of byAisle) {
|
||||
lines.push(`## ${aisle}`, "");
|
||||
for (const item of items) {
|
||||
const qty = [item.quantity, item.unit].filter(Boolean).join(" ");
|
||||
const qty = [hasQuantity(item.quantity) ? formatQuantity(parseFloat(item.quantity!)) : null, item.unit].filter(Boolean).join(" ");
|
||||
lines.push(`- [${item.checked ? "x" : " "}] ${qty ? `${qty} ` : ""}${item.rawName}`);
|
||||
}
|
||||
lines.push("");
|
||||
|
||||
Reference in New Issue
Block a user