feat: 新增採購單發票欄位、更新 SearchableSelect 樣式與搜尋門檻至 10 個項目
This commit is contained in:
@@ -11,13 +11,7 @@ import { Button } from "@/Components/ui/button";
|
||||
import { Input } from "@/Components/ui/input";
|
||||
import { Label } from "@/Components/ui/label";
|
||||
import { Textarea } from "@/Components/ui/textarea";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/Components/ui/select";
|
||||
import { SearchableSelect } from "@/Components/ui/searchable-select";
|
||||
import { useForm } from "@inertiajs/react";
|
||||
import { toast } from "sonner";
|
||||
import type { Product, Category } from "@/Pages/Product/Index";
|
||||
@@ -123,21 +117,14 @@ export default function ProductDialog({
|
||||
<Label htmlFor="category_id">
|
||||
分類 <span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Select
|
||||
<SearchableSelect
|
||||
value={data.category_id}
|
||||
onValueChange={(value) => setData("category_id", value)}
|
||||
>
|
||||
<SelectTrigger id="category_id" className={errors.category_id ? "border-red-500" : ""}>
|
||||
<SelectValue placeholder="選擇分類" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{categories.map((category) => (
|
||||
<SelectItem key={category.id} value={category.id.toString()}>
|
||||
{category.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
options={categories.map((c) => ({ label: c.name, value: c.id.toString() }))}
|
||||
placeholder="選擇分類"
|
||||
searchPlaceholder="搜尋分類..."
|
||||
className={errors.category_id ? "border-red-500" : ""}
|
||||
/>
|
||||
{errors.category_id && <p className="text-sm text-red-500">{errors.category_id}</p>}
|
||||
</div>
|
||||
|
||||
@@ -188,42 +175,30 @@ export default function ProductDialog({
|
||||
<Label htmlFor="base_unit_id">
|
||||
基本庫存單位 <span className="text-red-500">*</span>
|
||||
</Label>
|
||||
<Select
|
||||
<SearchableSelect
|
||||
value={data.base_unit_id}
|
||||
onValueChange={(value) => setData("base_unit_id", value)}
|
||||
>
|
||||
<SelectTrigger id="base_unit_id" className={errors.base_unit_id ? "border-red-500" : ""}>
|
||||
<SelectValue placeholder="選擇單位" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{units.map((unit) => (
|
||||
<SelectItem key={unit.id} value={unit.id.toString()}>
|
||||
{unit.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
options={units.map((u) => ({ label: u.name, value: u.id.toString() }))}
|
||||
placeholder="選擇單位"
|
||||
searchPlaceholder="搜尋單位..."
|
||||
className={errors.base_unit_id ? "border-red-500" : ""}
|
||||
/>
|
||||
{errors.base_unit_id && <p className="text-sm text-red-500">{errors.base_unit_id}</p>}
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="large_unit_id">大單位</Label>
|
||||
<Select
|
||||
<SearchableSelect
|
||||
value={data.large_unit_id}
|
||||
onValueChange={(value) => setData("large_unit_id", value)}
|
||||
>
|
||||
<SelectTrigger id="large_unit_id" className={errors.large_unit_id ? "border-red-500" : ""}>
|
||||
<SelectValue placeholder="無" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="none">無</SelectItem>
|
||||
{units.map((unit) => (
|
||||
<SelectItem key={unit.id} value={unit.id.toString()}>
|
||||
{unit.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
options={[
|
||||
{ label: "無", value: "none" },
|
||||
...units.map((u) => ({ label: u.name, value: u.id.toString() }))
|
||||
]}
|
||||
placeholder="無"
|
||||
searchPlaceholder="搜尋單位..."
|
||||
className={errors.large_unit_id ? "border-red-500" : ""}
|
||||
/>
|
||||
{errors.large_unit_id && <p className="text-sm text-red-500">{errors.large_unit_id}</p>}
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user