Unverified Commit d088a3ea authored by Florent Chehab's avatar Florent Chehab
Browse files

fix(front): adapted to deps breaking changes

parent 4f85ee06
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
import { ThemeProvider as MuiThemeProvider } from "@material-ui/core/styles";
import PropTypes from "prop-types";
import React from "react";
import defaultTheme from "../../../config/defaultTheme";
......@@ -16,5 +16,5 @@ export default function OfflineThemeProvider(props) {
}
OfflineThemeProvider.propTypes = {
children: PropTypes.node.isRequired
children: PropTypes.node.isRequired,
};
import React, { useEffect } from "react";
import PropTypes from "prop-types";
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
import { ThemeProvider as MuiThemeProvider } from "@material-ui/core/styles";
import { getTheme, updatePhoneStatusBarColor } from "./utils";
import RequestParams from "../../../utils/api/RequestParams";
import { CURRENT_USER_ID } from "../../../config/user";
import withNetworkWrapper, {
NetWrapParam
NetWrapParam,
} from "../../../hoc/withNetworkWrapper";
/**
......@@ -26,13 +26,13 @@ function ThemeProvider({ children, userData }) {
ThemeProvider.propTypes = {
children: PropTypes.node.isRequired,
userData: PropTypes.shape({
theme: PropTypes.object.isRequired
}).isRequired
theme: PropTypes.object.isRequired,
}).isRequired,
};
export default withNetworkWrapper([
new NetWrapParam("userData", "one", {
addDataToProp: "userData",
params: RequestParams.Builder.withId(CURRENT_USER_ID).build()
})
params: RequestParams.Builder.withId(CURRENT_USER_ID).build(),
}),
])(ThemeProvider);
......@@ -4,7 +4,7 @@ import ExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary";
import ExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import Typography from "@material-ui/core/Typography";
import uuid from "uuid/v4";
import { v4 as uuidv4 } from "uuid";
import { makeStyles } from "@material-ui/styles";
import { Checkbox } from "@material-ui/core";
import FormControl from "@material-ui/core/FormControl";
......@@ -15,29 +15,29 @@ import FilterService from "../../services/FilterService";
import FilterStatus from "./FilterStatus";
import { useSetSelectedUniversities } from "../../hooks/wrappers/useSelectedUniversities";
const useStyles = makeStyles(theme => ({
const useStyles = makeStyles((theme) => ({
root: {
width: "100%"
width: "100%",
},
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightMedium
fontWeight: theme.typography.fontWeightMedium,
},
input: {
marginTop: theme.spacing(1),
marginBottom: theme.spacing(0.5)
marginBottom: theme.spacing(0.5),
},
spacer1: {
marginTop: theme.spacing(1)
marginTop: theme.spacing(1),
},
spacer2: {
marginTop: theme.spacing(2)
}
marginTop: theme.spacing(2),
},
}));
const DOWNSHIFT_COUNTRIES_ID = uuid();
const DOWNSHIFT_SEMESTERS_ID = uuid();
const DOWNSHIFT_MAJORS_ID = uuid();
const DOWNSHIFT_COUNTRIES_ID = uuidv4();
const DOWNSHIFT_SEMESTERS_ID = uuidv4();
const DOWNSHIFT_MAJORS_ID = uuidv4();
const MINIMUM_NUMBER_OPEN_DESTINATIONS = 100;
/**
......@@ -76,7 +76,7 @@ function Filter() {
);
const hasSelection =
[countries, semesters, majorMinors].some(arr => arr.length !== 0) ||
[countries, semesters, majorMinors].some((arr) => arr.length !== 0) ||
onlyOpenDestinations === true;
saveSelectedUniversities(hasSelection ? selectedUniversities : null);
}, [countries, semesters, majorMinors, onlyOpenDestinations]);
......@@ -84,7 +84,7 @@ function Filter() {
const {
countriesOptions,
majorMinorOptions,
semesterOptions
semesterOptions,
} = FilterService;
return (
......
import React, { useMemo } from "react";
import uuid from "uuid/v4";
import { v4 as uuidv4 } from "uuid";
import BaseMap from "./BaseMap";
import "./map.scss";
......@@ -8,7 +8,7 @@ import UniversityService from "../../services/data/UniversityService";
import CountryService from "../../services/data/CountryService";
import { useSelectedUniversities } from "../../hooks/wrappers/useSelectedUniversities";
const MAIN_MAP_ID = uuid();
const MAIN_MAP_ID = uuidv4();
/**
* Main map of the application (map tab)
......@@ -20,7 +20,7 @@ function MainMap() {
const out = [];
const universities = UniversityService.getUniversities();
universities.forEach(univ => {
universities.forEach((univ) => {
if (univ) {
out.push({
univName: univ.name,
......@@ -32,7 +32,7 @@ function MainMap() {
univId: univ.id,
selected:
listUnivSel === null ||
(listUnivSel.length > 0 && listUnivSel.indexOf(univ.id) > -1)
(listUnivSel.length > 0 && listUnivSel.indexOf(univ.id) > -1),
});
}
});
......
......@@ -19,7 +19,7 @@ import DeleteIcon from "@material-ui/icons/DeleteForever";
import StartIcon from "@material-ui/icons/StarBorder";
import CheckIcon from "@material-ui/icons/CheckCircle";
import ShareIcon from "@material-ui/icons/Share";
import uuid from "uuid/v4";
import { v4 as uuidv4 } from "uuid";
import { withStyles } from "@material-ui/styles";
import isEqual from "lodash/isEqual";
import cloneDeep from "lodash/cloneDeep";
......@@ -39,7 +39,7 @@ import {
useApiDelete,
useApiInvalidateAll,
useApiInvalidateOne,
useApiUpdate
useApiUpdate,
} from "../../../hooks/wrappers/api";
const FORGET_SAVE_MESSAGE = "Des changements n'ont pas été enregistré !";
......@@ -98,7 +98,7 @@ ImperativeBtn.propTypes = {
disabled: PropTypes.bool.isRequired,
type: PropTypes.oneOf(["up", "down"]).isRequired,
onClick: PropTypes.func.isRequired,
subscribe: PropTypes.func.isRequired
subscribe: PropTypes.func.isRequired,
};
/**
......@@ -109,7 +109,7 @@ ImperativeBtn.propTypes = {
* Nasty direct DOM manipulations and directe state update to reduce the need to rerender.
*/
class View extends React.Component {
baseId = uuid();
baseId = uuidv4();
idMaker = new IdMaker();
......@@ -130,11 +130,11 @@ class View extends React.Component {
title: props.list.title,
description: props.list.description,
// clone deep to prevent nasty modifications propagation
content: cloneDeep(props.list.content).map(obj => ({
content: cloneDeep(props.list.content).map((obj) => ({
obj,
key: this.idMaker.next
key: this.idMaker.next,
})),
savingSuccess: false
savingSuccess: false,
};
}
......@@ -220,7 +220,7 @@ class View extends React.Component {
const key = this.idMaker.next;
copy.splice(idx, 0, {
obj,
key
key,
});
return { content: copy };
......@@ -237,8 +237,8 @@ class View extends React.Component {
type: "univ-block",
content: {
university: null,
appreciation: null
}
appreciation: null,
},
},
insertIndex
);
......@@ -246,7 +246,7 @@ class View extends React.Component {
this.insertAtIndex(
{
type: "text-block",
content: ""
content: "",
},
insertIndex
);
......@@ -282,7 +282,7 @@ class View extends React.Component {
removeAtIndex(idx) {
this.setState(({ content }) => ({
content: content.slice().splice(idx, 1)
content: content.slice().splice(idx, 1),
}));
}
......@@ -338,7 +338,10 @@ class View extends React.Component {
if (isPublic !== list.is_public) {
return true;
}
return !isEqual(content.map(({ obj }) => obj), list.content);
return !isEqual(
content.map(({ obj }) => obj),
list.content
);
}
// eslint-disable-next-line consistent-return
......@@ -375,8 +378,8 @@ class View extends React.Component {
maxLength={99}
text={title}
placeHolder="Saisissez l'intitulé de la liste."
render={titleEl => <Typography variant="h2">{titleEl}</Typography>}
onChange={newTitle => this.updateTitle(newTitle)}
render={(titleEl) => <Typography variant="h2">{titleEl}</Typography>}
onChange={(newTitle) => this.updateTitle(newTitle)}
readOnly={!isOwner}
/>
......@@ -385,8 +388,8 @@ class View extends React.Component {
text={description}
placeHolder="Saisissez la description de la liste."
maxLength={299}
render={descr => <Typography variant="h5">{descr}</Typography>}
onChange={newDescription => this.updateDescription(newDescription)}
render={(descr) => <Typography variant="h5">{descr}</Typography>}
onChange={(newDescription) => this.updateDescription(newDescription)}
readOnly={!isOwner}
/>
......@@ -405,7 +408,7 @@ class View extends React.Component {
control={
<Switch
checked={isPublic}
onChange={event => {
onChange={(event) => {
this.setState({ isPublic: event.target.checked });
}}
color="primary"
......@@ -460,7 +463,7 @@ class View extends React.Component {
>
<CopyToClipboard
message="Le lien de la liste a été copié 😁"
render={copy => (
render={(copy) => (
<Button
variant="outlined"
color="primary"
......@@ -488,7 +491,7 @@ class View extends React.Component {
disabled={this.cannotMoveUp(this.selectedIdx)}
type="up"
onClick={() => this.moveUp()}
subscribe={func => {
subscribe={(func) => {
this.setDisabledMoveUp = func;
}}
/>
......@@ -496,7 +499,7 @@ class View extends React.Component {
disabled={this.cannotMoveDown(this.selectedIdx)}
type="down"
onClick={() => this.moveDown()}
subscribe={func => {
subscribe={(func) => {
this.setDisabledMoveDown = func;
}}
/>
......@@ -506,8 +509,8 @@ class View extends React.Component {
{
disabled: false,
label: "Confirmer",
onClick: () => this.deleteBlock()
}
onClick: () => this.deleteBlock(),
},
]}
renderHolder={({ onClick }) => (
<IconButton
......@@ -525,13 +528,13 @@ class View extends React.Component {
{
label: "Markdown",
onClick: () => this.addBlock("text-block"),
disabled: false
disabled: false,
},
{
label: "Université",
onClick: () => this.addBlock("univ-block"),
disabled: false
}
disabled: false,
},
]}
renderHolder={({ onClick }) => (
<Button
......@@ -598,7 +601,7 @@ class View extends React.Component {
readOnly={!isOwner}
university={obj.content.university}
appreciation={obj.content.appreciation}
onChange={newItem =>
onChange={(newItem) =>
this.handleSilentUpdateBlock("univ-block", key, newItem)
}
/>
......@@ -606,7 +609,7 @@ class View extends React.Component {
<TextBlock
readOnly={!isOwner}
text={obj.content}
onChange={value =>
onChange={(value) =>
this.handleSilentUpdateBlock("text-block", key, value)
}
/>
......@@ -626,20 +629,20 @@ View.propTypes = {
followList: PropTypes.func.isRequired,
invalidateListsSummary: PropTypes.func.isRequired,
invalidateList: PropTypes.func.isRequired,
unFollowList: PropTypes.func.isRequired
unFollowList: PropTypes.func.isRequired,
};
View.defaultProps = {};
const styles = theme => ({
const styles = (theme) => ({
item: {
borderLeftWidth: theme.spacing(0.7),
borderLeftStyle: "solid",
borderLeftColor: "transparent",
paddingLeft: theme.spacing(1)
paddingLeft: theme.spacing(1),
},
selected: {
borderLeftColor: `${theme.palette.secondary.light}!important`
borderLeftColor: `${theme.palette.secondary.light}!important`,
},
topBlock: {
backgroundColor: theme.palette.background.paper,
......@@ -647,23 +650,23 @@ const styles = theme => ({
position: "sticky",
top: appBarHeight(theme) - 1,
paddingTop: theme.spacing(2),
zIndex: 1000
}
zIndex: 1000,
},
},
editToolsBlock: {},
leftIcon: {
marginRight: theme.spacing(0.5)
marginRight: theme.spacing(0.5),
},
divider: {
marginTop: theme.spacing(1),
marginBottom: theme.spacing(1)
marginBottom: theme.spacing(1),
},
editSpacer: {
height: theme.spacing(1)
height: theme.spacing(1),
},
bigButton: {
margin: theme.spacing(1)
}
margin: theme.spacing(1),
},
});
const StyledView = withStyles(styles)(View);
......
......@@ -10,7 +10,7 @@ import Button from "@material-ui/core/Button";
import { rgbToHex } from "@material-ui/core/styles/colorManipulator";
import FormControlLabel from "@material-ui/core/FormControlLabel";
import Switch from "@material-ui/core/Switch";
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
import { ThemeProvider as MuiThemeProvider } from "@material-ui/core/styles";
import { compose } from "recompose";
import Input from "@material-ui/core/Input";
import ExpansionPanel from "@material-ui/core/ExpansionPanel";
......@@ -29,12 +29,12 @@ import { getTheme } from "../../common/theme/utils";
import { CURRENT_USER_ID } from "../../../config/user";
import LicenseNotice from "../../common/LicenseNotice";
import withNetworkWrapper, {
NetWrapParam
NetWrapParam,
} from "../../../hoc/withNetworkWrapper";
import { useApiUpdate } from "../../../hooks/wrappers/api";
const isRgb = string => /#?([0-9a-f]{6})/i.test(string);
const isRgb = (string) => /#?([0-9a-f]{6})/i.test(string);
/**
* Component to handle website color customization
......@@ -67,7 +67,7 @@ class ColorTool extends React.Component {
"light-primary-input": theme.light.primary,
"light-secondary-input": theme.light.secondary,
"dark-primary-input": theme.dark.primary,
"dark-secondary-input": theme.dark.secondary
"dark-secondary-input": theme.dark.secondary,
};
}
......@@ -77,7 +77,7 @@ class ColorTool extends React.Component {
handleChangeNightMode() {
const oldTheme = deepCopy(this.state.theme);
const newTheme = Object.assign(oldTheme, {
mode: oldTheme.mode === "light" ? "dark" : "light"
mode: oldTheme.mode === "light" ? "dark" : "light",
});
this.updateStateTheme(newTheme);
}
......@@ -87,16 +87,16 @@ class ColorTool extends React.Component {
* @param intent
* @returns {Function}
*/
handleChangeColor = intent => event => {
handleChangeColor = (intent) => (event) => {
// Lazy to provide a cleaner fix
// eslint-disable-next-line react/no-access-state-in-setstate
const oldTheme = this.state.theme;
const {
target: { value: color }
target: { value: color },
} = event;
this.setState({
[`${oldTheme.mode}-${intent}-input`]: color
[`${oldTheme.mode}-${intent}-input`]: color,
});
if (isRgb(color)) {
......@@ -159,7 +159,7 @@ class ColorTool extends React.Component {
return (
<Grid container className={classes.colorBar}>
{["dark", "main", "light"].map(key => (
{["dark", "main", "light"].map((key) => (
<div
className={classes.colorSquare}
style={{ backgroundColor: background[key] }}
......@@ -197,7 +197,7 @@ class ColorTool extends React.Component {
<Input
id={intent}
value={inputValue}
onChange={e => this.handleChangeColor(intent)(e)}
onChange={(e) => this.handleChangeColor(intent)(e)}
type="color"
fullWidth
/>
......@@ -307,34 +307,34 @@ ColorTool.propTypes = {
classes: PropTypes.object.isRequired,
theme: PropTypes.object.isRequired,
saveUserDataToServer: PropTypes.func.isRequired,
userData: PropTypes.object.isRequired
userData: PropTypes.object.isRequired,
};
const styles = theme => ({
const styles = (theme) => ({
colorBar: {
marginTop: theme.spacing(2)
marginTop: theme.spacing(2),
},
colorSquare: {
width: 64,
height: 64,
display: "flex",
justifyContent: "center",
alignItems: "center"
alignItems: "center",
},
centered: {
margin: "0 auto"
margin: "0 auto",
},
divider: {
margin: theme.spacing(3)
}
margin: theme.spacing(3),
},
});
const ConnectedComp = compose(
withNetworkWrapper([
new NetWrapParam("userData", "one", {
addDataToProp: "userData",
params: RequestParams.Builder.withId(CURRENT_USER_ID).build()
})
params: RequestParams.Builder.withId(CURRENT_USER_ID).build(),
}),
]),
withStyles(styles, { withTheme: true })
)(ColorTool);
......@@ -342,7 +342,7 @@ const ConnectedComp = compose(
export default () => {
const saveUserDataToServerInt = useApiUpdate("userData");
const saveUserDataToServer = useCallback(
data => saveUserDataToServerInt(CURRENT_USER_ID, data),
(data) => saveUserDataToServerInt(CURRENT_USER_ID, data),
[]
);
......
......@@ -11,26 +11,26 @@ import Button from "@material-ui/core/Button";
import Checkbox from "@material-ui/core/Checkbox";
import Typography from "@material-ui/core/Typography";
import { makeStyles } from "@material-ui/styles";
import uuid from "uuid/v4";
import { v4 as uuidv4 } from "uuid";
import PreviousExchange from "../modules/previousExchangeFeedback/PreviousExchange";
import PaginatedData from "../../common/PaginatedData";
import RequestParams from "../../../utils/api/RequestParams";
import withUnivInfo from "../../../hoc/withUnivInfo";
import withNetworkWrapper, {
NetWrapParam
NetWrapParam,
} from "../../../hoc/withNetworkWrapper";
const undefinedVal = uuid();
const undefinedVal = uuidv4();
const useStyles = makeStyles(theme => ({
const useStyles = makeStyles((theme) => ({
root: {
display: "flex",
flexWrap: "wrap"
flexWrap: "wrap",
},
formControl: {
margin: theme.spacing(1),
minWidth: 150
}
minWidth: 150,
},
}));
/**
......@@ -47,14 +47,14 @@ function PreviousExchangesTab({
showUntouched,
setShowUntouched,
hasFilters,
resetFilters
resetFilters,
}) {
const classes = useStyles();
const displayMinorSelect = major !== undefinedVal;
let minors;
if (displayMinorSelect)
minors = univMajorMinors.find(el => el.major === major).minors;
minors = univMajorMinors.find((el) => el.major === major).minors;
return (
<>
......@@ -63,15 +63,15 @@ function PreviousExchangesTab({
<InputLabel htmlFor="major-select">Branche</InputLabel>
<Select
value={major}
onChange={e => setMajor(e.target.value)}
onChange={(e) => setMajor(e.target.value)}
inputProps={{
id: "major-select"
id: "major-select",
}}
>
<MenuItem value={undefinedVal}>Pas de filtre</MenuItem>
{univMajorMinors
.filter(el => el.major !== null)
.map(el => (
.filter((el) => el.major !== null)
.map((el) => (
<MenuItem key={el.major} value={el.major}>
{el.major}
</MenuItem>
......@@ -85,15 +85,15 @@ function PreviousExchangesTab({