- Create apps/web/lib/phone.ts with VN_PHONE_REGEX, normalizePhone, formatPhone, and zaloHref helpers - Deduplicate phone regex: auth.ts and inquiry.ts now import VN_PHONE_REGEX from @/lib/phone instead of defining their own local patterns - Replace raw .replace(/^0/, '84') in inquiry-detail-dialog.tsx and lead-detail-dialog.tsx with zaloHref(); use formatPhone() for display Resolves GOO-209 Co-Authored-By: Paperclip <noreply@paperclip.ing>
19 lines
637 B
TypeScript
19 lines
637 B
TypeScript
import { z } from 'zod';
|
|
|
|
import { VN_PHONE_REGEX as PHONE_REGEX } from '@/lib/phone';
|
|
|
|
export const inquiryFormSchema = z.object({
|
|
message: z
|
|
.string({ error: 'Vui lòng nhập nội dung tin nhắn' })
|
|
.trim()
|
|
.min(1, 'Vui lòng nhập nội dung tin nhắn')
|
|
.max(2000, 'Tin nhắn không được vượt quá 2000 ký tự'),
|
|
phone: z
|
|
.string({ error: 'Vui lòng nhập số điện thoại' })
|
|
.trim()
|
|
.min(9, 'Vui lòng nhập số điện thoại hợp lệ')
|
|
.regex(PHONE_REGEX, 'Số điện thoại không hợp lệ'),
|
|
});
|
|
|
|
export type InquiryFormData = z.infer<typeof inquiryFormSchema>;
|