feat(product): 恢復並實作商品起停用狀態功能,包含表單開關與列表顯示

This commit is contained in:
2026-02-05 16:15:06 +08:00
parent 196fec3120
commit 24aed44cd3
5 changed files with 35 additions and 4 deletions

View File

@@ -4,6 +4,7 @@ import { Input } from "@/Components/ui/input";
import { Label } from "@/Components/ui/label";
import { Textarea } from "@/Components/ui/textarea";
import { SearchableSelect } from "@/Components/ui/searchable-select";
import { Switch } from "@/Components/ui/switch";
import { useForm } from "@inertiajs/react";
import { toast } from "sonner";
import type { Category, Product } from "@/Pages/Product/Index";
@@ -41,6 +42,7 @@ export default function ProductForm({
price: initialData?.price?.toString() || "",
member_price: initialData?.member_price?.toString() || "",
wholesale_price: initialData?.wholesale_price?.toString() || "",
is_active: initialData?.is_active ?? true,
});
const handleSubmit = (e: React.FormEvent) => {
@@ -79,6 +81,16 @@ export default function ProductForm({
<div className="bg-white rounded-xl border border-gray-200 shadow-sm p-6 space-y-6">
<div className="flex items-center justify-between border-b pb-2">
<h3 className="text-lg font-bold text-grey-0"></h3>
<div className="flex items-center gap-2">
<Label htmlFor="is_active" className="text-sm font-medium text-gray-600">
{data.is_active ? "啟用" : "停用"}
</Label>
<Switch
id="is_active"
checked={data.is_active}
onCheckedChange={(checked) => setData("is_active", checked)}
/>
</div>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
<div className="space-y-2">