import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { db, pantryItems, eq, asc } from "@epicure/db";
import { PrintTrigger } from "@/components/recipe/print-trigger";
export default async function PantryPrintPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) return null;
const items = await db.query.pantryItems.findMany({
where: eq(pantryItems.userId, session.user.id),
orderBy: asc(pantryItems.rawName),
});
const now = new Date();
return (
<>
{items.length} item{items.length !== 1 ? "s" : ""}
{items.length === 0 ? (No items in pantry.
) : (| Item | Quantity | Expires |
|---|---|---|
| {item.rawName} | {[item.quantity, item.unit].filter(Boolean).join(" ") || "—"} | {exp ? daysLeft !== null && daysLeft < 0 ? `Expired ${Math.abs(daysLeft)}d ago` : exp.toLocaleDateString("en", { month: "short", day: "numeric", year: "numeric" }) : "—"} |