diff options
Diffstat (limited to 'lib/bidding/validation.ts')
| -rw-r--r-- | lib/bidding/validation.ts | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/lib/bidding/validation.ts b/lib/bidding/validation.ts index 556395b5..5dec3ab3 100644 --- a/lib/bidding/validation.ts +++ b/lib/bidding/validation.ts @@ -155,3 +155,67 @@ export const createBiddingSchema = z.object({ export type GetBiddingsSchema = Awaited<ReturnType<typeof searchParamsCache.parse>> export type CreateBiddingSchema = z.infer<typeof createBiddingSchema> export type UpdateBiddingSchema = z.infer<typeof updateBiddingSchema> + + // === 상세 페이지용 검증 스키마들 === + + // 내정가 업데이트 스키마 + export const updateTargetPriceSchema = z.object({ + biddingId: z.number().int().positive('입찰 ID는 필수입니다'), + targetPrice: z.number().min(0, '내정가는 0 이상이어야 합니다'), + }) + + // 협력업체 정보 생성 스키마 + export const createQuotationVendorSchema = z.object({ + biddingId: z.number().int().positive('입찰 ID는 필수입니다'), + vendorId: z.number().int().positive('업체 ID는 필수입니다'), + vendorName: z.string().min(1, '업체명은 필수입니다'), + vendorCode: z.string().min(1, '업체코드는 필수입니다'), + contactPerson: z.string().optional(), + contactEmail: z.string().email().optional().or(z.literal('')), + contactPhone: z.string().optional(), + quotationAmount: z.number().min(0, '견적금액은 0 이상이어야 합니다'), + currency: z.string().min(1, '통화는 필수입니다').default('KRW'), + paymentTerms: z.string().optional(), + taxConditions: z.string().optional(), + deliveryDate: z.string().optional(), + awardRatio: z.number().min(0).max(100, '발주비율은 0-100 사이여야 합니다').optional(), + status: z.enum(['pending', 'submitted', 'selected', 'rejected']).default('pending'), + }) + + // 협력업체 정보 업데이트 스키마 + export const updateQuotationVendorSchema = z.object({ + id: z.number().int().positive('협력업체 ID는 필수입니다'), + vendorName: z.string().min(1, '업체명은 필수입니다').optional(), + vendorCode: z.string().min(1, '업체코드는 필수입니다').optional(), + contactPerson: z.string().optional(), + contactEmail: z.string().email().optional().or(z.literal('')), + contactPhone: z.string().optional(), + quotationAmount: z.number().min(0, '견적금액은 0 이상이어야 합니다').optional(), + currency: z.string().min(1, '통화는 필수입니다').optional(), + paymentTerms: z.string().optional(), + taxConditions: z.string().optional(), + deliveryDate: z.string().optional(), + awardRatio: z.number().min(0).max(100, '발주비율은 0-100 사이여야 합니다').optional(), + status: z.enum(['pending', 'submitted', 'selected', 'rejected']).optional(), + }) + + // 낙찰 선택 스키마 + export const selectWinnerSchema = z.object({ + biddingId: z.number().int().positive('입찰 ID는 필수입니다'), + vendorId: z.number().int().positive('업체 ID는 필수입니다'), + awardRatio: z.number().min(0).max(100, '발주비율은 0-100 사이여야 합니다'), + }) + + // 입찰 상태 변경 스키마 + export const updateBiddingStatusSchema = z.object({ + biddingId: z.number().int().positive('입찰 ID는 필수입니다'), + status: z.enum(biddings.status.enumValues, { + required_error: '입찰 상태는 필수입니다' + }), + }) + + export type UpdateTargetPriceSchema = z.infer<typeof updateTargetPriceSchema> + export type CreateQuotationVendorSchema = z.infer<typeof createQuotationVendorSchema> + export type UpdateQuotationVendorSchema = z.infer<typeof updateQuotationVendorSchema> + export type SelectWinnerSchema = z.infer<typeof selectWinnerSchema> + export type UpdateBiddingStatusSchema = z.infer<typeof updateBiddingStatusSchema> |
