mirror of
https://git.meshkee.com/Meshkee/dashboards.git
synced 2026-08-11 22:30:58 +04:30
Includes business, customer, and super-admin apps with shared packages and production deploy scripts. Co-authored-by: Cursor <cursoragent@cursor.com>
31 lines
688 B
TypeScript
31 lines
688 B
TypeScript
/** Normalize Iranian/local input to E.164 (e.g. +989121111111). */
|
|
export function toE164CellNumber(input: string): string {
|
|
const digits = input.replace(/\D/g, '')
|
|
|
|
if (!digits) {
|
|
return ''
|
|
}
|
|
|
|
if (digits.startsWith('98')) {
|
|
return `+${digits}`
|
|
}
|
|
|
|
if (digits.startsWith('0')) {
|
|
return `+98${digits.slice(1)}`
|
|
}
|
|
|
|
if (digits.length === 10 && digits.startsWith('9')) {
|
|
return `+98${digits}`
|
|
}
|
|
|
|
return `+${digits}`
|
|
}
|
|
|
|
/** Display E.164 Iranian numbers as local format (e.g. 0912...). */
|
|
export function formatCellForDisplay(cellNumber: string): string {
|
|
if (cellNumber.startsWith('+98')) {
|
|
return `0${cellNumber.slice(3)}`
|
|
}
|
|
return cellNumber
|
|
}
|