Commit 2a664161 authored by Florent Chehab's avatar Florent Chehab

More specific provider

parent f9be8300
...@@ -117,7 +117,9 @@ class UniversityGeneral extends MyComponent { ...@@ -117,7 +117,9 @@ class UniversityGeneral extends MyComponent {
UniversityGeneral.propTypes = { UniversityGeneral.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired, theme: PropTypes.object.isRequired,
univId: PropTypes.string.isRequired univId: PropTypes.string.isRequired,
city: PropTypes.object.isRequired,
country: PropTypes.object.isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -21,22 +21,46 @@ class InfoProvider extends MyComponent { ...@@ -21,22 +21,46 @@ class InfoProvider extends MyComponent {
const universities = this.getFetchedData('universities'); const universities = this.getFetchedData('universities');
const countries = this.getFetchedData('countries'); const countries = this.getFetchedData('countries');
const propsToAdd = { let propsToAdd = { univId: this.props.univId, visible: this.props.visible };
universities,
countries, if (this.props.add) {
cityId: city.id, this.props.add.map(
countryId: country.id, (key) => {
city: city, switch (key) {
country: country, case 'universities':
univId: this.props.univId propsToAdd[key] = universities;
break;
case 'countries':
propsToAdd[key] = countries;
break;
case 'city':
propsToAdd[key] = city;
break;
case 'country':
propsToAdd[key] = country;
break;
case 'cityId':
propsToAdd[key] = city.id;
break;
case 'countryId':
propsToAdd[key] = country.id;
break;
default:
throw Error('Not supported.')
}
}
)
} }
return (<this.props.renderAndAddPropsTo {...propsToAdd} />) return (<this.props.renderAndAddPropsTo {...propsToAdd} />)
} }
} }
InfoProvider.propTypes = { InfoProvider.propTypes = {
univId: PropTypes.string.isRequired univId: PropTypes.string.isRequired,
add: PropTypes.arrayOf(PropTypes.string).isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
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