summaryrefslogtreecommitdiff
path: root/lib/vendor-investigation/validations.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendor-investigation/validations.ts')
-rw-r--r--lib/vendor-investigation/validations.ts53
1 files changed, 50 insertions, 3 deletions
diff --git a/lib/vendor-investigation/validations.ts b/lib/vendor-investigation/validations.ts
index 0e84f13a..19412539 100644
--- a/lib/vendor-investigation/validations.ts
+++ b/lib/vendor-investigation/validations.ts
@@ -60,17 +60,64 @@ export const searchParamsInvestigationCache = createSearchParamsCache({
// Finally, export the type you can use in your server action:
export type GetVendorsInvestigationSchema = Awaited<ReturnType<typeof searchParamsInvestigationCache.parse>>
+// 실사 진행 관리용 스키마
+export const updateVendorInvestigationProgressSchema = z.object({
+ investigationId: z.number({
+ required_error: "Investigation ID is required",
+ }),
+ investigationAddress: z.string().optional(),
+ investigationMethod: z.enum(["PURCHASE_SELF_EVAL", "DOCUMENT_EVAL", "PRODUCT_INSPECTION", "SITE_VISIT_EVAL"]).optional(),
+
+ // 날짜 필드들
+ forecastedAt: z.union([
+ z.date(),
+ z.string().transform((str) => str ? new Date(str) : undefined)
+ ]).optional(),
+
+ confirmedAt: z.union([
+ z.date(),
+ z.string().transform((str) => str ? new Date(str) : undefined)
+ ]).optional(),
+})
+
+export type UpdateVendorInvestigationProgressSchema = z.infer<typeof updateVendorInvestigationProgressSchema>
+
+// 실사 결과 입력용 스키마
+export const updateVendorInvestigationResultSchema = z.object({
+ investigationId: z.number({
+ required_error: "Investigation ID is required",
+ }),
+
+ // 날짜 필드들
+ completedAt: z.union([
+ z.date(),
+ z.string().transform((str) => str ? new Date(str) : undefined)
+ ]).optional(),
+
+ evaluationScore: z.number()
+ .int("평가 점수는 정수여야 합니다.")
+ .min(0, "평가 점수는 0점 이상이어야 합니다.")
+ .max(100, "평가 점수는 100점 이하여야 합니다.")
+ .optional(),
+ evaluationResult: z.enum(["APPROVED", "SUPPLEMENT", "SUPPLEMENT_REINSPECT", "SUPPLEMENT_DOCUMENT", "REJECTED", "RESULT_SENT"]).optional(),
+ investigationNotes: z.string().max(1000, "QM 의견은 1000자 이내로 입력해주세요.").optional(),
+ attachments: z.any().optional(), // File 업로드를 위한 필드
+})
+
+export type UpdateVendorInvestigationResultSchema = z.infer<typeof updateVendorInvestigationResultSchema>
+
+// 기존 호환성을 위한 통합 스키마
export const updateVendorInvestigationSchema = z.object({
investigationId: z.number({
required_error: "Investigation ID is required",
}),
- investigationStatus: z.enum(["PLANNED", "IN_PROGRESS", "COMPLETED", "CANCELED", "RESULT_SENT"], {
+ investigationStatus: z.enum(["PLANNED", "IN_PROGRESS", "COMPLETED", "CANCELED", "SUPPLEMENT_REQUIRED", "RESULT_SENT"], {
required_error: "실사 상태를 선택해주세요.",
}),
investigationAddress: z.string().optional(),
investigationMethod: z.enum(["PURCHASE_SELF_EVAL", "DOCUMENT_EVAL", "PRODUCT_INSPECTION", "SITE_VISIT_EVAL"]).optional(),
- // 날짜 필드들을 string에서 Date로 변환하도록 수정
+ // 날짜 필드들
forecastedAt: z.union([
z.date(),
z.string().transform((str) => str ? new Date(str) : undefined)
@@ -96,7 +143,7 @@ export const updateVendorInvestigationSchema = z.object({
.min(0, "평가 점수는 0점 이상이어야 합니다.")
.max(100, "평가 점수는 100점 이하여야 합니다.")
.optional(),
- evaluationResult: z.enum(["APPROVED", "SUPPLEMENT", "REJECTED", "RESULT_SENT"]).optional(),
+ evaluationResult: z.enum(["APPROVED", "SUPPLEMENT", "SUPPLEMENT_REINSPECT", "SUPPLEMENT_DOCUMENT", "REJECTED", "RESULT_SENT"]).optional(),
investigationNotes: z.string().max(1000, "QM 의견은 1000자 이내로 입력해주세요.").optional(),
attachments: z.any().optional(), // File 업로드를 위한 필드
})