feat: implement remaining TODO.md feature ideas + fix mobile headers
Implements the six previously-unscoped feature ideas plus a mobile layout fix reported via screenshot: - Mobile: Recipes/Collections/Pantry/Meal Plan/Shopping Lists headers now stack and wrap instead of clipping buttons on narrow viewports. - Recipe diff/compare view: word/list diff against any past version, next to Restore in version history. - Shared meal plans & shopping lists: new shoppingListMembers/ mealPlanMembers tables (viewer/editor roles, mirrors collectionMembers), share dialogs, membership-checked routes. - PDF cookbook export: /print/collection/[id] renders a whole collection with page breaks, using the existing print-CSS pattern instead of adding a PDF rendering dependency. - Grocery delivery handoff: shopping lists can copy-as-text (works today) or send to Instacart once INSTACART_API_KEY is configured (stub adapter — real API needs a partner agreement). - Personalized "For You" feed tab: ranks public recipes by tag/ dietary overlap with the user's favorited/highly-rated history. - PWA: added manifest.json + icons on top of the existing service worker so the app is installable; cook-mode pages were already cached for offline use. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,10 +4,13 @@ import { headers } from "next/headers";
|
||||
import Link from "next/link";
|
||||
import { Printer } from "lucide-react";
|
||||
import { auth } from "@/lib/auth/server";
|
||||
import { db, shoppingLists, eq, and } from "@epicure/db";
|
||||
import { db, shoppingLists, eq } from "@epicure/db";
|
||||
import { ShoppingListView } from "@/components/meal-plan/shopping-list-view";
|
||||
import { ShareShoppingListButton } from "@/components/shopping-lists/share-shopping-list-button";
|
||||
import { GroceryExportButton } from "@/components/shopping-lists/grocery-export-button";
|
||||
import { buttonVariants } from "@/components/ui/button";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { getShoppingListAccess, canWriteShoppingList } from "@/lib/shopping-list-access";
|
||||
|
||||
type Params = { params: Promise<{ id: string }> };
|
||||
|
||||
@@ -18,29 +21,39 @@ export default async function ShoppingListPage({ params }: Params) {
|
||||
const session = await auth.api.getSession({ headers: await headers() });
|
||||
if (!session) return null;
|
||||
|
||||
const access = await getShoppingListAccess(id, session.user.id);
|
||||
if (!access) notFound();
|
||||
|
||||
const list = await db.query.shoppingLists.findFirst({
|
||||
where: and(eq(shoppingLists.id, id), eq(shoppingLists.userId, session.user.id)),
|
||||
where: eq(shoppingLists.id, id),
|
||||
with: { items: { orderBy: (t, { asc }) => [asc(t.aisle), asc(t.rawName)] } },
|
||||
});
|
||||
|
||||
if (!list) notFound();
|
||||
|
||||
const canEdit = canWriteShoppingList(access.role);
|
||||
const instacartEnabled = process.env["NEXT_PUBLIC_GROCERY_PROVIDER"] === "instacart";
|
||||
|
||||
return (
|
||||
<div className="space-y-6 max-w-lg">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
|
||||
<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>
|
||||
<Link href={`/print/shopping-list/${id}`} target="_blank" className={cn(buttonVariants({ variant: "outline", size: "sm" }))}>
|
||||
<Printer className="h-4 w-4" />
|
||||
Print
|
||||
</Link>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<GroceryExportButton listId={id} instacartEnabled={instacartEnabled} />
|
||||
{access.role === "owner" && <ShareShoppingListButton listId={id} />}
|
||||
<Link href={`/print/shopping-list/${id}`} target="_blank" className={cn(buttonVariants({ variant: "outline", size: "sm" }))}>
|
||||
<Printer className="h-4 w-4" />
|
||||
Print
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
<ShoppingListView
|
||||
listId={id}
|
||||
readOnly={!canEdit}
|
||||
initialItems={list.items.map((i) => ({
|
||||
id: i.id,
|
||||
rawName: i.rawName,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
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 { db, shoppingLists, shoppingListMembers, eq, desc } from "@epicure/db";
|
||||
import { ShoppingListsPageContent } from "@/components/shopping-lists/shopping-lists-page-content";
|
||||
|
||||
export const metadata: Metadata = { title: "Shopping Lists" };
|
||||
@@ -10,11 +10,17 @@ 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 } } },
|
||||
});
|
||||
const [lists, memberships] = await Promise.all([
|
||||
db.query.shoppingLists.findMany({
|
||||
where: eq(shoppingLists.userId, session.user.id),
|
||||
orderBy: desc(shoppingLists.createdAt),
|
||||
with: { items: { columns: { id: true, checked: true } } },
|
||||
}),
|
||||
db.query.shoppingListMembers.findMany({
|
||||
where: eq(shoppingListMembers.userId, session.user.id),
|
||||
with: { list: { with: { user: true } } },
|
||||
}),
|
||||
]);
|
||||
|
||||
return (
|
||||
<ShoppingListsPageContent
|
||||
@@ -25,6 +31,12 @@ export default async function ShoppingListsPage() {
|
||||
totalItems: list.items.length,
|
||||
checkedItems: list.items.filter((i) => i.checked).length,
|
||||
}))}
|
||||
sharedLists={memberships.map((m) => ({
|
||||
id: m.list.id,
|
||||
name: m.list.name,
|
||||
ownerName: m.list.user?.name ?? "Unknown",
|
||||
role: m.role,
|
||||
}))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user