Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 124x 5x 5x 124x 16x 6x 124x 124x 7x 5x 5x 5x 124x | import { getCountryNameFromCode } from "@utils/country_dial_codes";
import {
TPrimaryAccountHolderAdress,
} from "../data.types";
export const parseTaxID = (id: string) => {
Iif (!id) return id;
Eif (id?.length > 2) return id.slice(0, 2) + "-" + id.slice(2);
return id;
};
// 999999999 to 99-9999999
export const formatEIN = (id: string) => {
if (!id) return id;
Eif (id?.length > 2) return id.replace(/^(\d{2})(\d{7})$/, "$1-$2");
return id;
};
// 999999999 to 999-99-9999
export const formatSSN = (id: string) => {
if (!id) return id;
if (id?.length > 2)
return id.replace(/\D/g, "").replace(/^(\d{3})(\d{2})(\d{4})$/, "$1-$2-$3");
return id;
};
export const betterPhoneNumber = (
phoneNumber: string | undefined,
): string | null => {
if (!phoneNumber) return null;
// Check if the phoneNumber has a valid length
const isValidLength = phoneNumber.length === 11;
Eif (!isValidLength) {
return phoneNumber;
}
const formatted = `${phoneNumber.substring(0, 1)} (${phoneNumber.substring(
1,
4,
)}) ${phoneNumber.substring(4, 7)}-${phoneNumber.substring(7)}`;
return formatted;
};
export const formatPrimaryAccountHolderAddress = (
address: TPrimaryAccountHolderAdress,
) => {
if (!address || !address.line1) return "";
const { line1, city, state, country, zip } = address;
return `${line1}, ${city}, ${state}, ${zip}, ${getCountryNameFromCode(
country,
)}`;
};
|