Commit 4936f83f authored by Florent Chehab's avatar Florent Chehab

Info Provider added

parent e9c7e960
......@@ -21,9 +21,6 @@ import UniversityGeneralEditor from '../editors/UniversityGeneralEditor';
import {
universitiesElFetchData,
universitiesElInvalidated,
citiesFetchData,
countriesFetchData,
mainCampusesFetchData,
} from '../../../generated/actions';
const styles = theme => ({
......@@ -95,11 +92,9 @@ class UniversityGeneral extends MyComponent {
myRender() {
const univInfos = this.getFetchedData('universitiesEl');
const { classes } = this.props;
const { city, country } = this.getUnivCityAndCountry(this.props.univId);
const outsideData = {
city: city.name,
country: country.name
city: this.props.city.name,
country: this.props.country.name
}
return (
......@@ -128,9 +123,6 @@ UniversityGeneral.propTypes = {
const mapStateToProps = (state) => {
return {
universitiesEl: state.universitiesEl,
countries: state.countries,
cities: state.cities,
mainCampuses: state.mainCampuses
};
};
......@@ -138,9 +130,6 @@ const mapDispatchToProps = (dispatch) => {
return {
fetchData: {
universitiesEl: (univId) => dispatch(universitiesElFetchData(univId)),
countries: () => dispatch(countriesFetchData()),
cities: () => dispatch(citiesFetchData()),
mainCampuses: () => dispatch(mainCampusesFetchData()),
},
invalidateData: () => dispatch(universitiesElInvalidated(true, true))
};
......
import React from 'react';
import PropTypes from 'prop-types';
import compose from 'recompose/compose';
import { connect } from "react-redux";
import __pick from 'lodash/pick';
import MyComponent from '../../MyComponent';
import {
citiesFetchData,
countriesFetchData,
mainCampusesFetchData,
} from '../../../generated/actions';
class InfoProvider extends MyComponent {
myRender() {
const { city, country } = this.getUnivCityAndCountry(this.props.univId);
const propsToAdd = {
cityId: city.id,
countryId: country.id,
city: city,
country: country,
univId: this.props.univId
}
return (<this.props.renderAndAddPropsTo {...propsToAdd} />)
}
}
InfoProvider.propTypes = {
univId: PropTypes.string.isRequired
};
const mapStateToProps = (state) => {
return {
countries: state.countries,
cities: state.cities,
mainCampuses: state.mainCampuses
};
};
const mapDispatchToProps = (dispatch) => {
return {
fetchData: {
countries: () => dispatch(countriesFetchData()),
cities: () => dispatch(citiesFetchData()),
mainCampuses: () => dispatch(mainCampusesFetchData()),
},
};
};
export default compose(
connect(mapStateToProps, mapDispatchToProps)
)(InfoProvider);
\ No newline at end of file
......@@ -12,6 +12,7 @@ import UniversityGeneral from '../modules/UniversityGeneral';
import UniversitySemestersDates from '../modules/UniversitySemestersDates';
import UniversityDri from '../modules/UniversityDri';
import withWidth, { isWidthUp } from '@material-ui/core/withWidth';
import InfoProvider from '../shared/InfoProvider';
const styles = theme => ({
root1: {
......@@ -39,10 +40,16 @@ class GeneralInfoTab extends MyComponent {
<div style={{ flexGrow: 8, paddingRight: 2 * theme.spacing.unit }}>
<Grid container direction='column' >
<Grid item xs style={{ paddingBottom: 2 * theme.spacing.unit }} >
<UniversityGeneral visible={this.props.visible} univId={this.props.univId} />
<InfoProvider
univId={this.props.univId}
renderAndAddPropsTo={UniversityGeneral}
/>
</Grid>
<Grid item xs>
<UniversityDri visible={this.props.visible} univId={this.props.univId} />
<InfoProvider
univId={this.props.univId}
renderAndAddPropsTo={UniversityDri}
/>
</Grid>
</Grid>
</div>
......@@ -66,10 +73,16 @@ class GeneralInfoTab extends MyComponent {
<Grid container spacing={16} >
<Grid item xs={12}>
<UniversityGeneral visible={this.props.visible} univId={this.props.univId} />
<InfoProvider
univId={this.props.univId}
renderAndAddPropsTo={UniversityGeneral}
/>
</Grid>
<Grid item xs={12}>
<UniversityDri visible={this.props.visible} univId={this.props.univId} />
<InfoProvider
univId={this.props.univId}
renderAndAddPropsTo={UniversityDri}
/>
</Grid>
<Grid item xs={12}>
<UniversitySemestersDates visible={this.props.visible} univId={this.props.univId} />
......
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