summaryrefslogtreecommitdiff
path: root/lib/edp-progress/validations.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/edp-progress/validations.ts')
-rw-r--r--lib/edp-progress/validations.ts28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/edp-progress/validations.ts b/lib/edp-progress/validations.ts
new file mode 100644
index 00000000..f2e9326d
--- /dev/null
+++ b/lib/edp-progress/validations.ts
@@ -0,0 +1,28 @@
+import {
+ createSearchParamsCache,
+ parseAsArrayOf,
+ parseAsInteger,
+ parseAsString,
+ parseAsStringEnum,
+} from "nuqs/server"
+import * as z from "zod"
+
+import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers"
+import type { EDPVendorRow } from "./table/edp-progress-table-columns"
+
+export const searchParamsCache = createSearchParamsCache({
+ flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault(
+ []
+ ),
+ page: parseAsInteger.withDefault(1),
+ perPage: parseAsInteger.withDefault(10),
+ sort: getSortingStateParser<EDPVendorRow>().withDefault([
+ { id: "completionPercentage", desc: true },
+ ]),
+ // advanced filter
+ filters: getFiltersStateParser().withDefault([]),
+ joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"),
+ search: parseAsString.withDefault(""),
+})
+
+export type GetEDPProgressSchema = Awaited<ReturnType<typeof searchParamsCache.parse>>