feat(meal-plan): weekly planner, pantry, shopping lists, nutrition tracking

AI-generated weekly meal plans with pantry-awareness. Manual entry per slot.
Pantry inventory management. Auto-generated shopping lists from meal plan.
Weekly nutrition bar chart vs daily goals. Nutrition goals settings.
This commit is contained in:
Arnaud
2026-07-01 08:10:39 +02:00
parent 9d02a69250
commit 3636ab27ae
23 changed files with 1791 additions and 0 deletions
@@ -0,0 +1,45 @@
import type { Metadata } from "next";
import { notFound } from "next/navigation";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { db, shoppingLists, eq, and } from "@epicure/db";
import { ShoppingListView } from "@/components/meal-plan/shopping-list-view";
type Params = { params: Promise<{ id: string }> };
export const metadata: Metadata = { title: "Shopping List" };
export default async function ShoppingListPage({ params }: Params) {
const { id } = await params;
const session = await auth.api.getSession({ headers: await headers() });
if (!session) return null;
const list = await db.query.shoppingLists.findFirst({
where: and(eq(shoppingLists.id, id), eq(shoppingLists.userId, session.user.id)),
with: { items: { orderBy: (t, { asc }) => [asc(t.aisle), asc(t.rawName)] } },
});
if (!list) notFound();
return (
<div className="space-y-6 max-w-lg">
<div>
<h1 className="text-3xl font-bold tracking-tight">{list.name}</h1>
<p className="text-muted-foreground mt-1">
{list.items.length} items{list.generatedAt ? " · Generated from meal plan" : ""}
</p>
</div>
<ShoppingListView
listId={id}
initialItems={list.items.map((i) => ({
id: i.id,
rawName: i.rawName,
quantity: i.quantity,
unit: i.unit,
aisle: i.aisle,
checked: i.checked,
}))}
/>
</div>
);
}
@@ -0,0 +1,30 @@
import type { Metadata } from "next";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { db, shoppingLists, eq, desc } from "@epicure/db";
import { ShoppingListsPageContent } from "@/components/shopping-lists/shopping-lists-page-content";
export const metadata: Metadata = { title: "Shopping Lists" };
export default async function ShoppingListsPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) return null;
const lists = await db.query.shoppingLists.findMany({
where: eq(shoppingLists.userId, session.user.id),
orderBy: desc(shoppingLists.createdAt),
with: { items: { columns: { id: true, checked: true } } },
});
return (
<ShoppingListsPageContent
lists={lists.map((list) => ({
id: list.id,
name: list.name,
generatedAt: list.generatedAt ? list.generatedAt.toISOString() : null,
totalItems: list.items.length,
checkedItems: list.items.filter((i) => i.checked).length,
}))}
/>
);
}