From 33be47506f0aa62b969d82521580a29e95080268 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Wed, 13 Aug 2025 11:05:09 +0000 Subject: (대표님) 입찰, 법무검토, EDP 변경사항 대응, dolce 개선, form-data 개선, 정규업체 등록관리 추가 (최겸) pq 미사용 컴포넌트 및 페이지 제거, 파일 라우트에 pq 적용 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../edit-investigation-dialog.tsx | 123 +++++++++++- .../request-investigation-dialog.tsx | 4 +- lib/pq/pq-review-table-new/site-visit-dialog.tsx | 179 +++++++++-------- .../pq-review-table-new/vendors-table-columns.tsx | 20 +- .../vendors-table-toolbar-actions.tsx | 55 +++++- lib/pq/pq-review-table/feature-flags-provider.tsx | 108 ----------- lib/pq/pq-review-table/vendors-table-columns.tsx | 212 --------------------- .../vendors-table-toolbar-actions.tsx | 41 ---- lib/pq/pq-review-table/vendors-table.tsx | 97 ---------- lib/pq/service.ts | 182 ++++++++++++++++-- 10 files changed, 451 insertions(+), 570 deletions(-) delete mode 100644 lib/pq/pq-review-table/feature-flags-provider.tsx delete mode 100644 lib/pq/pq-review-table/vendors-table-columns.tsx delete mode 100644 lib/pq/pq-review-table/vendors-table-toolbar-actions.tsx delete mode 100644 lib/pq/pq-review-table/vendors-table.tsx (limited to 'lib/pq') diff --git a/lib/pq/pq-review-table-new/edit-investigation-dialog.tsx b/lib/pq/pq-review-table-new/edit-investigation-dialog.tsx index 4df7a7ec..7fd1c3f8 100644 --- a/lib/pq/pq-review-table-new/edit-investigation-dialog.tsx +++ b/lib/pq/pq-review-table-new/edit-investigation-dialog.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 } from "lucide-react" +import { CalendarIcon, Loader, Upload, X, FileText } from "lucide-react" import { format } from "date-fns" import { toast } from "sonner" @@ -49,6 +49,7 @@ const editInvestigationSchema = z.object({ ]).optional(), evaluationResult: z.enum(["APPROVED", "SUPPLEMENT", "REJECTED"]).optional(), investigationNotes: z.string().max(1000, "QM 의견은 1000자 이내로 입력해주세요.").optional(), + attachments: z.array(z.instanceof(File)).optional(), }) type EditInvestigationSchema = z.infer @@ -72,6 +73,8 @@ export function EditInvestigationDialog({ onSubmit, }: EditInvestigationDialogProps) { const [isPending, startTransition] = React.useTransition() + const [selectedFiles, setSelectedFiles] = React.useState([]) + const fileInputRef = React.useRef(null) const form = useForm({ resolver: zodResolver(editInvestigationSchema), @@ -79,6 +82,7 @@ export function EditInvestigationDialog({ confirmedAt: investigation?.confirmedAt || undefined, evaluationResult: investigation?.evaluationResult as "APPROVED" | "SUPPLEMENT" | "REJECTED" | undefined, investigationNotes: investigation?.investigationNotes || "", + attachments: [], }, }) @@ -89,14 +93,47 @@ export function EditInvestigationDialog({ confirmedAt: investigation.confirmedAt || undefined, evaluationResult: investigation.evaluationResult as "APPROVED" | "SUPPLEMENT" | "REJECTED" | undefined, investigationNotes: investigation.investigationNotes || "", + attachments: [], }) + setSelectedFiles([]) } }, [investigation, form]) + // 파일 선택 핸들러 + const handleFileSelect = (event: React.ChangeEvent) => { + const files = Array.from(event.target.files || []) + if (files.length > 0) { + const newFiles = [...selectedFiles, ...files] + setSelectedFiles(newFiles) + form.setValue('attachments', newFiles, { shouldValidate: true }) + } + } + + // 파일 제거 핸들러 + const removeFile = (index: number) => { + const updatedFiles = selectedFiles.filter((_, i) => i !== index) + setSelectedFiles(updatedFiles) + form.setValue('attachments', updatedFiles, { shouldValidate: true }) + } + + // 파일 크기 포맷팅 + const formatFileSize = (bytes: number) => { + if (bytes === 0) return '0 Bytes' + const k = 1024 + const sizes = ['Bytes', 'KB', 'MB', 'GB'] + const i = Math.floor(Math.log(bytes) / Math.log(k)) + return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i] + } + const handleSubmit = async (values: EditInvestigationSchema) => { startTransition(async () => { try { - await onSubmit(values) + // 선택된 파일들을 values에 포함 + const submitData = { + ...values, + attachments: selectedFiles, + } + await onSubmit(submitData) toast.success("실사 정보가 업데이트되었습니다!") onClose() } catch (error) { @@ -181,16 +218,16 @@ export function EditInvestigationDialog({ )} /> - {/* QM 의견 */} + {/* 구매 의견 */} ( - QM 의견 + 구매 의견