Commit 665eeff7 authored by Ben Wheeler's avatar Ben Wheeler

move country name lookup to library

parent 1bab2bb5
......@@ -466,7 +466,7 @@ class DemographicsStep extends React.Component {
// look up country code from country label ('United States' -> 'us')
// if `countryName` is not found, including if it's null or undefined, then this function will return undefined.
getCountryCode (countryName) {
const country = countryData.countryInfo.find(countryItem => countryItem.name === countryName);
const country = countryData.lookupCountryName(countryName);
return country && country.code;
}
handleValidSubmit (formData) {
......
......@@ -1040,6 +1040,10 @@ module.exports.lookupCountryInfo = countryCode => (
countryInfo.find(country => country.code === countryCode)
);
module.exports.lookupCountryName = countryName => (
countryInfo.find(country => country.name === countryName)
);
/**
* Function dupeCommonCountries():
* takes startingCountryInfo, and duplicates any number of its country labels
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment