import { auth } from "@/lib/auth"; import { redirect } from "next/navigation"; import { getDashboardStats } from "@/data/dashboard.queries"; import { getUserSettings } from "@/data/settings.queries"; import { Package, DollarSign, AlertTriangle, Activity } from "lucide-react"; import { StatCard } from "@/components/shared/stat-card"; import { ColorSwatch } from "@/components/shared/color-swatch"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; export default async function DashboardPage() { const session = await auth(); if (!session?.user?.id) redirect("/login"); const settings = await getUserSettings(session.user.id); const stats = await getDashboardStats(session.user.id, settings.lowStockThreshold); const currencyFormatter = new Intl.NumberFormat("en-US", { style: "currency", currency: settings.currency, }); return (
All items are well stocked.
) : ({item.name}
{item.type}
{Math.round(item.remaining)} {item.type === "filament" ? "g" : "ml"}
{Math.round(item.percent)}% left
No usage logged yet.
) : ({log.itemName}
{log.notes || "No notes"}
-{log.amount}{log.unit}
{new Date(log.createdAt).toLocaleDateString()}