diff options
Diffstat (limited to 'lib/general-contracts/main')
3 files changed, 73 insertions, 93 deletions
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">
diff --git a/lib/general-contracts/main/general-contract-update-sheet.tsx b/lib/general-contracts/main/general-contract-update-sheet.tsx index 8df74beb..02bde6c9 100644 --- a/lib/general-contracts/main/general-contract-update-sheet.tsx +++ b/lib/general-contracts/main/general-contract-update-sheet.tsx @@ -116,14 +116,23 @@ export function GeneralContractUpdateSheet({ React.useEffect(() => { if (contract) { console.log("Loading contract data:", contract) + + // 날짜 포맷팅 헬퍼 (YYYY-MM-DD) + const formatDateValue = (dateStr: string | null | undefined) => { + if (!dateStr) return "" + // KST 기준 날짜 변환 (입찰 로직과 동일) + const date = new Date(dateStr) + return new Date(date.getTime() + 9 * 60 * 60 * 1000).toISOString().slice(0, 10) + } + const formData = { category: contract.category || "", type: contract.type || "", executionMethod: contract.executionMethod || "", name: contract.name || "", - startDate: contract.startDate || "", - endDate: contract.endDate || "", - validityEndDate: contract.validityEndDate || "", + startDate: formatDateValue(contract.startDate), + endDate: formatDateValue(contract.endDate), + validityEndDate: formatDateValue(contract.validityEndDate), contractScope: contract.contractScope || "", notes: contract.notes || "", linkedRfqOrItb: contract.linkedRfqOrItb || "", diff --git a/lib/general-contracts/main/general-contracts-table-columns.tsx b/lib/general-contracts/main/general-contracts-table-columns.tsx index 0b3143fe..c43bb383 100644 --- a/lib/general-contracts/main/general-contracts-table-columns.tsx +++ b/lib/general-contracts/main/general-contracts-table-columns.tsx @@ -368,14 +368,27 @@ export function getGeneralContractsColumns({ setRowAction }: GetColumnsProps): C if (!startDate || !endDate) return <span className="text-muted-foreground">-</span>
+ // UI 표시용 KST 변환 (YYYY-MM-DD)
+ const formatKstDate = (d: string | Date) => {
+ const date = new Date(d)
+ return new Date(date.getTime() + 9 * 60 * 60 * 1000).toISOString().slice(0, 10)
+ }
+
+ const formattedStart = formatKstDate(startDate)
+ const formattedEnd = formatKstDate(endDate)
+
const now = new Date()
- const isActive = now >= new Date(startDate) && now <= new Date(endDate)
- const isExpired = now > new Date(endDate)
+ const startObj = new Date(startDate)
+ const endObj = new Date(endDate)
+
+ // 종료일의 경우 23:59:59까지 유효하다고 가정하거나, 단순히 날짜 비교
+ const isActive = now >= startObj && now <= new Date(endObj.getTime() + 24 * 60 * 60 * 1000 - 1)
+ const isExpired = now > new Date(endObj.getTime() + 24 * 60 * 60 * 1000 - 1)
return (
<div className="text-xs">
<div className={`${isActive ? 'text-green-600 font-medium' : isExpired ? 'text-red-600' : 'text-gray-600'}`}>
- {formatDate(startDate, "KR")} ~ {formatDate(endDate, "KR")}
+ {formattedStart} ~ {formattedEnd}
</div>
{isActive && (
<Badge variant="default" className="text-xs mt-1">진행중</Badge>
|
