Commit 1237854b authored by Florent Chehab's avatar Florent Chehab
Browse files

Merge branch 'cleaning' into 'master'

Cleaning

Closes #48 and #47

See merge request rex-dri/rex-dri!48
parents 909dae0d 827fa5b8
...@@ -42,6 +42,7 @@ function TabContainer(props) { ...@@ -42,6 +42,7 @@ function TabContainer(props) {
TabContainer.propTypes = { TabContainer.propTypes = {
children: PropTypes.node.isRequired, children: PropTypes.node.isRequired,
visible: PropTypes.bool.isRequired
}; };
const styles = theme => ({ const styles = theme => ({
...@@ -81,7 +82,7 @@ class UniversityTemplate extends React.Component { ...@@ -81,7 +82,7 @@ class UniversityTemplate extends React.Component {
<Tabs <Tabs
value={value} value={value}
onChange={this.handleChange} onChange={this.handleChange}
scrollable={scroll} variant={scroll ? "scrollable" : "standard"}
centered={!scroll} centered={!scroll}
scrollButtons="on" scrollButtons="on"
indicatorColor="primary" indicatorColor="primary"
...@@ -110,6 +111,7 @@ class UniversityTemplate extends React.Component { ...@@ -110,6 +111,7 @@ class UniversityTemplate extends React.Component {
UniversityTemplate.propTypes = { UniversityTemplate.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
width: PropTypes.string.isRequired,
}; };
export default compose( export default compose(
......
...@@ -96,7 +96,7 @@ CountryDri.propTypes = { ...@@ -96,7 +96,7 @@ CountryDri.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired, theme: PropTypes.object.isRequired,
countryId: PropTypes.string.isRequired, countryId: PropTypes.string.isRequired,
countries: PropTypes.object.isRequired, countries: PropTypes.array.isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -116,8 +116,8 @@ CountryScholarships.propTypes = { ...@@ -116,8 +116,8 @@ CountryScholarships.propTypes = {
theme: PropTypes.object.isRequired, theme: PropTypes.object.isRequired,
countryId: PropTypes.string.isRequired, countryId: PropTypes.string.isRequired,
country: PropTypes.object.isRequired, country: PropTypes.object.isRequired,
countries: PropTypes.object.isRequired, countries: PropTypes.array.isRequired,
currencies: PropTypes.object.isRequired, currencies: PropTypes.array.isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -99,7 +99,7 @@ UniversityDri.propTypes = { ...@@ -99,7 +99,7 @@ UniversityDri.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,
universities: PropTypes.object.isRequired, universities: PropTypes.array.isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -42,11 +42,11 @@ function renderCore(rawModelData, classes, outsideData) { ...@@ -42,11 +42,11 @@ function renderCore(rawModelData, classes, outsideData) {
</Grid> </Grid>
<Grid item xs> <Grid item xs>
<Typography variant='headline'>{name}</Typography> <Typography variant='h5'>{name}</Typography>
<Typography variant='title'>{acronym}</Typography> <Typography variant='h6'>{acronym}</Typography>
<Divider /> <Divider />
<Typography variant='subheading'>{city}, {country}</Typography> <Typography variant='subtitle1'>{city}, {country}</Typography>
<Typography variant='body1'> Site internet&nbsp;:{" "} <Typography variant='body2'> Site internet&nbsp;:{" "}
{ {
website != "" ? website != "" ?
<TextLink href={website}>{website}</TextLink> <TextLink href={website}>{website}</TextLink>
......
...@@ -113,8 +113,8 @@ UniversityScholarships.propTypes = { ...@@ -113,8 +113,8 @@ UniversityScholarships.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,
universities: PropTypes.object.isRequired, universities: PropTypes.array.isRequired,
currencies: PropTypes.object.isRequired, currencies: PropTypes.array.isRequired,
}; };
const mapStateToProps = (state) => { const mapStateToProps = (state) => {
......
...@@ -99,6 +99,7 @@ Alert.propTypes = { ...@@ -99,6 +99,7 @@ Alert.propTypes = {
handleClose: PropTypes.func.isRequired, handleClose: PropTypes.func.isRequired,
handleResponse: PropTypes.func.isRequired, handleResponse: PropTypes.func.isRequired,
multilineButtons: PropTypes.bool.isRequired, multilineButtons: PropTypes.bool.isRequired,
classes: PropTypes.object.isRequired
}; };
......
...@@ -255,7 +255,7 @@ class Editor extends CustomComponentForAPI { ...@@ -255,7 +255,7 @@ class Editor extends CustomComponentForAPI {
<IconButton color="inherit" onClick={() => this.handleCloseEditorRequest()} aria-label="Close"> <IconButton color="inherit" onClick={() => this.handleCloseEditorRequest()} aria-label="Close">
<CloseIcon /> <CloseIcon />
</IconButton> </IconButton>
<Typography variant="title" color="inherit" className={classes.flex}> <Typography variant="h6" color="inherit" className={classes.flex}>
Mode édition Mode édition
</Typography> </Typography>
<Button color="inherit" onClick={() => this.handleSaveEditor()}> <Button color="inherit" onClick={() => this.handleSaveEditor()}>
......
...@@ -7,7 +7,7 @@ import { connect } from "react-redux"; ...@@ -7,7 +7,7 @@ import { connect } from "react-redux";
import Typography from "@material-ui/core/Typography"; import Typography from "@material-ui/core/Typography";
import Paper from "@material-ui/core/Paper"; import Paper from "@material-ui/core/Paper";
import Tooltip from "@material-ui/core/Tooltip"; import Tooltip from "@material-ui/core/Tooltip";
import Button from "@material-ui/core/Button"; import Fab from "@material-ui/core/Fab";
import Grid from "@material-ui/core/Grid"; import Grid from "@material-ui/core/Grid";
import Divider from "@material-ui/core/Divider"; import Divider from "@material-ui/core/Divider";
...@@ -74,15 +74,14 @@ class GenericGroupModule extends CustomComponentForAPI { ...@@ -74,15 +74,14 @@ class GenericGroupModule extends CustomComponentForAPI {
<Grid container spacing={8} alignItems='center'> <Grid container spacing={8} alignItems='center'>
<Grid item xs> <Grid item xs>
<Typography variant='title' align='center' color="textSecondary"><em>{groupTitle}</em></Typography> <Typography variant='h6' align='center' color="textSecondary"><em>{groupTitle}</em></Typography>
</Grid> </Grid>
<Grid item xs={2} style={{ textAlign: "right" }}> <Grid item xs={2} style={{ textAlign: "right" }}>
<Tooltip title={disabled ? "Vous ne pouvez pas ajouter d'élément" : "Ajouter un élément"} placement="top"> <Tooltip title={disabled ? "Vous ne pouvez pas ajouter d'élément" : "Ajouter un élément"} placement="top">
<div style={{ display: "inline-block" }}> {/* Needed to fire events for the tooltip when below is disabled! */} <div style={{ display: "inline-block" }}> {/* Needed to fire events for the tooltip when below is disabled! */}
<Button <Fab
variant='fab' size='small'
mini
aria-label="Ajouter un élément" aria-label="Ajouter un élément"
disabled={disabled} disabled={disabled}
style={disabled ? {} : { backgroundColor: green.A700 }} style={disabled ? {} : { backgroundColor: green.A700 }}
...@@ -90,7 +89,7 @@ class GenericGroupModule extends CustomComponentForAPI { ...@@ -90,7 +89,7 @@ class GenericGroupModule extends CustomComponentForAPI {
onClick={this.handleOpenEditor} onClick={this.handleOpenEditor}
> >
<AddIcon /> <AddIcon />
</Button> </Fab>
</div> </div>
</Tooltip> </Tooltip>
</Grid> </Grid>
......
...@@ -66,7 +66,7 @@ const styles = theme => ({ ...@@ -66,7 +66,7 @@ const styles = theme => ({
}, },
titleIcon: { titleIcon: {
paddingRight: theme.spacing.unit, paddingRight: theme.spacing.unit,
fontSize: theme.typography.display1.fontSize fontSize: theme.typography.h4.fontSize
} }
}); });
......
...@@ -68,6 +68,7 @@ class History extends React.Component { ...@@ -68,6 +68,7 @@ class History extends React.Component {
} }
getContentTypeAndId() { getContentTypeAndId() {
// eslint-disable-next-line react/prop-types
const { rawModelData } = this.props.factory.props; const { rawModelData } = this.props.factory.props;
const { content_type_id, id } = rawModelData; const { content_type_id, id } = rawModelData;
return { content_type_id, id }; return { content_type_id, id };
...@@ -109,7 +110,7 @@ class History extends React.Component { ...@@ -109,7 +110,7 @@ class History extends React.Component {
return ( return (
<div> <div>
<Typography variant='caption' align='center'>Les versions successives d'un même utilisateur ne sont pas enregistrés (dans de tels cas, seul la dernière est conservée).</Typography> <Typography variant='caption' align='center'>Les versions successives d'un même utilisateur ne sont pas enregistrés (dans de tels cas, seul la dernière est conservée).</Typography>
<Typography variant='title' align='center'>Version n°{this.state.versionInView + 1} du {dateInfo}</Typography> <Typography variant='h6' align='center'>Version n°{this.state.versionInView + 1} du {dateInfo}</Typography>
<Button <Button
variant='outlined' variant='outlined'
color="primary" color="primary"
...@@ -181,7 +182,7 @@ class History extends React.Component { ...@@ -181,7 +182,7 @@ class History extends React.Component {
<IconButton color="inherit" onClick={() => { this.props.handleCloseHistory(); this.props.resetVersions(); }} aria-label="Close"> <IconButton color="inherit" onClick={() => { this.props.handleCloseHistory(); this.props.resetVersions(); }} aria-label="Close">
<CloseIcon /> <CloseIcon />
</IconButton> </IconButton>
<Typography variant="title" color="inherit" className={classes.flex}> <Typography variant="h6" color="inherit" className={classes.flex}>
Parcours de l'historique Parcours de l'historique
</Typography> </Typography>
</Toolbar> </Toolbar>
...@@ -199,6 +200,11 @@ History.propTypes = { ...@@ -199,6 +200,11 @@ History.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
factory: PropTypes.object.isRequired, factory: PropTypes.object.isRequired,
handleRestoreVersion: PropTypes.func.isRequired, handleRestoreVersion: PropTypes.func.isRequired,
readVersions: PropTypes.func.isRequired,
handleCloseHistory: PropTypes.func.isRequired,
resetVersions: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
versions: PropTypes.object.isRequired
}; };
History.defaultProps = { History.defaultProps = {
......
...@@ -101,7 +101,7 @@ class PendingModeration extends React.Component { ...@@ -101,7 +101,7 @@ class PendingModeration extends React.Component {
<IconButton color="inherit" onClick={() => { this.props.handleClosePendingModeration(); }} aria-label="Close"> <IconButton color="inherit" onClick={() => { this.props.handleClosePendingModeration(); }} aria-label="Close">
<CloseIcon /> <CloseIcon />
</IconButton> </IconButton>
<Typography variant="title" color="inherit" className={classes.flex}> <Typography variant="h6" color="inherit" className={classes.flex}>
Version en attente de modération Version en attente de modération
</Typography> </Typography>
</Toolbar> </Toolbar>
...@@ -119,6 +119,9 @@ PendingModeration.propTypes = { ...@@ -119,6 +119,9 @@ PendingModeration.propTypes = {
classes: PropTypes.object.isRequired, classes: PropTypes.object.isRequired,
factory: PropTypes.object.isRequired, factory: PropTypes.object.isRequired,
handleEditPendingModeration: PropTypes.func.isRequired, handleEditPendingModeration: PropTypes.func.isRequired,
handleClosePendingModeration: PropTypes.func.isRequired,
handleApproveModeration: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
userCanModerate: PropTypes.bool.isRequired, userCanModerate: PropTypes.bool.isRequired,
}; };
......
...@@ -52,7 +52,7 @@ class Scholarship extends React.Component { ...@@ -52,7 +52,7 @@ class Scholarship extends React.Component {
getSymbol() { getSymbol() {
const { currencies, currency } = this.props; const { currencies, currency } = this.props;
const currencyInfo = currencies[currency]; const currencyInfo = currencies.find(c => c.id == currency);
const { symbol } = currencyInfo; const { symbol } = currencyInfo;
if (symbol) { if (symbol) {
...@@ -64,7 +64,7 @@ class Scholarship extends React.Component { ...@@ -64,7 +64,7 @@ class Scholarship extends React.Component {
convertAmountToEur(amount) { convertAmountToEur(amount) {
const { currencies, currency } = this.props; const { currencies, currency } = this.props;
const rate = currencies[currency].one_EUR_in_this_currency; const rate = currencies.find(c => c.id == currency).one_EUR_in_this_currency;
return Math.trunc(amount / rate); return Math.trunc(amount / rate);
} }
...@@ -91,7 +91,7 @@ class Scholarship extends React.Component { ...@@ -91,7 +91,7 @@ class Scholarship extends React.Component {
return ( return (
<div> <div>
<Typography className={classes.item} variant='headline'> Avantage financier : </Typography> <Typography className={classes.item} variant='h5'> Avantage financier : </Typography>
{ {
amountMin !== null ? ( amountMin !== null ? (
<div> <div>
...@@ -116,7 +116,7 @@ class Scholarship extends React.Component { ...@@ -116,7 +116,7 @@ class Scholarship extends React.Component {
return ( return (
<div> <div>
<Typography className={classes.item} variant='headline' > Autre(s) avantage(s) : </Typography> <Typography className={classes.item} variant='h5' > Autre(s) avantage(s) : </Typography>
{ {
otherAdvantages != "" && otherAdvantages !== null ? otherAdvantages != "" && otherAdvantages !== null ?
<Markdown source={otherAdvantages} /> <Markdown source={otherAdvantages} />
...@@ -132,11 +132,11 @@ class Scholarship extends React.Component { ...@@ -132,11 +132,11 @@ class Scholarship extends React.Component {
return ( return (
<div> <div>
<Typography className={classes.item} variant='headline'>{type}</Typography> <Typography className={classes.item} variant='h5'>{type}</Typography>
{this.renderFinancialAdvantage()} {this.renderFinancialAdvantage()}
<div style={{ height: 2 * theme.spacing.unit }} /> <div style={{ height: 2 * theme.spacing.unit }} />
{this.renderOtherAdvantages()} {this.renderOtherAdvantages()}
<Typography className={classes.item} variant='headline'> Informations complémentaires : </Typography> <Typography className={classes.item} variant='h5'> Informations complémentaires : </Typography>
<Markdown source={comment} /> <Markdown source={comment} />
</div> </div>
); );
...@@ -153,6 +153,7 @@ Scholarship.propTypes = { ...@@ -153,6 +153,7 @@ Scholarship.propTypes = {
otherAdvantages: PropTypes.string, otherAdvantages: PropTypes.string,
amountMin: PropTypes.string, amountMin: PropTypes.string,
amountMax: PropTypes.string, amountMax: PropTypes.string,
currencies: PropTypes.array.isRequired,
}; };
export default withStyles(styles, { withTheme: true })(Scholarship); export default withStyles(styles, { withTheme: true })(Scholarship);
...@@ -12,11 +12,9 @@ import getActions from "../../../api/getActions"; ...@@ -12,11 +12,9 @@ import getActions from "../../../api/getActions";
class UnivInfoProvider extends CustomComponentForAPI { class UnivInfoProvider extends CustomComponentForAPI {
customRender() { customRender() {
const { city, country } = this.getUnivCityAndCountry(this.props.univId);
const universities = this.getReadData("universities");
const countries = this.getReadData("countries");
const currencies = this.getReadData("currencies");
const { univId } = this.props, const { univId } = this.props,
{ city, country } = this.getUnivCityAndCountry(univId),
{ universities, countries, currencies } = this.getReadDataFor(["universities", "countries", "currencies"]),
countryId = country.id, countryId = country.id,
cityId = city.id; cityId = city.id;
......
import React from "react"; import React from "react";
import DatePicker from "material-ui-pickers/DatePicker";
import DateFnsUtils from "material-ui-pickers/utils/date-fns-utils";
import MuiPickersUtilsProvider from "material-ui-pickers/utils/MuiPickersUtilsProvider";
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import compose from "recompose/compose"; import compose from "recompose/compose";
import withStyles from "@material-ui/core/styles/withStyles"; import withStyles from "@material-ui/core/styles/withStyles";
import { DatePicker, MuiPickersUtilsProvider } from "material-ui-pickers";
import DateFnsUtils from "@date-io/date-fns";
import frLocale from "date-fns/locale/fr"; import frLocale from "date-fns/locale/fr";
import format from "date-fns/format"; import format from "date-fns/format";
...@@ -21,9 +21,15 @@ const styles = theme => ({ ...@@ -21,9 +21,15 @@ const styles = theme => ({
}); });
/**
* Class to customize the header of the date selection box
*
* @class LocalizedUtils
* @extends {DateFnsUtils}
*/
class LocalizedUtils extends DateFnsUtils { class LocalizedUtils extends DateFnsUtils {
getDatePickerHeaderText(date) { getDatePickerHeaderText(date) {
return format(date, "d MMM YYYY", { locale: this.locale }); return format(date, "d MMM yyyy", { locale: this.locale });
} }
} }
...@@ -58,7 +64,7 @@ class DateField extends Field { ...@@ -58,7 +64,7 @@ class DateField extends Field {
<MuiPickersUtilsProvider utils={LocalizedUtils} locale={frLocale}> <MuiPickersUtilsProvider utils={LocalizedUtils} locale={frLocale}>
<DatePicker <DatePicker
clearable clearable
format="d MMM YYYY" format="d MMM yyyy"
value={this.state.value} value={this.state.value}
onChange={this.handleDateChange} onChange={this.handleDateChange}
clearLabel="vider" clearLabel="vider"
......
...@@ -58,7 +58,8 @@ Field.propTypes = { ...@@ -58,7 +58,8 @@ Field.propTypes = {
required: PropTypes.bool.isRequired, required: PropTypes.bool.isRequired,
label: PropTypes.string, label: PropTypes.string,
formManager: PropTypes.object.isRequired, formManager: PropTypes.object.isRequired,
fieldMapping: PropTypes.string.isRequired fieldMapping: PropTypes.string.isRequired,
value: PropTypes.isRequired
}; };
export default Field; export default Field;
...@@ -18,15 +18,15 @@ export default function renderTitle(rawModelData, classes, buildTitle) { ...@@ -18,15 +18,15 @@ export default function renderTitle(rawModelData, classes, buildTitle) {
return ( return (
<div className={classes.titleContainer}> <div className={classes.titleContainer}>
<NotificationImportantIcon className={c} /> <NotificationImportantIcon className={c} />
<Typography variant='display1'>{title}</Typography> <Typography variant='h4'>{title}</Typography>
</div> </div>
); );
} else { } else {
return ( return (
<Typography variant='display1'>{title}</Typography> <Typography variant='h4'>{title}</Typography>
); );
} }
} else { } else {
return (<div></div>); return (<div></div>);
} }
} }
\ No newline at end of file
...@@ -9,11 +9,11 @@ import ThemeProvider from "./components/ThemeProvider"; ...@@ -9,11 +9,11 @@ import ThemeProvider from "./components/ThemeProvider";
const MainReactEntry = () => ( const MainReactEntry = () => (
<Provider store={store}> <Provider store={store}>
<React.StrictMode> {/* <React.StrictMode> */}
<ThemeProvider> <ThemeProvider>
<Route path="/:filter?" component={App} /> <Route path="/:filter?" component={App} />
</ThemeProvider> </ThemeProvider>
</React.StrictMode> {/* </React.StrictMode> */}
</Provider> </Provider>
); );
......
...@@ -12,7 +12,7 @@ export function saveSelectedUniversities(state = [], action) { ...@@ -12,7 +12,7 @@ export function saveSelectedUniversities(state = [], action) {
} }
} }
export function saveFilterConfig(state = { contriesFilter: { selectedItems: [], inputValue: "" } }, action) { export function saveFilterConfig(state = { countriesFilter: { selectedItems: [], inputValue: "" } }, action) {
switch (action.type) { switch (action.type) {
case SAVE_FILTER_CONFIG: case SAVE_FILTER_CONFIG:
return Object.assign({}, state, action.config); return Object.assign({}, state, action.config);
......
...@@ -12,7 +12,7 @@ export function saveSelectedUniversities(state = [], action) { ...@@ -12,7 +12,7 @@ export function saveSelectedUniversities(state = [], action) {
} }
} }
export function saveFilterConfig(state = { contriesFilter: { selectedItems: [], inputValue: "" } }, action) { export function saveFilterConfig(state = { countriesFilter: { selectedItems: [], inputValue: "" } }, action) {
switch (action.type) { switch (action.type) {