002f14ced0
Shopping list add already worked generically for batch-cook recipes — no code needed there. New: mark a specific batch-cook dish as "cooked today", track its fridge expiry (cookingHistory.batchDishId), surface a "Leftovers expiring soon" widget on the pantry page, and send a daily push+email reminder via a new /api/internal/cron/leftover-reminders endpoint (mirrors the weekly-digest cron pattern; doesn't use the social notifications table, which requires a non-null actor and isn't built for self-reminders). Also fixes, from user-reported bugs: - Recipe cards showed no batch-cook badge/dish-count/prep-time in some views — added dishCount + prepMins/cookMins (now generated by the AI and persisted) to the card component and /recipes query. - Batch-cook descriptions occasionally contained raw markdown (**bold**) — added explicit "plain prose only" prompt instructions and a stripMarkdown() defensive fallback at render time. - Truncated/cut-off descriptions — the generateObject call had no maxOutputTokens set, so long structured responses could get cut off mid-field; now capped explicitly at 8000. - Generate dialogs (batch-cook + the main AI dialog) could show buttons unreachable once the progress bar appeared mid-generation — restructured so the action row is pinned outside the scrollable content area, not affected by content height changes. - /api/internal/* routes were being redirected to /login by middleware before their own CRON_SECRET check ever ran (pre-existing bug, affected the weekly-digest cron too) — added to PUBLIC_PATHS. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
52 lines
1.6 KiB
TypeScript
52 lines
1.6 KiB
TypeScript
"use client";
|
|
|
|
import Link from "next/link";
|
|
import { useTranslations } from "next-intl";
|
|
import { AlertTriangle } from "lucide-react";
|
|
import { Badge } from "@/components/ui/badge";
|
|
|
|
type Leftover = {
|
|
recipeId: string;
|
|
dishName: string;
|
|
recipeTitle: string;
|
|
expiresAt: string;
|
|
daysLeft: number;
|
|
};
|
|
|
|
export function ExpiringLeftovers({ leftovers }: { leftovers: Leftover[] }) {
|
|
const t = useTranslations("pantry");
|
|
|
|
if (leftovers.length === 0) return null;
|
|
|
|
return (
|
|
<div className="rounded-xl border p-4 space-y-3">
|
|
<h2 className="font-semibold flex items-center gap-2">
|
|
<AlertTriangle className="h-4 w-4 text-orange-500" />
|
|
{t("expiringLeftoversTitle")}
|
|
</h2>
|
|
<div className="space-y-2">
|
|
{leftovers.map((l) => (
|
|
<Link
|
|
key={`${l.recipeId}-${l.dishName}`}
|
|
href={`/recipes/${l.recipeId}`}
|
|
className="flex items-center justify-between gap-3 rounded-lg border p-2.5 hover:bg-accent transition-colors"
|
|
>
|
|
<div className="min-w-0">
|
|
<p className="text-sm font-medium truncate">{l.dishName}</p>
|
|
<p className="text-xs text-muted-foreground truncate">{l.recipeTitle}</p>
|
|
</div>
|
|
<Badge
|
|
variant="outline"
|
|
className={l.daysLeft <= 0 ? "text-destructive border-destructive shrink-0" : "text-orange-500 border-orange-500 shrink-0"}
|
|
>
|
|
{l.daysLeft <= 0
|
|
? t("expiringToday")
|
|
: t("expiringInDays", { days: l.daysLeft })}
|
|
</Badge>
|
|
</Link>
|
|
))}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|