diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/bidding/bidding-conditions-edit.tsx | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/components/bidding/bidding-conditions-edit.tsx b/components/bidding/bidding-conditions-edit.tsx index 92893867..6541bdff 100644 --- a/components/bidding/bidding-conditions-edit.tsx +++ b/components/bidding/bidding-conditions-edit.tsx @@ -17,15 +17,17 @@ import { } from "@/components/ui/select" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Pencil, Save, X } from "lucide-react" -import { getBiddingConditions, updateBiddingConditions } from "@/lib/bidding/service" +import { getBiddingConditions, updateBiddingConditions, getActivePaymentTerms, getActiveIncoterms } from "@/lib/bidding/service" import { useToast } from "@/hooks/use-toast" interface BiddingConditionsEditProps { biddingId: number initialConditions?: any | null + paymentTermsOptions: Array<{code: string, description: string}> + incotermsOptions: Array<{code: string, description: string}> } -export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingConditionsEditProps) { +export function BiddingConditionsEdit({ biddingId, initialConditions, paymentTermsOptions, incotermsOptions }: BiddingConditionsEditProps) { const router = useRouter() const { toast } = useToast() const [isPending, startTransition] = useTransition() @@ -34,8 +36,8 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC paymentTerms: initialConditions?.paymentTerms || "", taxConditions: initialConditions?.taxConditions || "", incoterms: initialConditions?.incoterms || "", - contractDeliveryDate: initialConditions?.contractDeliveryDate - ? new Date(initialConditions.contractDeliveryDate).toISOString().split('T')[0] + contractDeliveryDate: initialConditions?.contractDeliveryDate + ? new Date(initialConditions.contractDeliveryDate).toISOString().split('T')[0] : "", shippingPort: initialConditions?.shippingPort || "", destinationPort: initialConditions?.destinationPort || "", @@ -43,6 +45,7 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC sparePartOptions: initialConditions?.sparePartOptions || "", }) + const handleSave = () => { startTransition(async () => { try { @@ -51,14 +54,15 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC if (result.success) { toast({ title: "성공", - description: result.message, + description: (result as { success: true; message: string }).message, + variant: "default", }) setIsEditing(false) router.refresh() } else { toast({ title: "오류", - description: result.error, + description: (result as { success: false; error: string }).error || "입찰 조건 업데이트 중 오류가 발생했습니다.", variant: "destructive", }) } @@ -108,7 +112,12 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 text-sm"> <div> <Label className="text-muted-foreground">지급조건</Label> - <p className="font-medium">{conditions.paymentTerms || "미설정"}</p> + <p className="font-medium"> + {conditions.paymentTerms + ? paymentTermsOptions.find(opt => opt.code === conditions.paymentTerms)?.code || conditions.paymentTerms + : "미설정" + } + </p> </div> <div> <Label className="text-muted-foreground">세금조건</Label> @@ -116,7 +125,12 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC </div> <div> <Label className="text-muted-foreground">운송조건</Label> - <p className="font-medium">{conditions.incoterms || "미설정"}</p> + <p className="font-medium"> + {conditions.incoterms + ? incotermsOptions.find(opt => opt.code === conditions.incoterms)?.code || conditions.incoterms + : "미설정" + } + </p> </div> <div> <Label className="text-muted-foreground">계약 납품일</Label> @@ -180,15 +194,30 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC <div className="grid grid-cols-1 md:grid-cols-2 gap-6"> <div className="space-y-2"> <Label htmlFor="paymentTerms">지급조건 *</Label> - <Input - id="paymentTerms" - placeholder="예: 월말결제, 60일" + <Select value={conditions.paymentTerms} - onChange={(e) => setConditions(prev => ({ + onValueChange={(value) => setConditions(prev => ({ ...prev, - paymentTerms: e.target.value + paymentTerms: value }))} - /> + > + <SelectTrigger> + <SelectValue placeholder="지급조건 선택" /> + </SelectTrigger> + <SelectContent> + {paymentTermsOptions.length > 0 ? ( + paymentTermsOptions.map((option) => ( + <SelectItem key={option.code} value={option.code}> + {option.code} {option.description && `(${option.description})`} + </SelectItem> + )) + ) : ( + <SelectItem value="no-data" disabled> + 데이터 없음 + </SelectItem> + )} + </SelectContent> + </Select> </div> <div className="space-y-2"> @@ -206,7 +235,7 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC <div className="space-y-2"> <Label htmlFor="incoterms">운송조건(인코텀즈) *</Label> - <Select + <Select value={conditions.incoterms} onValueChange={(value) => setConditions(prev => ({ ...prev, @@ -217,17 +246,17 @@ export function BiddingConditionsEdit({ biddingId, initialConditions }: BiddingC <SelectValue placeholder="인코텀즈 선택" /> </SelectTrigger> <SelectContent> - <SelectItem value="EXW">EXW (Ex Works)</SelectItem> - <SelectItem value="FCA">FCA (Free Carrier)</SelectItem> - <SelectItem value="CPT">CPT (Carriage Paid To)</SelectItem> - <SelectItem value="CIP">CIP (Carriage and Insurance Paid to)</SelectItem> - <SelectItem value="DAP">DAP (Delivered at Place)</SelectItem> - <SelectItem value="DPU">DPU (Delivered at Place Unloaded)</SelectItem> - <SelectItem value="DDP">DDP (Delivered Duty Paid)</SelectItem> - <SelectItem value="FAS">FAS (Free Alongside Ship)</SelectItem> - <SelectItem value="FOB">FOB (Free on Board)</SelectItem> - <SelectItem value="CFR">CFR (Cost and Freight)</SelectItem> - <SelectItem value="CIF">CIF (Cost, Insurance, and Freight)</SelectItem> + {incotermsOptions.length > 0 ? ( + incotermsOptions.map((option) => ( + <SelectItem key={option.code} value={option.code}> + {option.code} {option.description && `(${option.description})`} + </SelectItem> + )) + ) : ( + <SelectItem value="no-data" disabled> + 데이터 없음 + </SelectItem> + )} </SelectContent> </Select> </div> |
