samrocksc
9/11/2018 - 5:59 PM

Sorting Things

Sorting Things

import countryCodes from './countryCodes.json';

const countryCallingCodeList = () => {
  let codes = [];
  countryCodes
    .filter(country => {
      if (country.countryCallingCodes.length === 0) {
        return false;
      }
      return true;
    })
    .forEach(country => {
      const codeLists = country.countryCallingCodes.map(code => {
        return {
          value: code,
          label: `${country.name}(${code})`,
        };
      });
      codes = codes.concat(codeLists);
    });
  return codes;
};

export default countryCallingCodeList;