import {DeliveryOption, Lang, Order} from '@prisma/client' import {z} from 'zod' interface Map { [key: string]: string | undefined } export const DeliveryOptionTypeDescription: Map = { NP: 'До відділення «Нової Пошти»', PICKUP: 'Самовивіз (для Києва)', COURIER: "Кур'єр (для Києва)" } export const createOrderFormSchema = z.object({ user_id: z.string().optional(), is_quick: z.boolean(), lang: z.enum(Object.keys(Lang) as [string, ...string[]]), first_name: z.coerce.string().trim().min(1).max(255), //patronymic: z.coerce.string().trim().min(1).max(255), surname: z.coerce.string().trim().min(1).max(255), delivery_option: z.enum( Object.keys(DeliveryOption) as [string, ...string[]], { message: "Обов'язкове до вибору" } ), phone: z.coerce.string().trim().min(1).max(24), email: z.coerce .string() .trim() .regex(/^[A-Za-z0-9\._%+\-]+@[A-Za-z0-9\.\-]+\.[A-Za-z]{2,}$/, { message: 'Ведуть коректну e-mail адресу' }) .max(320), address: z.coerce.string().trim(), notes: z.coerce.string().trim().max(1024).optional(), details: z.coerce.string().trim() })