Spaces:
Runtime error
Runtime error
File size: 2,404 Bytes
ad79323 | 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 | 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>;
|