/** * 編輯供貨商品對話框 */ import { useEffect, useState } from "react"; import { Button } from "@/Components/ui/button"; import { Input } from "@/Components/ui/input"; import { Label } from "@/Components/ui/label"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, } from "@/Components/ui/dialog"; import type { SupplyProduct } from "@/types/vendor"; interface EditSupplyProductDialogProps { open: boolean; product: SupplyProduct | null; onClose: () => void; onSave: (productId: string, lastPrice?: number) => void; } export default function EditSupplyProductDialog({ open, product, onClose, onSave, }: EditSupplyProductDialogProps) { const [lastPrice, setLastPrice] = useState(""); useEffect(() => { if (product) { setLastPrice(product.lastPrice?.toString() || ""); } }, [product, open]); const handleSave = () => { if (!product) return; const price = lastPrice ? parseFloat(lastPrice) : undefined; onSave(product.productId, price); setLastPrice(""); }; const handleCancel = () => { setLastPrice(""); onClose(); }; if (!product) return null; return ( 編輯供貨商品 修改商品的採購價格資訊。
{/* 商品名稱(不可編輯) */}
{/* 單位(不可編輯) */}
{/* 上次採購價格 */}
setLastPrice(e.target.value)} className="mt-1" />
); }