Files
tm_panel/src/constants/phone-countries.ts
T
AmirReza Jamali d9a945904a feat(phone-input): integrate phone number input component and validation
- Added `libphonenumber-js` dependency for improved phone number handling.
- Refactored `CreateAdmin` form to utilize a new `PhoneNumberInput` component with validation rules.
- Updated `useCreateAdminPresenter` to normalize phone number input before submission.
- Enhanced error messages for phone validation in `Texts` constant.
- Modified `User` schema to validate phone numbers using E.164 format.
2026-05-16 10:28:03 +03:30

23 lines
749 B
TypeScript

import { getCountryLabel } from "@/lib/phone/e164";
import { getCountries, getCountryCallingCode } from "libphonenumber-js";
import type { CountryCode } from "libphonenumber-js";
import type { ILabelValue } from "@/types/shared";
export type PhoneCountryOption = ILabelValue<CountryCode> & {
callingCode: string;
};
export const PHONE_COUNTRIES: PhoneCountryOption[] = getCountries()
.map((code) => {
const callingCode = getCountryCallingCode(code);
const name = getCountryLabel(code);
return {
value: code,
label: `${name} (+${callingCode})`,
callingCode,
};
})
.sort((a, b) => a.label.localeCompare(b.label, undefined, { sensitivity: "base" }));
export const DEFAULT_PHONE_COUNTRY: CountryCode = "US";