Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
4936f83f
Commit
4936f83f
authored
Sep 15, 2018
by
Florent Chehab
Browse files
Info Provider added
parent
e9c7e960
Changes
3
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/university/modules/UniversityGeneral.js
View file @
4936f83f
...
...
@@ -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
))
};
...
...
frontend/src/components/university/shared/InfoProvider.js
0 → 100644
View file @
4936f83f
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
frontend/src/components/university/tabs/GeneralInfoTab.js
View file @
4936f83f
...
...
@@ -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
}
/
>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment