Fix product stock, booking actions, settings, reservation UX, nav and category filter

This commit is contained in:
belviskhoremk
2026-05-20 23:56:43 +00:00
parent a89793a059
commit affff1c502
12 changed files with 137 additions and 102 deletions

View File

@@ -33,6 +33,7 @@ type FormState = {
category: Product["category"];
price: string;
original_price: string;
stock_quantity: string;
description: string;
colors: string;
lengths: string;
@@ -45,6 +46,7 @@ const emptyForm: FormState = {
category: "clip-in",
price: "",
original_price: "",
stock_quantity: "0",
description: "",
colors: "",
lengths: "",
@@ -86,6 +88,7 @@ export default function AdminProducts() {
category: p.category,
price: String(p.price),
original_price: p.originalPrice ? String(p.originalPrice) : "",
stock_quantity: String(p.stockQuantity ?? 0),
description: p.description,
colors: p.colors.join(", "),
lengths: p.lengths.join(", "),
@@ -123,6 +126,7 @@ export default function AdminProducts() {
category: form.category,
price,
original_price: form.original_price ? parseFloat(form.original_price) : undefined,
stock_quantity: parseInt(form.stock_quantity) || 0,
colors: form.colors.split(",").map((c) => c.trim()).filter(Boolean),
lengths: form.lengths.split(",").map((l) => l.trim()).filter(Boolean),
description: form.description,
@@ -195,6 +199,7 @@ export default function AdminProducts() {
<TableHead>{t("admin.products.col_name")}</TableHead>
<TableHead>{t("admin.products.col_category")}</TableHead>
<TableHead>{t("admin.products.col_price")}</TableHead>
<TableHead className="text-center">{t("admin.products.col_stock")}</TableHead>
<TableHead>{t("admin.products.col_status")}</TableHead>
<TableHead className="text-right">{t("admin.actions")}</TableHead>
</TableRow>
@@ -214,6 +219,9 @@ export default function AdminProducts() {
<TableCell className="font-medium">{p.name}</TableCell>
<TableCell className="text-muted-foreground">{categoryLabels[p.category]}</TableCell>
<TableCell>{p.price} </TableCell>
<TableCell className="text-center">
<span className={p.stockQuantity === 0 ? "text-destructive font-medium" : ""}>{p.stockQuantity ?? 0}</span>
</TableCell>
<TableCell className="space-x-1">
{p.isNew && <Badge variant="secondary">{t("admin.products.badge_new")}</Badge>}
{p.isBestseller && <Badge>Bestseller</Badge>}
@@ -265,6 +273,10 @@ export default function AdminProducts() {
<Label htmlFor="original_price">{t("admin.products.original_price")}</Label>
<Input id="original_price" type="number" step="0.01" value={form.original_price} onChange={(e) => setForm({ ...form, original_price: e.target.value })} placeholder={t("admin.products.optional")} />
</div>
<div className="space-y-2 col-span-2">
<Label htmlFor="stock_quantity">{t("admin.products.stock_quantity")}</Label>
<Input id="stock_quantity" type="number" min="0" step="1" value={form.stock_quantity} onChange={(e) => setForm({ ...form, stock_quantity: e.target.value })} />
</div>
<div className="space-y-2 col-span-2">
<Label>{t("admin.products.image")}</Label>
<div className="flex items-start gap-4">