diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-21 07:54:26 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-21 07:54:26 +0000 |
| commit | 14f61e24947fb92dd71ec0a7196a6e815f8e66da (patch) | |
| tree | 317c501d64662d05914330628f867467fba78132 /lib/contact-possible-items/validations.ts | |
| parent | 194bd4bd7e6144d5c09c5e3f5476d254234dce72 (diff) | |
(최겸)기술영업 RFQ 담당자 초대, 요구사항 반영
Diffstat (limited to 'lib/contact-possible-items/validations.ts')
| -rw-r--r-- | lib/contact-possible-items/validations.ts | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/lib/contact-possible-items/validations.ts b/lib/contact-possible-items/validations.ts new file mode 100644 index 00000000..609be0df --- /dev/null +++ b/lib/contact-possible-items/validations.ts @@ -0,0 +1,59 @@ +import { createSearchParamsCache, parseAsInteger, parseAsString } from "nuqs/server"
+import { z } from "zod"
+
+// 검색 파라미터 스키마 (뷰 기반으로 수정)
+export const searchParamsSchema = z.object({
+ page: z.coerce.number().default(1),
+ per_page: z.coerce.number().default(10),
+ sort: z.string().optional(),
+ search: z.string().optional(), // 통합 검색
+ contactName: z.string().optional(),
+ vendorName: z.string().optional(),
+ itemCode: z.string().optional(),
+ vendorCode: z.string().optional(),
+ workType: z.string().optional(),
+ from: z.string().optional(),
+ to: z.string().optional(),
+})
+
+// searchParams 캐시 생성
+export const searchParamsCache = createSearchParamsCache({
+ page: parseAsInteger.withDefault(1),
+ per_page: parseAsInteger.withDefault(10),
+ sort: parseAsString.withDefault(""),
+ search: parseAsString.withDefault(""), // 통합 검색 추가
+ contactName: parseAsString.withDefault(""),
+ vendorName: parseAsString.withDefault(""),
+ itemCode: parseAsString.withDefault(""),
+ vendorCode: parseAsString.withDefault(""),
+ workType: parseAsString.withDefault(""),
+ from: parseAsString.withDefault(""),
+ to: parseAsString.withDefault(""),
+})
+
+export type SearchParamsCache = typeof searchParamsCache
+
+// 담당자별 아이템 생성용 스키마 (FK만 사용)
+export const contactPossibleItemSchema = z.object({
+ contactId: z.number().min(1, "담당자를 선택해주세요"),
+ vendorPossibleItemId: z.number().min(1, "벤더 가능 아이템을 선택해주세요"),
+})
+
+export type ContactPossibleItemSchema = z.infer<typeof contactPossibleItemSchema>
+
+// 조회용 스키마 (searchParamsCache와 일치하도록 수정)
+export const getContactPossibleItemsSchema = z.object({
+ page: z.number().default(1),
+ per_page: z.number().default(10),
+ sort: z.string().optional(),
+ search: z.string().optional(),
+ contactName: z.string().optional(),
+ vendorName: z.string().optional(),
+ itemCode: z.string().optional(),
+ vendorCode: z.string().optional(),
+ workType: z.string().optional(),
+ from: z.string().optional(),
+ to: z.string().optional(),
+})
+
+export type GetContactPossibleItemsSchema = z.infer<typeof getContactPossibleItemsSchema>
\ No newline at end of file |
