);
}
Option.propTypes = {
+ selectOption: PropTypes.func.isRequired,
+ data: PropTypes.shape({}).isRequired,
children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node
@@ -275,11 +344,12 @@ const components = {
DropdownIndicator: null
};
-const DEFAULT_OPTIONS = [
- { value: 'nairobi', label: 'Nairobi, Kenya' },
- { value: 'lagos', label: 'Lagos, Nigeria' },
- { value: 'dar-es-salaam', label: 'Dar-es-Salaam, Tanzania' }
-];
+const DEFAULT_OPTIONS = [{ value: 'locate-me', label: 'LOCATE ME' }].concat(
+ Object.values(CITIES_LOCATION).map(({ slug: value, name: label }) => ({
+ value,
+ label
+ }))
+);
class SearchBar extends React.Component {
constructor(props) {
diff --git a/src/pages/air/City.js b/src/pages/air/City.js
index e751c424..de098f87 100644
--- a/src/pages/air/City.js
+++ b/src/pages/air/City.js
@@ -102,8 +102,6 @@ const styles = () => ({
}
});
-const CITY_PATHNAME = '/air/city';
-
class City extends React.Component {
constructor() {
super();
@@ -207,7 +205,8 @@ class City extends React.Component {
const searchedCity = (option && option.value) || DEFAULT_CITY;
const { city } = this.state;
if (searchedCity !== city) {
- const path = `${CITY_PATHNAME}/${searchedCity}`;
+ const path =
+ city === 'locate-me' ? '/air/locate-me' : `/air/city/${searchedCity}`;
const { history } = this.props;
history.push(path);
diff --git a/src/pages/air/index.js b/src/pages/air/index.js
index a380590f..2ccd4036 100644
--- a/src/pages/air/index.js
+++ b/src/pages/air/index.js
@@ -19,7 +19,6 @@ import Support from '../../components/Support';
import HealthAndClimateImpacts from './HealthAndClimateImpacts';
import Showcase from '../../components/Showcase';
-const CITY_PATHNAME = '/air/city';
class AirHome extends React.Component {
constructor(props) {
super(props);
@@ -28,7 +27,8 @@ class AirHome extends React.Component {
}
handleSearch(city) {
- const path = `${CITY_PATHNAME}/${city.value}`;
+ const path =
+ city.value === 'locate-me' ? '/air/locate-me' : `/air/city/${city.value}`;
const { history } = this.props;
history.push(path);
}