feat(ui): sayım ekranı, tüketim analizi ve sayım hatırlatmaları
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Clock } from "lucide-react";
|
||||
import { ClipboardCheck, Clock } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
@@ -9,7 +9,7 @@ import { getStock } from "../service";
|
||||
const t = tr.stock;
|
||||
const LIMIT = 5;
|
||||
|
||||
/** Dashboard: eşiğin altındaki ürünler ve SKT'si yaklaşan partiler (yoksa görünmez). */
|
||||
/** Dashboard: eşiğin altındaki ürünler, SKT'si yaklaşan partiler, sayımı gelen kategoriler. */
|
||||
export async function LowStockCard({
|
||||
userId,
|
||||
householdId,
|
||||
@@ -18,7 +18,8 @@ export async function LowStockCard({
|
||||
householdId: string;
|
||||
}) {
|
||||
const data = await getStock(userId, householdId);
|
||||
if (!data || (!data.suggestions.length && !data.expiring.length)) return null;
|
||||
if (!data || (!data.suggestions.length && !data.expiring.length && !data.countDue.length))
|
||||
return null;
|
||||
const low = data.suggestions.slice(0, LIMIT);
|
||||
const expiring = data.expiring.slice(0, Math.max(0, LIMIT - low.length) || 2);
|
||||
return (
|
||||
@@ -26,7 +27,11 @@ export async function LowStockCard({
|
||||
<CardHeader>
|
||||
<CardTitle className="text-base">{t.dashboard.title}</CardTitle>
|
||||
<CardDescription>
|
||||
{t.dashboard.description(data.suggestions.length, data.expiring.length)}
|
||||
{t.dashboard.description(
|
||||
data.suggestions.length,
|
||||
data.expiring.length,
|
||||
data.countDue.length,
|
||||
)}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-3">
|
||||
@@ -69,6 +74,23 @@ export async function LowStockCard({
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
{data.countDue.slice(0, 3).map((g) => (
|
||||
<li
|
||||
key={`count-${g.categoryId}`}
|
||||
className="flex items-center justify-between gap-3 py-1.5"
|
||||
>
|
||||
<Link
|
||||
href={`/stok/sayim?kategori=${g.categoryId}`}
|
||||
className="min-w-0 truncate hover:underline"
|
||||
>
|
||||
{g.path}
|
||||
</Link>
|
||||
<span className="flex shrink-0 items-center gap-1 text-xs text-amber-700 dark:text-amber-400">
|
||||
<ClipboardCheck className="size-3" />
|
||||
{t.count.dueBadge(g.overdueDays)}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{data.suggestions.length > low.length ? (
|
||||
<p className="text-xs text-muted-foreground">
|
||||
|
||||
Reference in New Issue
Block a user