diff options
Diffstat (limited to 'lib/vendor-investigation/table')
3 files changed, 47 insertions, 67 deletions
diff --git a/lib/vendor-investigation/table/investigation-table-columns.tsx b/lib/vendor-investigation/table/investigation-table-columns.tsx index 88b6644f..3d765179 100644 --- a/lib/vendor-investigation/table/investigation-table-columns.tsx +++ b/lib/vendor-investigation/table/investigation-table-columns.tsx @@ -168,17 +168,6 @@ export function getColumns({ ) } - // Handle evaluation type - if (column.id === "evaluationType") { - if (!value) return "" - - return ( - <span> - {formatEnumValue(value as string)} - </span> - ) - } - // Handle evaluation result if (column.id === "evaluationResult") { if (!value) return "" @@ -287,6 +276,8 @@ function formatStatus(status: string): string { return "완료됨" case "CANCELED": return "취소됨" + case "RESULT_SENT": + return "실사결과발송" default: return status } diff --git a/lib/vendor-investigation/table/investigation-table.tsx b/lib/vendor-investigation/table/investigation-table.tsx index 660a8507..fcd2d0be 100644 --- a/lib/vendor-investigation/table/investigation-table.tsx +++ b/lib/vendor-investigation/table/investigation-table.tsx @@ -98,17 +98,6 @@ export function VendorsInvestigationTable({ promises }: VendorsTableProps) { ] }, { - id: "evaluationType", - label: "평가 유형", - type: "select", - options: [ - { label: "구매자체평가", value: "PURCHASE_SELF_EVAL" }, - { label: "서류평가", value: "DOCUMENT_EVAL" }, - { label: "제품검사평가", value: "PRODUCT_INSPECTION" }, - { label: "방문실사평가", value: "SITE_VISIT_EVAL" }, - ] - }, - { id: "evaluationResult", label: "평가 결과", type: "select", diff --git a/lib/vendor-investigation/table/update-investigation-sheet.tsx b/lib/vendor-investigation/table/update-investigation-sheet.tsx index c04aad64..14350815 100644 --- a/lib/vendor-investigation/table/update-investigation-sheet.tsx +++ b/lib/vendor-investigation/table/update-investigation-sheet.tsx @@ -3,7 +3,7 @@ import * as React from "react" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" -import { CalendarIcon, Loader, X } from "lucide-react" +import { CalendarIcon, Loader, X, Download } from "lucide-react" import { format } from "date-fns" import { toast } from "sonner" @@ -67,6 +67,7 @@ import { import { updateVendorInvestigationAction, getInvestigationAttachments, deleteInvestigationAttachment } from "../service" import { VendorInvestigationsViewWithContacts } from "@/config/vendorInvestigationsColumnsConfig" import prettyBytes from "pretty-bytes" +import { downloadFile } from "@/lib/file-download" interface UpdateVendorInvestigationSheetProps extends React.ComponentPropsWithoutRef<typeof Sheet> { @@ -123,7 +124,6 @@ export function UpdateVendorInvestigationSheet({ defaultValues: { investigationId: investigation?.investigationId ?? 0, investigationStatus: investigation?.investigationStatus ?? "PLANNED", - evaluationType: investigation?.evaluationType ?? undefined, investigationAddress: investigation?.investigationAddress ?? "", investigationMethod: investigation?.investigationMethod ?? undefined, forecastedAt: investigation?.forecastedAt ?? undefined, @@ -143,7 +143,6 @@ export function UpdateVendorInvestigationSheet({ form.reset({ investigationId: investigation.investigationId, investigationStatus: investigation.investigationStatus || "PLANNED", - evaluationType: investigation.evaluationType ?? undefined, investigationAddress: investigation.investigationAddress ?? "", investigationMethod: investigation.investigationMethod ?? undefined, forecastedAt: investigation.forecastedAt ?? undefined, @@ -203,10 +202,28 @@ export function UpdateVendorInvestigationSheet({ } } + // 첨부파일 다운로드 함수 + const handleDownloadAttachment = async (attachment: any) => { + if (!attachment.filePath || !attachment.fileName) { + toast.error("첨부파일 정보가 올바르지 않습니다.") + return + } + + try { + await downloadFile(attachment.filePath, attachment.fileName, { + showToast: true, + action: 'download' + }) + } catch (error) { + console.error("첨부파일 다운로드 오류:", error) + toast.error("첨부파일 다운로드 중 오류가 발생했습니다.") + } + } + // 선택된 파일에서 특정 파일 제거 const handleRemoveSelectedFile = (indexToRemove: number) => { const currentFiles = form.getValues("attachments") || [] - const updatedFiles = currentFiles.filter((_, index) => index !== indexToRemove) + const updatedFiles = currentFiles.filter((_: File, index: number) => index !== indexToRemove) form.setValue("attachments", updatedFiles.length > 0 ? updatedFiles : undefined) if (updatedFiles.length === 0) { @@ -250,16 +267,30 @@ export function UpdateVendorInvestigationSheet({ ({Math.round(attachment.fileSize / 1024)}KB) </span> </div> - <Button - type="button" - variant="ghost" - size="sm" - onClick={() => handleDeleteAttachment(attachment.id)} - className="text-destructive hover:text-destructive" - disabled={isPending} - > - 삭제 - </Button> + <div className="flex items-center gap-1"> + <Button + type="button" + variant="ghost" + size="sm" + onClick={() => handleDownloadAttachment(attachment)} + className="text-blue-600 hover:text-blue-700" + disabled={isPending} + title="파일 다운로드" + > + <Download className="h-4 w-4" /> + </Button> + <Button + type="button" + variant="ghost" + size="sm" + onClick={() => handleDeleteAttachment(attachment.id)} + className="text-destructive hover:text-destructive" + disabled={isPending} + title="파일 삭제" + > + <X className="h-4 w-4" /> + </Button> + </div> </div> )) ) : ( @@ -417,10 +448,6 @@ export function UpdateVendorInvestigationSheet({ formData.append("investigationId", String(values.investigationId)) formData.append("investigationStatus", values.investigationStatus) - // 선택적 필드들 - if (values.evaluationType) { - formData.append("evaluationType", values.evaluationType) - } if (values.investigationAddress) { formData.append("investigationAddress", values.investigationAddress) @@ -559,33 +586,6 @@ export function UpdateVendorInvestigationSheet({ )} /> - {/* 평가 유형 */} - <FormField - control={form.control} - name="evaluationType" - render={({ field }) => ( - <FormItem> - <FormLabel>평가 유형</FormLabel> - <FormControl> - <Select value={field.value || ""} onValueChange={field.onChange}> - <SelectTrigger> - <SelectValue placeholder="평가 유형을 선택하세요" /> - </SelectTrigger> - <SelectContent> - <SelectGroup> - <SelectItem value="PURCHASE_SELF_EVAL">구매자체평가</SelectItem> - <SelectItem value="DOCUMENT_EVAL">서류평가</SelectItem> - <SelectItem value="PRODUCT_INSPECTION">제품검사평가</SelectItem> - <SelectItem value="SITE_VISIT_EVAL">방문실사평가</SelectItem> - </SelectGroup> - </SelectContent> - </Select> - </FormControl> - <FormMessage /> - </FormItem> - )} - /> - {/* 실사 주소 */} <FormField control={form.control} |
