stuff done

This commit is contained in:
2025-03-11 02:54:09 +02:00
parent 58e7ed2f06
commit 516b45fad9
90 changed files with 2950 additions and 9458 deletions

View File

@@ -0,0 +1,38 @@
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()
})