Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/**
* Provides lookup data for countryies.
*/
import _ from 'lodash';
import countryUtil from 'i18n-iso-countries';
import enCountries from 'i18n-iso-countries/langs/en.json';
countryUtil.registerLocale(enCountries);
const countries = [];
_.forIn(countryUtil.getNames('en'), (name, alpha2) => {
countries.push({ name, alpha3: countryUtil.alpha2ToAlpha3(alpha2) });
});
export function getCountryObjFromAlpha3(alpha3) {
if (!alpha3) {
return null;
}
const name = countryUtil.getName(alpha3, 'en');
if (!name) {
return null;
}
return { name, alpha3 };
}
export function getAllCountryObjects() {
return countries;
options() {
return Object.entries(countries.getNames('en')).map(country => {
return {
id: country[1],
name: countries.getName(country[0], window.languageCode),
};
});
},
rules() {
useEffect(() => {
if (displayCountryNameOnHover && isEmpty(countries.getNames('en'))) {
countries.registerLocale(countryJson);
}
}, []);
const flag = getFlag(countryCode);
export default ({ data }) => {
const countries = require('i18n-iso-countries').getNames('en');
const [searchTerm, setSearchTerm] = useState('');
const countriesWithContent = flattenDeep([
...new Set(
data.allLinksYaml.edges
.map(({ node }) => node.countries)
.filter(countryList => !!countryList)
),
]).map(countryCode => countryCode.toUpperCase());
return (
{({ country, setCountry, clearCountry }) => (
<div>
<div></div></div>
data() {
return {
localStoreKey: 'linkedPhone',
previouslyVerified: false,
addSpace: false,
finalizingSwap: false,
countryList: Object.entries(getNames('en')),
complete: {
step1: false,
step2: false
},
steps: {
step1: true,
step2: false
},
inputCountryCode: {
title: this.$t('swap.exit-to-fiat.country-code'),
placeHolder: '000'
},
inputPhoneNumber: {
title: this.$t('swap.exit-to-fiat.phone-number'),
placeHolder: '000-000-0000'
},
full: false,
whitelist: ladders,
required: false,
missingError: ({ t, prefix }) => {
return new SwitchbladeEmbed().setTitle(t('commands:steamladder.noLadder'))
.setDescription([
this.usage(t, prefix),
'',
`__**${t('commands:steamladder.availableLadders')}:**__`,
`**${ladders.map(l => `\`${l}\``).join(', ')}**`
].join('\n'))
}
}, {
type: 'string',
required: false,
whitelist: Object.keys(countries.getNames('en')).map(c => c.toLowerCase()).concat(Object.keys(countries.getNames('en'))).concat(regions),
missingError: ({ t, prefix }) => {
return new SwitchbladeEmbed().setTitle(t('commands:steamladder.noRegion'))
.setDescription([
this.usage(t, prefix),
'',
`__**${t('commands:steamladder.availableRegions')}:**__`,
`**${regions.map(l => `\`${l}\``).join(', ')}**`,
'',
`[${t('commands:steamladder.youCanAlsoUse')}](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)`
].join('\n'))
}
}]
}, client)
}