refactoring
This commit is contained in:
20
src/components/PhoneInput/utils/getInitialDataFromValue.ts
Normal file
20
src/components/PhoneInput/utils/getInitialDataFromValue.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { CountryCode } from "libphonenumber-js";
|
||||
import { Country } from "@/components/PhoneInput/types";
|
||||
import countryOptionsDataMap from "@/components/PhoneInput/utils/countryOptionsDataMap";
|
||||
import getPhoneMask from "@/components/PhoneInput/utils/getPhoneMask";
|
||||
|
||||
type InitialDataFromValue = {
|
||||
country: Country;
|
||||
format: ReturnType<typeof getPhoneMask>;
|
||||
};
|
||||
|
||||
const getInitialDataFromValue = (
|
||||
initialCountryCode: string
|
||||
): InitialDataFromValue => {
|
||||
return {
|
||||
country: countryOptionsDataMap[initialCountryCode],
|
||||
format: getPhoneMask(initialCountryCode as CountryCode),
|
||||
};
|
||||
};
|
||||
|
||||
export default getInitialDataFromValue;
|
||||
Reference in New Issue
Block a user