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

More specific provider

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