Spaces:
Runtime error
Runtime error
| import { z } from "zod"; | |
| import { | |
| customerDatePresetValues, | |
| customerGenderValues, | |
| sessionDatePresetValues, | |
| } from "@/lib/constants"; | |
| const phoneRegex = /^[0-9+\s()\-]+$/; | |
| export const customerSchema = z.object({ | |
| firstName: z | |
| .string() | |
| .trim() | |
| .min(2, "ุงูุงุณู ุงูุฃูู ูุงุฒู ูููู ุญุฑููู ุนูู ุงูุฃูู.") | |
| .max(60, "ุงูุงุณู ุงูุฃูู ุทููู ุฒูุงุฏุฉ ุนู ุงููุฒูู ."), | |
| middleName: z | |
| .string() | |
| .trim() | |
| .max(60, "ุงูุงุณู ุงูุฃูุณุท ุทููู ุฒูุงุฏุฉ ุนู ุงููุฒูู .") | |
| .optional() | |
| .or(z.literal("")), | |
| lastName: z | |
| .string() | |
| .trim() | |
| .min(2, "ุงุณู ุงูุนููุฉ ูุงุฒู ูููู ุญุฑููู ุนูู ุงูุฃูู.") | |
| .max(60, "ุงุณู ุงูุนููุฉ ุทููู ุฒูุงุฏุฉ ุนู ุงููุฒูู ."), | |
| gender: z.enum(customerGenderValues, { | |
| error: "ุงุฎุชุงุฑ ุงูููุน.", | |
| }), | |
| phone: z | |
| .string() | |
| .trim() | |
| .min(7, "ุฑูู ุงูู ูุจุงูู ูุตูุฑ ุฌุฏูุง.") | |
| .max(30, "ุฑูู ุงูู ูุจุงูู ุทููู ุฒูุงุฏุฉ ุนู ุงููุฒูู .") | |
| .regex(phoneRegex, "ุฑูู ุงูู ูุจุงูู ูุงุฒู ูุญุชูู ุนูู ุฃุฑูุงู ูุฑู ูุฒ ุตุญูุญุฉ ุจุณ."), | |
| }); | |
| export const customerListQuerySchema = z.object({ | |
| search: z.string().trim().max(100).optional().catch(undefined), | |
| gender: z.enum(customerGenderValues).optional().catch(undefined), | |
| createdPreset: z | |
| .enum(customerDatePresetValues) | |
| .optional() | |
| .catch(undefined) | |
| .default("all"), | |
| page: z.coerce.number().int().min(1).optional().catch(1).default(1), | |
| }); | |
| export const customerDetailsQuerySchema = z.object({ | |
| tab: z | |
| .enum(["info", "cases", "sessions", "archive"]) | |
| .optional() | |
| .catch(undefined), | |
| caseSearch: z.string().trim().max(100).optional().catch(undefined), | |
| caseType: z | |
| .enum(["CIVIL", "CRIMINAL", "PERSONAL_STATUS"]) | |
| .optional() | |
| .catch(undefined), | |
| archiveSearch: z.string().trim().max(100).optional().catch(undefined), | |
| archiveFileId: z.string().trim().optional().catch(undefined), | |
| sessionPreset: z | |
| .enum(sessionDatePresetValues) | |
| .optional() | |
| .catch(undefined) | |
| .default("all"), | |
| sessionId: z.string().trim().optional().catch(undefined), | |
| }); | |
| export type CustomerInput = z.infer<typeof customerSchema>; | |
| export type CustomerListQueryInput = z.infer<typeof customerListQuerySchema>; | |
| export type CustomerDetailsQueryInput = z.infer<typeof customerDetailsQuerySchema>; | |