From 3c9a95332298450c7e0f75bfb08944439e1a3739 Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Mon, 1 Dec 2025 03:09:00 +0000
Subject: (최겸)구매 일반계약 템플릿 자동 연동 및 매핑 기능 추가
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .../main/create-general-contract-dialog.tsx        | 132 +++++++--------------
 1 file changed, 45 insertions(+), 87 deletions(-)

(limited to 'lib/general-contracts/main/create-general-contract-dialog.tsx')

diff --git a/lib/general-contracts/main/create-general-contract-dialog.tsx b/lib/general-contracts/main/create-general-contract-dialog.tsx
index bb251408..8a506e4f 100644
--- a/lib/general-contracts/main/create-general-contract-dialog.tsx
+++ b/lib/general-contracts/main/create-general-contract-dialog.tsx
@@ -18,12 +18,6 @@ import { Input } from "@/components/ui/input"
 import { Label } from "@/components/ui/label"
 import { Textarea } from "@/components/ui/textarea"
 import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
-import { Calendar } from "@/components/ui/calendar"
-import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
-import { CalendarIcon } from "lucide-react"
-import { format } from "date-fns"
-import { ko } from "date-fns/locale"
-import { cn } from "@/lib/utils"
 import { createContract } from "@/lib/general-contracts/service"
 import { 
   GENERAL_CONTRACT_CATEGORIES, 
@@ -40,9 +34,9 @@ interface CreateContractForm {
   category: string
   type: string
   executionMethod: string
-  startDate: Date | undefined
-  endDate: Date | undefined
-  validityEndDate: Date | undefined
+  startDate: string
+  endDate: string
+  validityEndDate: string
   notes: string
 }
 
@@ -59,9 +53,9 @@ export function CreateGeneralContractDialog() {
     category: '',
     type: '',
     executionMethod: '',
-    startDate: undefined,
-    endDate: undefined,
-    validityEndDate: undefined,
+    startDate: '',
+    endDate: '',
+    validityEndDate: '',
     notes: '',
   })
 
@@ -106,9 +100,9 @@ export function CreateGeneralContractDialog() {
         executionMethod: form.executionMethod,
         contractSourceType: 'manual',
         vendorId: selectedVendor!.id,
-        startDate: form.startDate!.toISOString().split('T')[0],
-        endDate: form.endDate!.toISOString().split('T')[0],
-        validityEndDate: (form.validityEndDate || form.endDate!).toISOString().split('T')[0],
+        startDate: form.startDate,
+        endDate: form.endDate,
+        validityEndDate: form.validityEndDate || form.endDate,
         status: 'Draft',
         registeredById: session?.user?.id || 1,
         lastUpdatedById: session?.user?.id || 1,
@@ -138,9 +132,9 @@ export function CreateGeneralContractDialog() {
       category: '',
       type: '',
       executionMethod: '',
-      startDate: undefined,
-      endDate: undefined,
-      validityEndDate: undefined,
+      startDate: '',
+      endDate: '',
+      validityEndDate: '',
       notes: '',
     })
     setSelectedVendor(null)
@@ -276,81 +270,45 @@ export function CreateGeneralContractDialog() {
 
           <div className="grid grid-cols-3 gap-4">
             <div className="grid gap-2">
-              <Label>계약시작일 *</Label>
-              <Popover>
-                <PopoverTrigger asChild>
-                  <Button
-                    variant="outline"
-                    className={cn(
-                      "justify-start text-left font-normal",
-                      !form.startDate && "text-muted-foreground"
-                    )}
-                  >
-                    <CalendarIcon className="mr-2 h-4 w-4" />
-                    {form.startDate ? format(form.startDate, "yyyy-MM-dd", { locale: ko }) : "날짜 선택"}
-                  </Button>
-                </PopoverTrigger>
-                <PopoverContent className="w-auto p-0">
-                  <Calendar
-                    mode="single"
-                    selected={form.startDate}
-                    onSelect={(date) => setForm(prev => ({ ...prev, startDate: date }))}
-                    initialFocus
-                  />
-                </PopoverContent>
-              </Popover>
+              <Label htmlFor="startDate">
+                계약시작일
+                {!['AD', 'LO', 'OF'].includes(form.type) && <span className="text-red-600 ml-1">*</span>}
+              </Label>
+              <Input
+                id="startDate"
+                type="date"
+                value={form.startDate}
+                onChange={(e) => setForm(prev => ({ ...prev, startDate: e.target.value }))}
+                min="1900-01-01"
+                max="2100-12-31"
+              />
             </div>
 
             <div className="grid gap-2">
-              <Label>계약종료일 *</Label>
-              <Popover>
-                <PopoverTrigger asChild>
-                  <Button
-                    variant="outline"
-                    className={cn(
-                      "justify-start text-left font-normal",
-                      !form.endDate && "text-muted-foreground"
-                    )}
-                  >
-                    <CalendarIcon className="mr-2 h-4 w-4" />
-                    {form.endDate ? format(form.endDate, "yyyy-MM-dd", { locale: ko }) : "날짜 선택"}
-                  </Button>
-                </PopoverTrigger>
-                <PopoverContent className="w-auto p-0">
-                  <Calendar
-                    mode="single"
-                    selected={form.endDate}
-                    onSelect={(date) => setForm(prev => ({ ...prev, endDate: date }))}
-                    initialFocus
-                  />
-                </PopoverContent>
-              </Popover>
+              <Label htmlFor="endDate">
+                계약종료일
+                {!['AD', 'LO', 'OF'].includes(form.type) && <span className="text-red-600 ml-1">*</span>}
+              </Label>
+              <Input
+                id="endDate"
+                type="date"
+                value={form.endDate}
+                onChange={(e) => setForm(prev => ({ ...prev, endDate: e.target.value }))}
+                min="1900-01-01"
+                max="2100-12-31"
+              />
             </div>
 
             <div className="grid gap-2">
-              <Label>유효기간종료일</Label>
-              <Popover>
-                <PopoverTrigger asChild>
-                  <Button
-                    variant="outline"
-                    className={cn(
-                      "justify-start text-left font-normal",
-                      !form.validityEndDate && "text-muted-foreground"
-                    )}
-                  >
-                    <CalendarIcon className="mr-2 h-4 w-4" />
-                    {form.validityEndDate ? format(form.validityEndDate, "yyyy-MM-dd", { locale: ko }) : "날짜 선택"}
-                  </Button>
-                </PopoverTrigger>
-                <PopoverContent className="w-auto p-0">
-                  <Calendar
-                    mode="single"
-                    selected={form.validityEndDate}
-                    onSelect={(date) => setForm(prev => ({ ...prev, validityEndDate: date }))}
-                    initialFocus
-                  />
-                </PopoverContent>
-              </Popover>
+              <Label htmlFor="validityEndDate">유효기간종료일</Label>
+              <Input
+                id="validityEndDate"
+                type="date"
+                value={form.validityEndDate}
+                onChange={(e) => setForm(prev => ({ ...prev, validityEndDate: e.target.value }))}
+                min="1900-01-01"
+                max="2100-12-31"
+              />
             </div>
           </div>
           <div className="grid gap-2">
-- 
cgit v1.2.3

