feat: standardize contact formatting
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { formatPhone } from '~/utils/formatters/phone';
|
||||
|
||||
export interface ConstructeurSummary {
|
||||
id: string;
|
||||
name?: string | null;
|
||||
@@ -92,8 +94,16 @@ export const resolveConstructeurs = (
|
||||
|
||||
export const formatConstructeurContact = (
|
||||
constructeur?: ConstructeurSummary | null,
|
||||
): string =>
|
||||
[constructeur?.email, constructeur?.phone].filter(Boolean).join(' • ');
|
||||
): string => {
|
||||
if (!constructeur) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const formattedPhone = formatPhone(constructeur.phone);
|
||||
const phone = formattedPhone || constructeur.phone || null;
|
||||
|
||||
return [constructeur.email, phone].filter(Boolean).join(' • ');
|
||||
};
|
||||
|
||||
export const buildConstructeurRequestPayload = <T extends Record<string, any>>(
|
||||
payload: T,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { normalizeEmail } from '~/utils/formatters/email'
|
||||
|
||||
export const EMAIL_INPUT_PATTERN = '[^\s@]+'
|
||||
|
||||
const EMAIL_VALIDATION_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
|
||||
|
||||
export const EMAIL_INPUT_PATTERN = EMAIL_VALIDATION_PATTERN.source
|
||||
|
||||
export type EmailValidationResult = {
|
||||
valid: boolean
|
||||
error?: string
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { normalizePhone } from '~/utils/formatters/phone'
|
||||
|
||||
/** Pattern used for the HTML input `pattern` attribute on phone fields. */
|
||||
export const PHONE_INPUT_PATTERN = '[0-9+ ]*'
|
||||
export const PHONE_INPUT_PATTERN = '[0-9+ .]*'
|
||||
|
||||
const PHONE_VALIDATION_PATTERN = /^\+?\d{7,15}$/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user