From 33e8452331c301430191b3506825ebaf3edac93a Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Wed, 1 Oct 2025 09:48:03 +0000
Subject: (최겸) 구매 PQ 리스트 기능 수정, 견적 첨부파일 리비전 액션 추가, 기타
 등
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/pq/table/copy-pq-list-dialog.tsx | 80 +++++++++++++++++++++---------------
 1 file changed, 46 insertions(+), 34 deletions(-)

(limited to 'lib/pq/table/copy-pq-list-dialog.tsx')

diff --git a/lib/pq/table/copy-pq-list-dialog.tsx b/lib/pq/table/copy-pq-list-dialog.tsx
index 647ab1a3..51b7eed1 100644
--- a/lib/pq/table/copy-pq-list-dialog.tsx
+++ b/lib/pq/table/copy-pq-list-dialog.tsx
@@ -33,11 +33,17 @@ const copyPqSchema = z.object({
   sourcePqListId: z.number({
     required_error: "복사할 PQ 목록을 선택해주세요"
   }),
-  targetProjectId: z.number({
-    required_error: "대상 프로젝트를 선택해주세요"
-  }),
+  targetProjectId: z.number().optional(),
   validTo: z.date(),
   newName: z.string(),
+}).refine((data) => {
+  // 미실사 PQ가 아닌 경우에만 targetProjectId 필수
+  if (data.targetProjectId !== undefined) return true
+  // 미실사 PQ인 경우 targetProjectId는 선택사항
+  return true
+}, {
+  message: "프로젝트 PQ인 경우 대상 프로젝트를 선택해야 합니다",
+  path: ["targetProjectId"]
 })
 
 type CopyPqFormData = z.infer<typeof copyPqSchema>
@@ -106,36 +112,6 @@ export function CopyPqDialog({
 
         <Form {...form}>
           <form onSubmit={form.handleSubmit(handleSubmit)} className="space-y-6">
-            {/* 대상 프로젝트 선택 */}
-            <FormField
-              control={form.control}
-              name="targetProjectId"
-              render={({ field }) => (
-                <FormItem>
-                  <FormLabel className="flex items-center gap-1">
-                    대상 프로젝트 <span className="text-red-500">*</span>
-                  </FormLabel>
-                  <Select 
-                    onValueChange={(value) => field.onChange(parseInt(value))} 
-                    defaultValue={field.value?.toString()}
-                  >
-                    <FormControl>
-                      <SelectTrigger>
-                        <SelectValue placeholder="PQ를 적용할 프로젝트를 선택하세요" />
-                      </SelectTrigger>
-                    </FormControl>
-                    <SelectContent>
-                      {projects.map((project) => (
-                        <SelectItem key={project.id} value={project.id.toString()}>
-                          {project.code} - {project.name}
-                        </SelectItem>
-                      ))}
-                    </SelectContent>
-                  </Select>
-                  <FormMessage />
-                </FormItem>
-              )}
-            />
             {/* 복사할 PQ 목록 선택 */}
             <FormField
               control={form.control}
@@ -155,7 +131,9 @@ export function CopyPqDialog({
                       </SelectTrigger>
                     </FormControl>
                     <SelectContent>
-                      {pqLists.map((pqList) => (
+                      {pqLists
+                        .filter(pqList => pqList.type !== "GENERAL") // 일반 PQ 제외
+                        .map((pqList) => (
                         <SelectItem key={pqList.id} value={pqList.id.toString()}>
                           <div className="flex items-center gap-2">
                             <Badge className={typeColors[pqList.type]}>
@@ -184,6 +162,39 @@ export function CopyPqDialog({
                 </FormItem>
               )}
             />
+            {/* 대상 프로젝트 선택 (미실사 PQ가 아닌 경우에만) */}
+            {selectedPqList?.type !== "NON_INSPECTION" && (
+              <FormField
+                control={form.control}
+                name="targetProjectId"
+                render={({ field }) => (
+                  <FormItem>
+                    <FormLabel className="flex items-center gap-1">
+                      대상 프로젝트 <span className="text-red-500">*</span>
+                    </FormLabel>
+                    <Select
+                      onValueChange={(value) => field.onChange(parseInt(value))}
+                      defaultValue={field.value?.toString()}
+                    >
+                      <FormControl>
+                        <SelectTrigger>
+                          <SelectValue placeholder="PQ를 적용할 프로젝트를 선택하세요" />
+                        </SelectTrigger>
+                      </FormControl>
+                      <SelectContent>
+                        {projects.map((project) => (
+                          <SelectItem key={project.id} value={project.id.toString()}>
+                            {project.code} - {project.name}
+                          </SelectItem>
+                        ))}
+                      </SelectContent>
+                    </Select>
+                    <FormMessage />
+                  </FormItem>
+                )}
+              />
+            )}
+
             {/* 새 PQ 목록 명 */}
             <FormField
               control={form.control}
@@ -214,6 +225,7 @@ export function CopyPqDialog({
                       date={field.value ?? undefined}
                       onSelect={(date) => field.onChange(date ?? null)}
                       placeholder="유효기간 선택"
+                      minDate={new Date()}
                     />
                   </FormControl>
                   <FormMessage />
-- 
cgit v1.2.3

