PromucFlow_constructor/app/client/src/widgets/PhoneInputWidget/component/utilities.ts
balajisoundar 02785b90b2
feat: Input, Phone no., Currency input widget (#10259)
* feat: Input, Phone no., Currency Widget

* cypress tests, jest test, QA and CR callouts

* fix tests

* Cypress and jest test fixes
2022-01-18 13:22:24 +05:30

14 lines
447 B
TypeScript

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;
};