1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
// lib/rfq/validation.ts
import {
createSearchParamsCache,
parseAsArrayOf,
parseAsInteger,
parseAsString,
parseAsStringEnum,
} from "nuqs/server";
import * as z from "zod";
import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers";
import { RfqLastAttachments } from "@/db/schema";
// RFQ 상태 옵션
export const RFQ_STATUS_OPTIONS = [
{ value: "RFQ 생성", label: "RFQ 생성" },
{ value: "구매담당지정", label: "구매담당지정" },
{ value: "견적요청문서 확정", label: "견적요청문서 확정" },
{ value: "TBE 요청", label: "TBE 요청" },
{ value: "TBE 완료", label: "TBE 완료" },
{ value: "RFQ 발송", label: "RFQ 발송" },
{ value: "견적접수", label: "견적접수" },
{ value: "최종업체선정", label: "최종업체선정" },
];
// 시리즈 옵션
export const SERIES_OPTIONS = [
{ value: "SS", label: "시리즈 통합" },
{ value: "II", label: "품목 통합" },
{ value: "", label: "통합 없음" },
];
// RFQ 카테고리 (탭 구분용)
export const RFQ_CATEGORY_OPTIONS = [
{ value: "all", label: "전체" },
{ value: "general", label: "일반견적" },
{ value: "itb", label: "ITB" },
{ value: "rfq", label: "RFQ" },
];
// ============= 메인 검색 파라미터 스키마 =============
export const searchParamsRfqCache = createSearchParamsCache({
flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault([]),
page: parseAsInteger.withDefault(1),
perPage: parseAsInteger.withDefault(10),
sort: getSortingStateParser<any>().withDefault([
{ id: "createdAt", desc: true },
]),
filters: getFiltersStateParser().withDefault([]),
joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
// 검색
search: parseAsString.withDefault(""),
// RFQ 카테고리 (전체/일반견적/ITB/RFQ)
rfqCategory: parseAsStringEnum(["all", "general", "itb", "rfq"]),
});
// ============= 타입 정의 =============
export type GetRfqsSchema = Awaited<
ReturnType<typeof searchParamsRfqCache.parse>
>;
// 공통 탭 파라미터
export const searchParamsRfqTabCache = createSearchParamsCache({
tab: parseAsStringEnum(['design', 'purchase']).withDefault('design'),
})
// 통합 파라미터 캐시 (모든 파라미터를 한 번에 파싱)
export const searchParamsRfqAttachmentsCache =createSearchParamsCache({
flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault([]),
page: parseAsInteger.withDefault(1),
perPage: parseAsInteger.withDefault(10),
sort: getSortingStateParser<RfqLastAttachments>().withDefault([
{ id: "createdAt", desc: true },
]),
filters: getFiltersStateParser().withDefault([]),
joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
search: parseAsString.withDefault(""),
});
// 타입 정의
export type GetRfqLastAttachmentsSchema =Awaited<
ReturnType<typeof searchParamsRfqAttachmentsCache.parse>
>;
|