Task/refactor country code logic in data provider services (#6993)
Refactor country code logicpull/6902/head
parent
3da6380618
commit
bf7409ec20
@ -0,0 +1,17 @@
|
||||
import { countries } from 'countries-list';
|
||||
|
||||
export function getCountryCodeByName({
|
||||
aliases = {},
|
||||
name
|
||||
}: {
|
||||
aliases?: Record<string, string>;
|
||||
name: string;
|
||||
}): string {
|
||||
for (const [code, country] of Object.entries(countries)) {
|
||||
if (country.name === name || country.name === aliases[name]) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
Loading…
Reference in new issue