From ba8cd44a0ed2c613a5f2cee06bfc9bd0f61f21c7 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 7 Nov 2025 08:39:04 +0000
Subject: (최겸) 입찰/견적 수정사항
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../main/general-contract-update-sheet.tsx         | 53 ++++++++++++++++++----
 1 file changed, 44 insertions(+), 9 deletions(-)

(limited to 'lib/general-contracts/main/general-contract-update-sheet.tsx')

diff --git a/lib/general-contracts/main/general-contract-update-sheet.tsx b/lib/general-contracts/main/general-contract-update-sheet.tsx
index 54f4ae4e..18095516 100644
--- a/lib/general-contracts/main/general-contract-update-sheet.tsx
+++ b/lib/general-contracts/main/general-contract-update-sheet.tsx
@@ -44,14 +44,41 @@ const updateContractSchema = z.object({
   type: z.string().min(1, "계약종류를 선택해주세요"),
   executionMethod: z.string().min(1, "체결방식을 선택해주세요"),
   name: z.string().min(1, "계약명을 입력해주세요"),
-  startDate: z.string().min(1, "계약시작일을 선택해주세요"),
-  endDate: z.string().min(1, "계약종료일을 선택해주세요"),
-  validityEndDate: z.string().min(1, "유효기간종료일을 선택해주세요"),
+  startDate: z.string().optional(), // AD, LO, OF 계약인 경우 선택사항
+  endDate: z.string().optional(), // AD, LO, OF 계약인 경우 선택사항
+  validityEndDate: z.string().optional(), // LO 계약인 경우에만 필수값으로 처리
   contractScope: z.string().min(1, "계약확정범위를 선택해주세요"),
   notes: z.string().optional(),
   linkedRfqOrItb: z.string().optional(),
   linkedPoNumber: z.string().optional(),
   linkedBidNumber: z.string().optional(),
+}).superRefine((data, ctx) => {
+  // AD, LO, OF 계약이 아닌 경우 계약기간 필수값 체크
+  if (!['AD', 'LO', 'OF'].includes(data.type)) {
+    if (!data.startDate) {
+      ctx.addIssue({
+        code: z.ZodIssueCode.custom,
+        message: "계약시작일을 선택해주세요",
+        path: ["startDate"],
+      })
+    }
+    if (!data.endDate) {
+      ctx.addIssue({
+        code: z.ZodIssueCode.custom,
+        message: "계약종료일을 선택해주세요",
+        path: ["endDate"],
+      })
+    }
+  }
+  
+  // LO 계약인 경우 계약체결유효기간 필수값 체크
+  if (data.type === 'LO' && !data.validityEndDate) {
+    ctx.addIssue({
+      code: z.ZodIssueCode.custom,
+      message: "LO 계약의 경우 계약체결유효기간은 필수 항목입니다",
+      path: ["validityEndDate"],
+    })
+  }
 })
 
 type UpdateContractFormData = z.infer<typeof updateContractSchema>
@@ -219,15 +246,14 @@ export function GeneralContractUpdateSheet({
                             'AL': '연간운송계약',
                             'OS': '외주용역계약',
                             'OW': '도급계약',
-                            'IS': '검사계약',
                             'LO': 'LOI',
                             'FA': 'FA',
                             'SC': '납품합의계약',
                             'OF': '클레임상계계약',
                             'AW': '사전작업합의',
                             'AD': '사전납품합의',
-                            'AM': '설계계약',
-                            'SC_SELL': '폐기물매각계약'
+                            'SG': '임치(물품보관)계약',
+                            'SR': '폐기물매각계약'
                           }
                           return (
                           <SelectItem key={type} value={type}>
@@ -293,7 +319,10 @@ export function GeneralContractUpdateSheet({
                 name="startDate"
                 render={({ field }) => (
                   <FormItem>
-                    <FormLabel>계약시작일 *</FormLabel>
+                    <FormLabel>
+                      계약시작일
+                      {!['AD', 'LO', 'OF'].includes(form.watch('type')) && <span className="text-red-600 ml-1">*</span>}
+                    </FormLabel>
                     <FormControl>
                       <Input type="date" {...field} />
                     </FormControl>
@@ -308,7 +337,10 @@ export function GeneralContractUpdateSheet({
                 name="endDate"
                 render={({ field }) => (
                   <FormItem>
-                    <FormLabel>계약종료일 *</FormLabel>
+                    <FormLabel>
+                      계약종료일
+                      {!['AD', 'LO', 'OF'].includes(form.watch('type')) && <span className="text-red-600 ml-1">*</span>}
+                    </FormLabel>
                     <FormControl>
                       <Input type="date" {...field} />
                     </FormControl>
@@ -323,7 +355,10 @@ export function GeneralContractUpdateSheet({
                 name="validityEndDate"
                 render={({ field }) => (
                   <FormItem>
-                    <FormLabel>유효기간종료일 *</FormLabel>
+                    <FormLabel>
+                      유효기간종료일
+                      {form.watch('type') === 'LO' && <span className="text-red-600 ml-1">*</span>}
+                    </FormLabel>
                     <FormControl>
                       <Input type="date" {...field} />
                     </FormControl>
-- 
cgit v1.2.3

