Skip to content

Commit

Permalink
build: fix type errors (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
pure-js authored Jul 12, 2023
1 parent 2bcd394 commit f6989c3
Show file tree
Hide file tree
Showing 5 changed files with 2,304 additions and 2,639 deletions.
6 changes: 2 additions & 4 deletions app/helpers/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const COUNTRIES = [
export const COUNTRIES = new Map([
['united states (usa)', 'US'],
['germany', 'DE'],
['united kingdom (uk)', 'GB'],
Expand All @@ -10,6 +10,4 @@ const COUNTRIES = [
['italy', 'IT'],
['south korea', 'KR'],
['turkey', 'TR'],
];

export const Countries = new Map(COUNTRIES);
]);
6 changes: 3 additions & 3 deletions app/helpers/getEmojiFlagByISO.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Countries } from './constants';
import { COUNTRIES } from './constants';

export function getEmojiFlagByISO(countryCode: string) {
const codePoints = countryCode
Expand All @@ -8,7 +8,7 @@ export function getEmojiFlagByISO(countryCode: string) {
return String.fromCodePoint(...codePoints);
}

export function getISObyCountryName(name: string): string {
export function getISObyCountryName(name: string) {
const ISO = new Intl.Locale('en', { baseName: name });
return ISO;
}
Expand All @@ -18,7 +18,7 @@ export function formatName(name: string) {
}

export function getFlagByCountryName(name: string) {
const ISO = Countries.get(name.toLowerCase());
const ISO = COUNTRIES.get(name.toLowerCase());
console.log(ISO);
return ISO ? getEmojiFlagByISO(ISO) : '';
}
Loading

0 comments on commit f6989c3

Please sign in to comment.