diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-08 10:29:19 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-08 10:29:19 +0000 |
| commit | f93493f68c9f368e10f1c3379f1c1384068e3b14 (patch) | |
| tree | a9dada58741750fa7ca6e04b210443ad99a6bccc /lib/bidding/detail/table/bidding-detail-vendor-edit-dialog.tsx | |
| parent | e832a508e1b3c531fb3e1b9761e18e1b55e3d76a (diff) | |
(대표님, 최겸) rfqLast, bidding, prequote
Diffstat (limited to 'lib/bidding/detail/table/bidding-detail-vendor-edit-dialog.tsx')
| -rw-r--r-- | lib/bidding/detail/table/bidding-detail-vendor-edit-dialog.tsx | 289 |
1 files changed, 38 insertions, 251 deletions
diff --git a/lib/bidding/detail/table/bidding-detail-vendor-edit-dialog.tsx b/lib/bidding/detail/table/bidding-detail-vendor-edit-dialog.tsx index 75f53503..b10212ab 100644 --- a/lib/bidding/detail/table/bidding-detail-vendor-edit-dialog.tsx +++ b/lib/bidding/detail/table/bidding-detail-vendor-edit-dialog.tsx @@ -21,8 +21,7 @@ import { SelectTrigger, SelectValue, } from '@/components/ui/select' -import { updateQuotationVendor } from '@/lib/bidding/detail/service' -import { updateQuotationVendorSchema } from '@/lib/bidding/validation' +import { updateBiddingDetailVendor } from '@/lib/bidding/detail/service' import { QuotationVendor } from '@/lib/bidding/detail/service' import { useToast } from '@/hooks/use-toast' import { useTransition } from 'react' @@ -43,52 +42,16 @@ export function BiddingDetailVendorEditDialog({ const { toast } = useToast() const [isPending, startTransition] = useTransition() - // 폼 상태 + // 폼 상태 (간소화 - 수정 가능한 필드만) const [formData, setFormData] = React.useState({ - vendorName: '', - vendorCode: '', - contactPerson: '', - contactEmail: '', - contactPhone: '', - quotationAmount: 0, - currency: 'KRW', awardRatio: 0, - status: 'pending' as const, - // 입찰 조건 (companyConditionResponses 기반) - paymentTermsResponse: '', - taxConditionsResponse: '', - proposedContractDeliveryDate: '', - priceAdjustmentResponse: false, - incotermsResponse: '', - proposedShippingPort: '', - proposedDestinationPort: '', - sparePartResponse: '', - additionalProposals: '', }) // vendor가 변경되면 폼 데이터 업데이트 React.useEffect(() => { if (vendor) { setFormData({ - vendorName: vendor.vendorName, - vendorCode: vendor.vendorCode, - contactPerson: vendor.contactPerson || '', - contactEmail: vendor.contactEmail || '', - contactPhone: vendor.contactPhone || '', - quotationAmount: vendor.quotationAmount, - currency: vendor.currency, awardRatio: vendor.awardRatio || 0, - status: vendor.status, - // 입찰 조건 데이터 (vendor에서 가져오거나 기본값) - paymentTermsResponse: '', - taxConditionsResponse: '', - proposedContractDeliveryDate: '', - priceAdjustmentResponse: false, - incotermsResponse: '', - proposedShippingPort: '', - proposedDestinationPort: '', - sparePartResponse: '', - additionalProposals: '', }) } }, [vendor]) @@ -96,22 +59,15 @@ export function BiddingDetailVendorEditDialog({ const handleEdit = () => { if (!vendor) return - const result = updateQuotationVendorSchema.safeParse({ - id: vendor.id, - ...formData, - }) - - if (!result.success) { - toast({ - title: '유효성 오류', - description: result.error.issues[0]?.message || '입력값을 확인해주세요.', - variant: 'destructive', - }) - return - } startTransition(async () => { - const response = await updateQuotationVendor(vendor.id, result.data, 'current-user') + const response = await updateBiddingDetailVendor( + vendor.id, + vendor.quotationAmount, // 기존 견적금액 유지 + vendor.currency, // 기존 통화 유지 + formData.awardRatio, + 'current-user' // TODO: 실제 사용자 ID + ) if (response.success) { toast({ @@ -134,209 +90,40 @@ export function BiddingDetailVendorEditDialog({ <Dialog open={open} onOpenChange={onOpenChange}> <DialogContent className="sm:max-w-[600px]"> <DialogHeader> - <DialogTitle>협력업체 수정</DialogTitle> + <DialogTitle>협력업체 발주비율 산정</DialogTitle> <DialogDescription> - 협력업체 정보를 수정해주세요. + 협력업체 발주비율을 산정해주세요. </DialogDescription> </DialogHeader> <div className="grid gap-4 py-4"> - <div className="grid grid-cols-2 gap-4"> - <div className="space-y-2"> - <Label htmlFor="edit-vendorName">업체명</Label> - <Input - id="edit-vendorName" - value={formData.vendorName} - onChange={(e) => setFormData({ ...formData, vendorName: e.target.value })} - /> - </div> - <div className="space-y-2"> - <Label htmlFor="edit-vendorCode">업체코드</Label> - <Input - id="edit-vendorCode" - value={formData.vendorCode} - onChange={(e) => setFormData({ ...formData, vendorCode: e.target.value })} - /> - </div> - </div> - <div className="grid grid-cols-3 gap-4"> - <div className="space-y-2"> - <Label htmlFor="edit-contactPerson">담당자</Label> - <Input - id="edit-contactPerson" - value={formData.contactPerson} - onChange={(e) => setFormData({ ...formData, contactPerson: e.target.value })} - /> - </div> - <div className="space-y-2"> - <Label htmlFor="edit-contactEmail">이메일</Label> - <Input - id="edit-contactEmail" - type="email" - value={formData.contactEmail} - onChange={(e) => setFormData({ ...formData, contactEmail: e.target.value })} - /> - </div> - <div className="space-y-2"> - <Label htmlFor="edit-contactPhone">연락처</Label> - <Input - id="edit-contactPhone" - value={formData.contactPhone} - onChange={(e) => setFormData({ ...formData, contactPhone: e.target.value })} - /> - </div> - </div> - <div className="grid grid-cols-2 gap-4"> - <div className="space-y-2"> - <Label htmlFor="edit-quotationAmount">견적금액</Label> - <Input - id="edit-quotationAmount" - type="number" - value={formData.quotationAmount} - onChange={(e) => setFormData({ ...formData, quotationAmount: Number(e.target.value) })} - /> - </div> - <div className="space-y-2"> - <Label htmlFor="edit-currency">통화</Label> - <Select value={formData.currency} onValueChange={(value) => setFormData({ ...formData, currency: value })}> - <SelectTrigger> - <SelectValue /> - </SelectTrigger> - <SelectContent> - <SelectItem value="KRW">KRW</SelectItem> - <SelectItem value="USD">USD</SelectItem> - <SelectItem value="EUR">EUR</SelectItem> - </SelectContent> - </Select> - </div> - </div> - <div className="grid grid-cols-2 gap-4"> - <div className="space-y-2"> - <Label htmlFor="edit-awardRatio">발주비율 (%)</Label> - <Input - id="edit-awardRatio" - type="number" - min="0" - max="100" - value={formData.awardRatio} - onChange={(e) => setFormData({ ...formData, awardRatio: Number(e.target.value) })} - /> - </div> - <div className="space-y-2"> - <Label htmlFor="edit-status">상태</Label> - <Select value={formData.status} onValueChange={(value: any) => setFormData({ ...formData, status: value })}> - <SelectTrigger> - <SelectValue /> - </SelectTrigger> - <SelectContent> - <SelectItem value="pending">대기</SelectItem> - <SelectItem value="submitted">제출</SelectItem> - <SelectItem value="selected">선정</SelectItem> - <SelectItem value="rejected">거절</SelectItem> - </SelectContent> - </Select> - </div> - </div> - {/* 입찰 조건 섹션 */} - <div className="col-span-2 pt-4 border-t"> - <h3 className="text-lg font-medium mb-4">입찰 조건 설정</h3> - - <div className="grid grid-cols-2 gap-4"> - <div className="space-y-2"> - <Label htmlFor="edit-paymentTermsResponse">지급조건</Label> - <Input - id="edit-paymentTermsResponse" - value={formData.paymentTermsResponse} - onChange={(e) => setFormData({ ...formData, paymentTermsResponse: e.target.value })} - placeholder="지급조건을 입력하세요" - /> - </div> - - <div className="space-y-2"> - <Label htmlFor="edit-taxConditionsResponse">세금조건</Label> - <Input - id="edit-taxConditionsResponse" - value={formData.taxConditionsResponse} - onChange={(e) => setFormData({ ...formData, taxConditionsResponse: e.target.value })} - placeholder="세금조건을 입력하세요" - /> - </div> - </div> - - <div className="grid grid-cols-2 gap-4 mt-4"> - <div className="space-y-2"> - <Label htmlFor="edit-incotermsResponse">운송조건 (Incoterms)</Label> - <Input - id="edit-incotermsResponse" - value={formData.incotermsResponse} - onChange={(e) => setFormData({ ...formData, incotermsResponse: e.target.value })} - placeholder="운송조건을 입력하세요" - /> - </div> - - <div className="space-y-2"> - <Label htmlFor="edit-proposedContractDeliveryDate">제안 계약납기일</Label> - <Input - id="edit-proposedContractDeliveryDate" - type="date" - value={formData.proposedContractDeliveryDate} - onChange={(e) => setFormData({ ...formData, proposedContractDeliveryDate: e.target.value })} - /> - </div> - </div> - - <div className="grid grid-cols-2 gap-4 mt-4"> - <div className="space-y-2"> - <Label htmlFor="edit-proposedShippingPort">제안 선적지</Label> - <Input - id="edit-proposedShippingPort" - value={formData.proposedShippingPort} - onChange={(e) => setFormData({ ...formData, proposedShippingPort: e.target.value })} - placeholder="선적지를 입력하세요" - /> - </div> - - <div className="space-y-2"> - <Label htmlFor="edit-proposedDestinationPort">제안 도착지</Label> - <Input - id="edit-proposedDestinationPort" - value={formData.proposedDestinationPort} - onChange={(e) => setFormData({ ...formData, proposedDestinationPort: e.target.value })} - placeholder="도착지를 입력하세요" - /> + {/* 읽기 전용 업체 정보 */} + {vendor && ( + <div className="bg-muted/50 rounded-lg p-3 border"> + <h4 className="font-medium mb-2">협력업체 정보</h4> + <div className="grid grid-cols-2 gap-4 text-sm"> + <div> + <span className="text-muted-foreground">협력업체명:</span> {vendor.vendorName} + </div> + <div> + <span className="text-muted-foreground">협력업체코드:</span> {vendor.vendorCode} + </div> </div> </div> - - <div className="space-y-2 mt-4"> - <Label htmlFor="edit-sparePartResponse">스페어파트 응답</Label> - <Input - id="edit-sparePartResponse" - value={formData.sparePartResponse} - onChange={(e) => setFormData({ ...formData, sparePartResponse: e.target.value })} - placeholder="스페어파트 관련 응답을 입력하세요" - /> - </div> - - <div className="space-y-2 mt-4"> - <Label htmlFor="edit-additionalProposals">추가 제안사항</Label> - <Textarea - id="edit-additionalProposals" - value={formData.additionalProposals} - onChange={(e) => setFormData({ ...formData, additionalProposals: e.target.value })} - placeholder="추가 제안사항을 입력하세요" - rows={3} - /> - </div> - - <div className="flex items-center space-x-2 mt-4"> - <Checkbox - id="edit-priceAdjustmentResponse" - checked={formData.priceAdjustmentResponse} - onCheckedChange={(checked) => - setFormData({ ...formData, priceAdjustmentResponse: !!checked }) - } - /> - <Label htmlFor="edit-priceAdjustmentResponse">연동제 적용</Label> - </div> + )} + + {/* 수정 가능한 필드들 */} + + <div className="space-y-2"> + <Label htmlFor="edit-awardRatio">발주비율 (%)</Label> + <Input + id="edit-awardRatio" + type="number" + min="0" + max="100" + value={formData.awardRatio} + onChange={(e) => setFormData({ ...formData, awardRatio: Number(e.target.value) })} + placeholder="발주비율을 입력하세요" + /> </div> </div> <DialogFooter> @@ -344,7 +131,7 @@ export function BiddingDetailVendorEditDialog({ 취소 </Button> <Button onClick={handleEdit} disabled={isPending}> - 수정 + 산정 </Button> </DialogFooter> </DialogContent> |
