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.
This commit is contained in:
AmirReza Jamali
2026-05-16 10:28:03 +03:30
parent f79348312b
commit d9a945904a
11 changed files with 378 additions and 25 deletions
+22
View File
@@ -0,0 +1,22 @@
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";