PromucFlow_constructor/app/client/src/widgets/PhoneInputWidget/component/utilities.ts

14 lines
447 B
TypeScript
Raw Normal View History

import { ISDCodeOptions } from "constants/ISDCodes_v2";
export const countryToFlag = (dialCode: string) => {
const country = ISDCodeOptions.find((item) => item.dial_code === dialCode);
const isoCode = country ? country.code : "";
return typeof String.fromCodePoint !== "undefined"
? isoCode
.toUpperCase()
.replace(/./g, (char) =>
String.fromCodePoint(char.charCodeAt(0) + 127397),
)
: isoCode;
};