feat(web): add lib/phone.ts with formatPhone/normalizePhone/zaloHref helpers

- 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>
This commit is contained in:
Ho Ngoc Hai
2026-04-24 12:01:14 +07:00
parent d7c5b1ca2c
commit b4bb05479e
6 changed files with 102 additions and 13 deletions

View File

@@ -1,6 +1,6 @@
import { z } from 'zod';
const phoneRegex = /^(0|\+84)(3[2-9]|5[2689]|7[06-9]|8[1-9]|9[0-9])\d{7}$/;
import { VN_PHONE_REGEX as phoneRegex } from '@/lib/phone';
export const loginSchema = z.object({
phone: z

View File

@@ -1,12 +1,6 @@
import { z } from 'zod';
/**
* Vietnamese phone number rule:
* - 911 digits, optional leading +84 or 0.
* We keep validation pragmatic: whitespace is stripped, then the remaining
* string must be 911 digits (country code / leading zero stripped).
*/
const PHONE_REGEX = /^(?:\+?84|0)?\d{9,11}$/;
import { VN_PHONE_REGEX as PHONE_REGEX } from '@/lib/phone';
export const inquiryFormSchema = z.object({
message: z