import { createSearchParamsCache, parseAsArrayOf, parseAsInteger, parseAsString, parseAsStringEnum, } from "nuqs/server" import * as z from "zod" import { getFiltersStateParser, getSortingStateParser } from "@/lib/parsers" import { techVendorPossibleItems } from "@/db/schema/techVendors" export const searchParamsTechVendorPossibleItemsCache = createSearchParamsCache({ flags: parseAsArrayOf(z.enum(["advancedTable", "floatingBar"])).withDefault([]), page: parseAsInteger.withDefault(1), perPage: parseAsInteger.withDefault(20), sort: getSortingStateParser().withDefault([ { id: "createdAt", desc: true }, ]), // advanced filter filters: getFiltersStateParser().withDefault([]), joinOperator: parseAsStringEnum(["and", "or"]).withDefault("and"), search: parseAsString.withDefault(""), // 추가 필터 (기존 호환성) vendorCode: parseAsString.withDefault(""), vendorName: parseAsString.withDefault(""), itemCode: parseAsString.withDefault(""), vendorType: parseAsString.withDefault(""), }) export const createTechVendorPossibleItemSchema = z.object({ vendorId: z.number().min(1, "벤더 ID는 필수입니다"), itemCode: z.string().min(1, "아이템 코드를 입력해주세요"), workType: z.string().nullable().optional(), shipTypes: z.string().nullable().optional(), itemList: z.string().nullable().optional(), subItemList: z.string().nullable().optional(), }) export const updateTechVendorPossibleItemSchema = createTechVendorPossibleItemSchema.extend({ id: z.number(), }) export const importTechVendorPossibleItemSchema = z.object({ vendorCode: z.string().optional(), vendorEmail: z.string().email("올바른 이메일 형식을 입력해주세요").min(1, "벤더 이메일을 입력해주세요"), itemCode: z.string().min(1, "아이템 코드를 입력해주세요"), workType: z.string().optional(), shipTypes: z.string().optional(), itemList: z.string().optional(), subItemList: z.string().optional(), }) export type CreateTechVendorPossibleItemSchema = z.infer export type UpdateTechVendorPossibleItemSchema = z.infer export type GetTechVendorPossibleItemsSchema = Awaited>