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 PropTypes from "prop-types";
import React from "react"; import React from "react";
import defaultTheme from "../../../config/defaultTheme"; import defaultTheme from "../../../config/defaultTheme";
...@@ -16,5 +16,5 @@ export default function OfflineThemeProvider(props) { ...@@ -16,5 +16,5 @@ export default function OfflineThemeProvider(props) {
} }
OfflineThemeProvider.propTypes = { OfflineThemeProvider.propTypes = {
children: PropTypes.node.isRequired children: PropTypes.node.isRequired,
}; };
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import PropTypes from "prop-types"; 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 { getTheme, updatePhoneStatusBarColor } from "./utils";
import RequestParams from "../../../utils/api/RequestParams"; import RequestParams from "../../../utils/api/RequestParams";
import { CURRENT_USER_ID } from "../../../config/user"; import { CURRENT_USER_ID } from "../../../config/user";
import withNetworkWrapper, { import withNetworkWrapper, {
NetWrapParam NetWrapParam,
} from "../../../hoc/withNetworkWrapper"; } from "../../../hoc/withNetworkWrapper";
/** /**
...@@ -26,13 +26,13 @@ function ThemeProvider({ children, userData }) { ...@@ -26,13 +26,13 @@ function ThemeProvider({ children, userData }) {
ThemeProvider.propTypes = { ThemeProvider.propTypes = {
children: PropTypes.node.isRequired, children: PropTypes.node.isRequired,
userData: PropTypes.shape({ userData: PropTypes.shape({
theme: PropTypes.object.isRequired theme: PropTypes.object.isRequired,
}).isRequired }).isRequired,
}; };
export default withNetworkWrapper([ export default withNetworkWrapper([
new NetWrapParam("userData", "one", { new NetWrapParam("userData", "one", {
addDataToProp: "userData", addDataToProp: "userData",
params: RequestParams.Builder.withId(CURRENT_USER_ID).build() params: RequestParams.Builder.withId(CURRENT_USER_ID).build(),
}) }),
])(ThemeProvider); ])(ThemeProvider);
...@@ -4,7 +4,7 @@ import ExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary"; ...@@ -4,7 +4,7 @@ import ExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary";
import ExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails"; import ExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore"; import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import Typography from "@material-ui/core/Typography"; 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 { makeStyles } from "@material-ui/styles";
import { Checkbox } from "@material-ui/core"; import { Checkbox } from "@material-ui/core";
import FormControl from "@material-ui/core/FormControl"; import FormControl from "@material-ui/core/FormControl";
...@@ -15,29 +15,29 @@ import FilterService from "../../services/FilterService"; ...@@ -15,29 +15,29 @@ import FilterService from "../../services/FilterService";
import FilterStatus from "./FilterStatus"; import FilterStatus from "./FilterStatus";
import { useSetSelectedUniversities } from "../../hooks/wrappers/useSelectedUniversities"; import { useSetSelectedUniversities } from "../../hooks/wrappers/useSelectedUniversities";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles((theme) => ({
root: { root: {
width: "100%" width: "100%",
}, },
heading: { heading: {
fontSize: theme.typography.pxToRem(15), fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightMedium fontWeight: theme.typography.fontWeightMedium,
}, },
input: { input: {
marginTop: theme.spacing(1), marginTop: theme.spacing(1),
marginBottom: theme.spacing(0.5) marginBottom: theme.spacing(0.5),
}, },
spacer1: { spacer1: {
marginTop: theme.spacing(1) marginTop: theme.spacing(1),
}, },
spacer2: { spacer2: {
marginTop: theme.spacing(2) marginTop: theme.spacing(2),
} },
})); }));
const DOWNSHIFT_COUNTRIES_ID = uuid(); const DOWNSHIFT_COUNTRIES_ID = uuidv4();
const DOWNSHIFT_SEMESTERS_ID = uuid(); const DOWNSHIFT_SEMESTERS_ID = uuidv4();
const DOWNSHIFT_MAJORS_ID = uuid(); const DOWNSHIFT_MAJORS_ID = uuidv4();
const MINIMUM_NUMBER_OPEN_DESTINATIONS = 100; const MINIMUM_NUMBER_OPEN_DESTINATIONS = 100;
/** /**
...@@ -76,7 +76,7 @@ function Filter() { ...@@ -76,7 +76,7 @@ function Filter() {
); );
const hasSelection = const hasSelection =
[countries, semesters, majorMinors].some(arr => arr.length !== 0) || [countries, semesters, majorMinors].some((arr) => arr.length !== 0) ||
onlyOpenDestinations === true; onlyOpenDestinations === true;
saveSelectedUniversities(hasSelection ? selectedUniversities : null); saveSelectedUniversities(hasSelection ? selectedUniversities : null);
}, [countries, semesters, majorMinors, onlyOpenDestinations]); }, [countries, semesters, majorMinors, onlyOpenDestinations]);
...@@ -84,7 +84,7 @@ function Filter() { ...@@ -84,7 +84,7 @@ function Filter() {
const { const {
countriesOptions, countriesOptions,
majorMinorOptions, majorMinorOptions,
semesterOptions semesterOptions,
} = FilterService; } = FilterService;
return ( return (
......
import React, { useMemo } from "react"; import React, { useMemo } from "react";
import uuid from "uuid/v4"; import { v4 as uuidv4 } from "uuid";
import BaseMap from "./BaseMap"; import BaseMap from "./BaseMap";
import "./map.scss"; import "./map.scss";
...@@ -8,7 +8,7 @@ import UniversityService from "../../services/data/UniversityService"; ...@@ -8,7 +8,7 @@ import UniversityService from "../../services/data/UniversityService";
import CountryService from "../../services/data/CountryService"; import CountryService from "../../services/data/CountryService";
import { useSelectedUniversities } from "../../hooks/wrappers/useSelectedUniversities"; import { useSelectedUniversities } from "../../hooks/wrappers/useSelectedUniversities";
const MAIN_MAP_ID = uuid(); const MAIN_MAP_ID = uuidv4();
/** /**
* Main map of the application (map tab) * Main map of the application (map tab)
...@@ -20,7 +20,7 @@ function MainMap() { ...@@ -20,7 +20,7 @@ function MainMap() {
const out = []; const out = [];
const universities = UniversityService.getUniversities(); const universities = UniversityService.getUniversities();
universities.forEach(univ => { universities.forEach((univ) => {
if (univ) { if (univ) {
out.push({ out.push({
univName: univ.name, univName: univ.name,
...@@ -32,7 +32,7 @@ function MainMap() { ...@@ -32,7 +32,7 @@ function MainMap() {
univId: univ.id, univId: univ.id,
selected: selected:
listUnivSel === null || 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"; ...@@ -19,7 +19,7 @@ import DeleteIcon from "@material-ui/icons/DeleteForever";
import StartIcon from "@material-ui/icons/StarBorder"; import StartIcon from "@material-ui/icons/StarBorder";
import CheckIcon from "@material-ui/icons/CheckCircle"; import CheckIcon from "@material-ui/icons/CheckCircle";
import ShareIcon from "@material-ui/icons/Share"; 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 { withStyles } from "@material-ui/styles";
import isEqual from "lodash/isEqual"; import isEqual from "lodash/isEqual";
import cloneDeep from "lodash/cloneDeep"; import cloneDeep from "lodash/cloneDeep";
...@@ -39,7 +39,7 @@ import { ...@@ -39,7 +39,7 @@ import {
useApiDelete, useApiDelete,
useApiInvalidateAll, useApiInvalidateAll,
useApiInvalidateOne, useApiInvalidateOne,
useApiUpdate useApiUpdate,
} from "../../../hooks/wrappers/api"; } from "../../../hooks/wrappers/api";
const FORGET_SAVE_MESSAGE = "Des changements n'ont pas été enregistré !"; const FORGET_SAVE_MESSAGE = "Des changements n'ont pas été enregistré !";
...@@ -98,7 +98,7 @@ ImperativeBtn.propTypes = { ...@@ -98,7 +98,7 @@ ImperativeBtn.propTypes = {
disabled: PropTypes.bool.isRequired, disabled: PropTypes.bool.isRequired,
type: PropTypes.oneOf(["up", "down"]).isRequired, type: PropTypes.oneOf(["up", "down"]).isRequired,
onClick: PropTypes.func.isRequired, onClick: PropTypes.func.isRequired,
subscribe: PropTypes.func.isRequired subscribe: PropTypes.func.isRequired,
}; };
/** /**
...@@ -109,7 +109,7 @@ ImperativeBtn.propTypes = { ...@@ -109,7 +109,7 @@ ImperativeBtn.propTypes = {
* Nasty direct DOM manipulations and directe state update to reduce the need to rerender. * Nasty direct DOM manipulations and directe state update to reduce the need to rerender.
*/ */
class View extends React.Component { class View extends React.Component {
baseId = uuid(); baseId = uuidv4();
idMaker = new IdMaker(); idMaker = new IdMaker();
...@@ -130,11 +130,11 @@ class View extends React.Component { ...@@ -130,11 +130,11 @@ class View extends React.Component {
title: props.list.title, title: props.list.title,
description: props.list.description, description: props.list.description,
// clone deep to prevent nasty modifications propagation // clone deep to prevent nasty modifications propagation
content: cloneDeep(props.list.content).map(obj => ({ content: cloneDeep(props.list.content).map((obj) => ({
obj, obj,
key: this.idMaker.next key: this.idMaker.next,
})), })),
savingSuccess: false savingSuccess: false,
}; };
} }
...@@ -220,7 +220,7 @@ class View extends React.Component { ...@@ -220,7 +220,7 @@ class View extends React.Component {
const key = this.idMaker.next; const key = this.idMaker.next;
copy.splice(idx, 0, { copy.splice(idx, 0, {
obj, obj,
key key,
}); });
return { content: copy }; return { content: copy };
...@@ -237,8 +237,8 @@ class View extends React.Component { ...@@ -237,8 +237,8 @@ class View extends React.Component {
type: "univ-block", type: "univ-block",
content: { content: {
university: null, university: null,
appreciation: null appreciation: null,
} },
}, },
insertIndex insertIndex
); );
...@@ -246,7 +246,7 @@ class View extends React.Component { ...@@ -246,7 +246,7 @@ class View extends React.Component {
this.insertAtIndex( this.insertAtIndex(
{ {
type: "text-block", type: "text-block",
content: "" content: "",
}, },
insertIndex insertIndex
); );
...@@ -282,7 +282,7 @@ class View extends React.Component { ...@@ -282,7 +282,7 @@ class View extends React.Component {
removeAtIndex(idx) { removeAtIndex(idx) {
this.setState(({ content }) => ({ this.setState(({ content }) => ({
content: content.slice().splice(idx, 1) content: content.slice().splice(idx, 1),
})); }));
} }
...@@ -338,7 +338,10 @@ class View extends React.Component { ...@@ -338,7 +338,10 @@ class View extends React.Component {
if (isPublic !== list.is_public) { if (isPublic !== list.is_public) {
return true; return true;
} }
return !isEqual(content.map(({ obj }) => obj), list.content); return !isEqual(
content.map(({ obj }) => obj),
list.content
);
} }
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
...@@ -375,8 +378,8 @@ class View extends React.Component { ...@@ -375,8 +378,8 @@ class View extends React.Component {
maxLength={99} maxLength={99}
text={title} text={title}
placeHolder="Saisissez l'intitulé de la liste." placeHolder="Saisissez l'intitulé de la liste."
render={titleEl => <Typography variant="h2">{titleEl}</Typography>} render={(titleEl) => <Typography variant="h2">{titleEl}</Typography>}
onChange={newTitle => this.updateTitle(newTitle)} onChange={(newTitle) => this.updateTitle(newTitle)}
readOnly={!isOwner} readOnly={!isOwner}
/> />
...@@ -385,8 +388,8 @@ class View extends React.Component { ...@@ -385,8 +388,8 @@ class View extends React.Component {
text={description} text={description}
placeHolder="Saisissez la description de la liste." placeHolder="Saisissez la description de la liste."
maxLength={299} maxLength={299}
render={descr => <Typography variant="h5">{descr}</Typography>} render={(descr) => <Typography variant="h5">{descr}</Typography>}
onChange={newDescription => this.updateDescription(newDescription)} onChange={(newDescription) => this.updateDescription(newDescription)}
readOnly={!isOwner} readOnly={!isOwner}
/> />
...@@ -405,7 +408,7 @@ class View extends React.Component { ...@@ -405,7 +408,7 @@ class View extends React.Component {
control={ control={
<Switch <Switch
checked={isPublic} checked={isPublic}
onChange={event => { onChange={(event) => {
this.setState({ isPublic: event.target.checked }); this.setState({ isPublic: event.target.checked });
}} }}
color="primary" color="primary"
...@@ -460,7 +463,7 @@ class View extends React.Component { ...@@ -460,7 +463,7 @@ class View extends React.Component {
> >
<CopyToClipboard <CopyToClipboard
message="Le lien de la liste a été copié 😁" message="Le lien de la liste a été copié 😁"
render={copy => ( render={(copy) => (
<Button <Button
variant="outlined" variant="outlined"
color="primary" color="primary"
...@@ -488,7 +491,7 @@ class View extends React.Component { ...@@ -488,7 +491,7 @@ class View extends React.Component {
disabled={this.cannotMoveUp(this.selectedIdx)} disabled={this.cannotMoveUp(this.selectedIdx)}
type="up" type="up"
onClick={() => this.moveUp()} onClick={() => this.moveUp()}
subscribe={func => { subscribe={(func) => {
this.setDisabledMoveUp = func; this.setDisabledMoveUp = func;
}} }}
/> />
...@@ -496,7 +499,7 @@ class View extends React.Component { ...@@ -496,7 +499,7 @@ class View extends React.Component {
disabled={this.cannotMoveDown(this.selectedIdx)} disabled={this.cannotMoveDown(this.selectedIdx)}
type="down" type="down"
onClick={() => this.moveDown()} onClick={() => this.moveDown()}
subscribe={func => { subscribe={(func) => {
this.setDisabledMoveDown = func; this.setDisabledMoveDown = func;
}} }}
/> />
...@@ -506,8 +509,8 @@ class View extends React.Component { ...@@ -506,8 +509,8 @@ class View extends React.Component {
{ {
disabled: false, disabled: false,
label: "Confirmer", label: "Confirmer",
onClick: () => this.deleteBlock() onClick: () => this.deleteBlock(),
} },
]} ]}
renderHolder={({ onClick }) => ( renderHolder={({ onClick }) => (
<IconButton <IconButton
...@@ -525,13 +528,13 @@ class View extends React.Component { ...@@ -525,13 +528,13 @@ class View extends React.Component {
{ {
label: "Markdown", label: "Markdown",
onClick: () => this.addBlock("text-block"), onClick: () => this.addBlock("text-block"),
disabled: false disabled: false,
}, },
{ {
label: "Université", label: "Université",
onClick: () => this.addBlock("univ-block"), onClick: () => this.addBlock("univ-block"),
disabled: false disabled: false,
} },
]} ]}
renderHolder={({ onClick }) => ( renderHolder={({ onClick }) => (
<Button <Button
...@@ -598,7 +601,7 @@ class View extends React.Component { ...@@ -598,7 +601,7 @@ class View extends React.Component {
readOnly={!isOwner} readOnly={!isOwner}
university={obj.content.university} university={obj.content.university}
appreciation={obj.content.appreciation} appreciation={obj.content.appreciation}
onChange={newItem => onChange={(newItem) =>
this.handleSilentUpdateBlock("univ-block", key, newItem) this.handleSilentUpdateBlock("univ-block", key, newItem)
} }
/> />
...@@ -606,7 +609,7 @@ class View extends React.Component { ...@@ -606,7 +609,7 @@ class View extends React.Component {
<TextBlock <TextBlock
readOnly={!isOwner} readOnly={!isOwner}
text={obj.content} text={obj.content}
onChange={value => onChange={(value) =>
this.handleSilentUpdateBlock("text-block", key, value) this.handleSilentUpdateBlock("text-block", key, value)
} }
/> />
...@@ -626,20 +629,20 @@ View.propTypes = { ...@@ -626,20 +629,20 @@ View.propTypes = {
followList: PropTypes.func.isRequired, followList: PropTypes.func.isRequired,
invalidateListsSummary: PropTypes.func.isRequired, invalidateListsSummary: PropTypes.func.isRequired,
invalidateList: PropTypes.func.isRequired, invalidateList: PropTypes.func.isRequired,
unFollowList: PropTypes.func.isRequired unFollowList: PropTypes.func.isRequired,
}; };
View.defaultProps = {}; View.defaultProps = {};
const styles = theme => ({ const styles = (theme) => ({
item: { item: {
borderLeftWidth: theme.spacing(0.7), borderLeftWidth: theme.spacing(0.7),
borderLeftStyle: "solid", borderLeftStyle: "solid",
borderLeftColor: "transparent", borderLeftColor: "transparent",
paddingLeft: theme.spacing(1) paddingLeft: theme.spacing(1),
}, },
selected: { selected: {
borderLeftColor: `${theme.palette.secondary.light}!important` borderLeftColor: `${theme.palette.secondary.light}!important`,
}, },
topBlock: { topBlock: {
backgroundColor: theme.palette.background.paper, backgroundColor: theme.palette.background.paper,
...@@ -647,23 +650,23 @@ const styles = theme => ({ ...@@ -647,23 +650,23 @@ const styles = theme => ({
position: "sticky", position: "sticky",
top: appBarHeight(theme) - 1, top: appBarHeight(theme) - 1,
paddingTop: theme.spacing(2), paddingTop: theme.spacing(2),
zIndex: 1000 zIndex: 1000,
} },
}, },
editToolsBlock: {}, editToolsBlock: {},
leftIcon: { leftIcon: {
marginRight: theme.spacing(0.5) marginRight: theme.spacing(0.5),
}, },
divider: { divider: {
marginTop: theme.spacing(1), marginTop: theme.spacing(1),
marginBottom: theme.spacing(1) marginBottom: theme.spacing(1),
}, },
editSpacer: { editSpacer: {
height: theme.spacing(1) height: theme.spacing(1),
}, },
bigButton: { bigButton: {
margin: theme.spacing(1) margin: theme.spacing(1),
} },
}); });
const StyledView = withStyles(styles)(View); const StyledView = withStyles(styles)(View);
......
...@@ -10,7 +10,7 @@ import Button from "@material-ui/core/Button"; ...@@ -10,7 +10,7 @@ import Button from "@material-ui/core/Button";
import { rgbToHex } from "@material-ui/core/styles/colorManipulator"; import { rgbToHex } from "@material-ui/core/styles/colorManipulator";
import FormControlLabel from "@material-ui/core/FormControlLabel"; import FormControlLabel from "@material-ui/core/FormControlLabel";
import Switch from "@material-ui/core/Switch"; 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";