summaryrefslogtreecommitdiff
path: root/lib/general-contracts/main/general-contract-update-sheet.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'lib/general-contracts/main/general-contract-update-sheet.tsx')
-rw-r--r--lib/general-contracts/main/general-contract-update-sheet.tsx53
1 files changed, 44 insertions, 9 deletions
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>