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 !48
parents 909dae0d 827fa5b8
......@@ -42,6 +42,7 @@ function TabContainer(props) {
TabContainer.propTypes = {
children: PropTypes.node.isRequired,
visible: PropTypes.bool.isRequired
};
const styles = theme => ({
......@@ -81,7 +82,7 @@ class UniversityTemplate extends React.Component {
<Tabs
value={value}
onChange={this.handleChange}
scrollable={scroll}
variant={scroll ? "scrollable" : "standard"}
centered={!scroll}
scrollButtons="on"
indicatorColor="primary"
......@@ -110,6 +111,7 @@ class UniversityTemplate extends React.Component {
UniversityTemplate.propTypes = {
classes: PropTypes.object.isRequired,
width: PropTypes.string.isRequired,
};
export default compose(
......
......@@ -96,7 +96,7 @@ CountryDri.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
countryId: PropTypes.string.isRequired,
countries: PropTypes.object.isRequired,
countries: PropTypes.array.isRequired,
};
const mapStateToProps = (state) => {
......
......@@ -116,8 +116,8 @@ CountryScholarships.propTypes = {
theme: PropTypes.object.isRequired,
countryId: PropTypes.string.isRequired,
country: PropTypes.object.isRequired,
countries: PropTypes.object.isRequired,
currencies: PropTypes.object.isRequired,
countries: PropTypes.array.isRequired,
currencies: PropTypes.array.isRequired,
};
const mapStateToProps = (state) => {
......
......@@ -99,7 +99,7 @@ UniversityDri.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
univId: PropTypes.string.isRequired,
universities: PropTypes.object.isRequired,
universities: PropTypes.array.isRequired,
};
const mapStateToProps = (state) => {
......
......@@ -42,11 +42,11 @@ function renderCore(rawModelData, classes, outsideData) {
</Grid>
<Grid item xs>
<Typography variant='headline'>{name}</Typography>
<Typography variant='title'>{acronym}</Typography>
<Typography variant='h5'>{name}</Typography>
<Typography variant='h6'>{acronym}</Typography>
<Divider />
<Typography variant='subheading'>{city}, {country}</Typography>
<Typography variant='body1'> Site internet&nbsp;:{" "}
<Typography variant='subtitle1'>{city}, {country}</Typography>
<Typography variant='body2'> Site internet&nbsp;:{" "}
{
website != "" ?
<TextLink href={website}>{website}</TextLink>
......
......@@ -113,8 +113,8 @@ UniversityScholarships.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
univId: PropTypes.string.isRequired,
universities: PropTypes.object.isRequired,
currencies: PropTypes.object.isRequired,
universities: PropTypes.array.isRequired,
currencies: PropTypes.array.isRequired,
};
const mapStateToProps = (state) => {
......
......@@ -99,6 +99,7 @@ Alert.propTypes = {
handleClose: PropTypes.func.isRequired,
handleResponse: PropTypes.func.isRequired,
multilineButtons: PropTypes.bool.isRequired,
classes: PropTypes.object.isRequired
};
......
......@@ -255,7 +255,7 @@ class Editor extends CustomComponentForAPI {
<IconButton color="inherit" onClick={() => this.handleCloseEditorRequest()} aria-label="Close">
<CloseIcon />
</IconButton>
<Typography variant="title" color="inherit" className={classes.flex}>
<Typography variant="h6" color="inherit" className={classes.flex}>
Mode édition
</Typography>
<Button color="inherit" onClick={() => this.handleSaveEditor()}>
......
......@@ -7,7 +7,7 @@ import { connect } from "react-redux";
import Typography from "@material-ui/core/Typography";
import Paper from "@material-ui/core/Paper";
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 Divider from "@material-ui/core/Divider";
......@@ -74,15 +74,14 @@ class GenericGroupModule extends CustomComponentForAPI {
<Grid container spacing={8} alignItems='center'>
<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 item xs={2} style={{ textAlign: "right" }}>
<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! */}
<Button
variant='fab'
mini
<Fab
size='small'
aria-label="Ajouter un élément"
disabled={disabled}
style={disabled ? {} : { backgroundColor: green.A700 }}
......@@ -90,7 +89,7 @@ class GenericGroupModule extends CustomComponentForAPI {
onClick={this.handleOpenEditor}
>
<AddIcon />
</Button>
</Fab>
</div>
</Tooltip>
</Grid>
......
......@@ -66,7 +66,7 @@ const styles = theme => ({
},
titleIcon: {
paddingRight: theme.spacing.unit,
fontSize: theme.typography.display1.fontSize
fontSize: theme.typography.h4.fontSize
}
});
......
......@@ -68,6 +68,7 @@ class History extends React.Component {
}
getContentTypeAndId() {
// eslint-disable-next-line react/prop-types
const { rawModelData } = this.props.factory.props;
const { content_type_id, id } = rawModelData;
return { content_type_id, id };
......@@ -109,7 +110,7 @@ class History extends React.Component {
return (
<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='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
variant='outlined'
color="primary"
......@@ -181,7 +182,7 @@ class History extends React.Component {
<IconButton color="inherit" onClick={() => { this.props.handleCloseHistory(); this.props.resetVersions(); }} aria-label="Close">
<CloseIcon />
</IconButton>
<Typography variant="title" color="inherit" className={classes.flex}>
<Typography variant="h6" color="inherit" className={classes.flex}>
Parcours de l'historique
</Typography>
</Toolbar>
......@@ -199,6 +200,11 @@ History.propTypes = {
classes: PropTypes.object.isRequired,
factory: PropTypes.object.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 = {
......
......@@ -101,7 +101,7 @@ class PendingModeration extends React.Component {
<IconButton color="inherit" onClick={() => { this.props.handleClosePendingModeration(); }} aria-label="Close">
<CloseIcon />
</IconButton>
<Typography variant="title" color="inherit" className={classes.flex}>
<Typography variant="h6" color="inherit" className={classes.flex}>
Version en attente de modération
</Typography>
</Toolbar>
......@@ -119,6 +119,9 @@ PendingModeration.propTypes = {
classes: PropTypes.object.isRequired,
factory: PropTypes.object.isRequired,
handleEditPendingModeration: PropTypes.func.isRequired,
handleClosePendingModeration: PropTypes.func.isRequired,
handleApproveModeration: PropTypes.func.isRequired,
open: PropTypes.bool.isRequired,
userCanModerate: PropTypes.bool.isRequired,
};
......
......@@ -52,7 +52,7 @@ class Scholarship extends React.Component {
getSymbol() {
const { currencies, currency } = this.props;
const currencyInfo = currencies[currency];
const currencyInfo = currencies.find(c => c.id == currency);
const { symbol } = currencyInfo;
if (symbol) {
......@@ -64,7 +64,7 @@ class Scholarship extends React.Component {
convertAmountToEur(amount) {
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);
}
......@@ -91,7 +91,7 @@ class Scholarship extends React.Component {
return (
<div>
<Typography className={classes.item} variant='headline'> Avantage financier : </Typography>
<Typography className={classes.item} variant='h5'> Avantage financier : </Typography>
{
amountMin !== null ? (
<div>
......@@ -116,7 +116,7 @@ class Scholarship extends React.Component {
return (
<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 ?
<Markdown source={otherAdvantages} />
......@@ -132,11 +132,11 @@ class Scholarship extends React.Component {
return (
<div>
<Typography className={classes.item} variant='headline'>{type}</Typography>
<Typography className={classes.item} variant='h5'>{type}</Typography>
{this.renderFinancialAdvantage()}
<div style={{ height: 2 * theme.spacing.unit }} />
{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} />
</div>
);
......@@ -153,6 +153,7 @@ Scholarship.propTypes = {
otherAdvantages: PropTypes.string,
amountMin: PropTypes.string,
amountMax: PropTypes.string,
currencies: PropTypes.array.isRequired,
};
export default withStyles(styles, { withTheme: true })(Scholarship);
......@@ -12,11 +12,9 @@ import getActions from "../../../api/getActions";
class UnivInfoProvider extends CustomComponentForAPI {
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,
{ city, country } = this.getUnivCityAndCountry(univId),
{ universities, countries, currencies } = this.getReadDataFor(["universities", "countries", "currencies"]),
countryId = country.id,
cityId = city.id;
......
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 compose from "recompose/compose";
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 format from "date-fns/format";
......@@ -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 {
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 {
<MuiPickersUtilsProvider utils={LocalizedUtils} locale={frLocale}>
<DatePicker
clearable
format="d MMM YYYY"
format="d MMM yyyy"
value={this.state.value}
onChange={this.handleDateChange}
clearLabel="vider"
......
......@@ -58,7 +58,8 @@ Field.propTypes = {
required: PropTypes.bool.isRequired,
label: PropTypes.string,
formManager: PropTypes.object.isRequired,
fieldMapping: PropTypes.string.isRequired
fieldMapping: PropTypes.string.isRequired,
value: PropTypes.isRequired
};
export default Field;
......@@ -18,15 +18,15 @@ export default function renderTitle(rawModelData, classes, buildTitle) {
return (
<div className={classes.titleContainer}>
<NotificationImportantIcon className={c} />
<Typography variant='display1'>{title}</Typography>
<Typography variant='h4'>{title}</Typography>
</div>
);
} else {
return (
<Typography variant='display1'>{title}</Typography>
<Typography variant='h4'>{title}</Typography>
);
}
} else {
return (<div></div>);
}
}
\ No newline at end of file
}
......@@ -9,11 +9,11 @@ import ThemeProvider from "./components/ThemeProvider";
const MainReactEntry = () => (
<Provider store={store}>
<React.StrictMode>
<ThemeProvider>
<Route path="/:filter?" component={App} />
</ThemeProvider>
</React.StrictMode>
{/* <React.StrictMode> */}
<ThemeProvider>
<Route path="/:filter?" component={App} />
</ThemeProvider>
{/* </React.StrictMode> */}
</Provider>
);
......
......@@ -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) {
case SAVE_FILTER_CONFIG:
return Object.assign({}, state, action.config);
......
......@@ -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) {
case SAVE_FILTER_CONFIG:
return Object.assign({}, state, action.config);
......
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