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
|
import { createSearchParamsCache,
parseAsArrayOf,
parseAsInteger,
parseAsString,
parseAsStringEnum,parseAsBoolean
} from "nuqs/server"
import * as z from "zod"
import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers"
import { ProcurementRfqsView, ProcurementVendorQuotations } from "@/db/schema";
// =======================
// 1) SearchParams (목록 필터링/정렬)
// =======================
export const searchParamsCache = createSearchParamsCache({
flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault([]),
page: parseAsInteger.withDefault(1),
perPage: parseAsInteger.withDefault(10),
sort: getSortingStateParser<ProcurementRfqsView>().withDefault([
{ id: "updatedAt", desc: true },
]),
// 고급 필터
filters: getFiltersStateParser().withDefault([]),
joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
// 기본 필터 (RFQFilterBox) - 새로운 필드 추가
basicFilters: getFiltersStateParser().withDefault([]),
basicJoinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
search: parseAsString.withDefault(""),
from: parseAsString.withDefault(""),
to: parseAsString.withDefault(""),
});
export type GetPORfqsSchema = Awaited<ReturnType<typeof searchParamsCache.parse>>;
export const searchParamsVendorRfqCache = createSearchParamsCache({
flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault([]),
page: parseAsInteger.withDefault(1),
perPage: parseAsInteger.withDefault(10),
sort: getSortingStateParser<ProcurementVendorQuotations>().withDefault([
{ id: "updatedAt", desc: true },
]),
// 고급 필터
filters: getFiltersStateParser().withDefault([]),
joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
// 기본 필터 (RFQFilterBox) - 새로운 필드 추가
basicFilters: getFiltersStateParser().withDefault([]),
basicJoinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
search: parseAsString.withDefault(""),
from: parseAsString.withDefault(""),
to: parseAsString.withDefault(""),
});
export type GetQuotationsSchema = Awaited<ReturnType<typeof searchParamsVendorRfqCache.parse>>;
|