diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3700bc8b5015dfa44490b98b03c5584c47452dde..ca95d6018216ab736fdfda33cb44958bea9375f6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,9 +36,9 @@ check_back: check_front: <<: *only-default stage: check - image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v1.2.0 + image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.0.0 before_script: - - cd frontend && cp -R /usr/src/deps/node_modules . + - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/ script: - yarn build artifacts: @@ -78,9 +78,9 @@ test_back: test_frontend: <<: *only-default stage: test - image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v1.2.0 + image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.0.0 before_script: - - cd frontend && cp -R /usr/src/deps/node_modules . + - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/ script: - yarn test tags: @@ -98,9 +98,9 @@ flake8: eslint: <<: *only-default stage: lint - image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v1.2.0 + image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.0.0 before_script: - - cd frontend && cp -R /usr/src/deps/node_modules . + - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/ script: - yarn lint tags: diff --git a/CHANGELOG.md b/CHANGELOG.md index 023001897dcd68f022a5e4b83a2793b7643ee722..7f200e0c5b48386f21c3f801e00de8444dcf1616 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,27 @@ ###### _TBD_ +- [next] blabla + +## v2.5.0 + +###### _17 May 2020_ + - [feat] add filter to show only currently available destinations +- [feat] filter of available destinations is activated by default if there are enough open destinations +- [feat] front: updated docker image & deps => v2.0.0 +- [feat] ci: a bit more performant +- [style] new prettier on all the repo :tada: +- [style] eslint: cleaned code after eslint update - [fix] clarified cgu / rgpd -- [refacto] filter of available destinations is activated by default if there are enough open destinations +- [fix] front: corrected warnings +- [fix] front: remove CoverGallery +- [fix] front: align form in previousDepartureTab +- [fix] front: cleaned chip / avatar after deps update +- [fix] front: Cleaned Logo +- [fix] front deps: clean after removal of postcss +- [fix] main template: invalid HTML, script outside body +- [fix] Makefile: --renew-anon-volumes for docker-compose ## v2.3.0 diff --git a/Makefile b/Makefile index d7053a8e783afde0bc15d46ccceb3f84ecba245a..786721b589759e05b204f727a53a823644d8efa1 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ clear_setup: rm server/envs/django.env up: setup - docker-compose up --build + docker-compose up --build --renew-anon-volumes dev: up @@ -68,7 +68,7 @@ prod: setup $(info In production, we need to reset the webpack-stats.json file to make sure the front is up-to-date) sudo rm -f frontend/webpack-stats.json # Need higher compose timeout as the big map container can take a lot of time to wake up - COMPOSE_HTTP_TIMEOUT=600 docker-compose $(prod_yml) up --build -d + COMPOSE_HTTP_TIMEOUT=600 docker-compose $(prod_yml) up --build -d --renew-anon-volumes down_prod: docker-compose $(prod_yml) down diff --git a/backend/backend_app/load_data/assets/tags.json b/backend/backend_app/load_data/assets/tags.json index 128a72a9d20a80f30093e9480506b6eaf3f866d7..83825d89a52dbfc512ff782f115895299366d3ff 100644 --- a/backend/backend_app/load_data/assets/tags.json +++ b/backend/backend_app/load_data/assets/tags.json @@ -11,4 +11,4 @@ "tourism", "shared_comment", "specific_partnership" -] \ No newline at end of file +] diff --git a/backend/backend_app/validation/json_schemas/definitions.json b/backend/backend_app/validation/json_schemas/definitions.json index a0de507613595abd51d3f8c8cccda44061efa889..2d425c4087fc0c20174631561239ae2bd9a13300 100644 --- a/backend/backend_app/validation/json_schemas/definitions.json +++ b/backend/backend_app/validation/json_schemas/definitions.json @@ -21,10 +21,7 @@ "maxLength": 500 } }, - "required": [ - "url", - "description" - ], + "required": ["url", "description"], "additionalProperties": false } }, @@ -54,10 +51,7 @@ "maxLength": 500 } }, - "required": [ - "url", - "title" - ], + "required": ["url", "title"], "additionalProperties": false } }, @@ -71,10 +65,7 @@ "$ref": "definitions.json#/definitions/hex-color" } }, - "required": [ - "primary", - "secondary" - ], + "required": ["primary", "secondary"], "additionalProperties": false }, "hex-color": { diff --git a/backend/backend_app/validation/json_schemas/recommendation_list_content.json b/backend/backend_app/validation/json_schemas/recommendation_list_content.json index 297565649707e4f80c62fe0de4eba89a79728076..2758019752c1a53c81bd2f845797f7c8f456e1be 100644 --- a/backend/backend_app/validation/json_schemas/recommendation_list_content.json +++ b/backend/backend_app/validation/json_schemas/recommendation_list_content.json @@ -10,10 +10,7 @@ { "type": "object", "additionalProperties": false, - "required": [ - "type", - "content" - ], + "required": ["type", "content"], "properties": { "type": { "const": "univ-block" @@ -21,23 +18,14 @@ "content": { "type": "object", "additionalProperties": false, - "required": [ - "university", - "appreciation" - ], + "required": ["university", "appreciation"], "properties": { "university": { - "type": [ - "integer", - "null" - ], + "type": ["integer", "null"], "description": "pk of the university" }, "appreciation": { - "type": [ - "integer", - "null" - ], + "type": ["integer", "null"], "minimum": 0, "maximum": 10 } @@ -48,10 +36,7 @@ { "type": "object", "additionalProperties": false, - "required": [ - "type", - "content" - ], + "required": ["type", "content"], "properties": { "type": { "const": "text-block" diff --git a/backend/backend_app/validation/json_schemas/theme.json b/backend/backend_app/validation/json_schemas/theme.json index 2c04f43b24c7e0ab4ac55c446930f6999254a327..5ad9fd7df51729202c7f0d92b3194e5ca3109c97 100644 --- a/backend/backend_app/validation/json_schemas/theme.json +++ b/backend/backend_app/validation/json_schemas/theme.json @@ -7,10 +7,7 @@ "mode": { "description": "What is the selected mode of the theme", "type": "string", - "enum": [ - "light", - "dark" - ] + "enum": ["light", "dark"] }, "light": { "description": "Settings in light mode", @@ -21,10 +18,6 @@ "$ref": "definitions.json#/definitions/palette" } }, - "required": [ - "mode", - "light", - "dark" - ], + "required": ["mode", "light", "dark"], "additionalProperties": false } diff --git a/backend/base_app/templates/banned.html b/backend/base_app/templates/banned.html index ddda6331cb9be0e4f4423dbf49f6d95c879299f7..838d928f81af792f42c9e9c1eff2ef4ac43465e8 100644 --- a/backend/base_app/templates/banned.html +++ b/backend/base_app/templates/banned.html @@ -1,10 +1,10 @@ - - + + Vous êtes banni du site - - + + Vous êtes banni du site, veuillez contacter le SIMDE. - + diff --git a/backend/base_app/templates/base.html b/backend/base_app/templates/base.html index aa44879ca4cd436c5ced93221f681d5dd31a5c19..85fe107025a6eded90bfb095eab85417801ac316 100644 --- a/backend/base_app/templates/base.html +++ b/backend/base_app/templates/base.html @@ -1,7 +1,6 @@ {% load static %} - - + - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + REX-DRI @@ -33,9 +89,12 @@
- - {% block content %}{% endblock %} + {% block content %}{% endblock %} - + + diff --git a/docker-compose.yml b/docker-compose.yml index 11502923d7e20b501e0729bbc6d3008781397fb6..7979b54174dcc87411055a64681e1e91ab22b411 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -68,11 +68,11 @@ services: # Service to handle frontend live developpments and building frontend: # Get the image from the registry - image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v1.2.0 + image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.0.0 # To use a locally built one, comment above, uncomment bellow. # build: ./frontend # On startup, we retrieve the dependencies from the image and start the developpement server - command: /bin/sh -c "cd frontend && cp -R /usr/src/deps/node_modules . && yarn dev" + command: /bin/sh -c "cd frontend && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/ && yarn dev" volumes: # "Copy" the repo to the workdir. - .:/usr/src/app/ diff --git a/documentation/Application/Frontend/interacting_with_backend.md b/documentation/Application/Frontend/interacting_with_backend.md index 515d8701e552296faf3dce3c0ca7a4b3c4dcd4f7..0784795d42e995f1ae0ee36e2e543a63b1917e30 100644 --- a/documentation/Application/Frontend/interacting_with_backend.md +++ b/documentation/Application/Frontend/interacting_with_backend.md @@ -74,8 +74,8 @@ import withNetworkWrapper, { NetWrapParam } from ".../withNetworkWrapper"; 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); ``` @@ -93,7 +93,7 @@ You will see that those parameters can also depend on your component `props`. ```js import withNetworkWrapper, { NetWrapParam } from ".../withNetworkWrapper"; -const buildParams = univId => +const buildParams = (univId) => RequestParams.Builder.withQueryParam("university", univId).build(); export default compose( @@ -101,11 +101,11 @@ export default compose( withNetworkWrapper([ new NetWrapParam("sharedUnivFeedbacks", "all", { addDataToProp: "feedback", - params: props => buildParams(props.univId), + params: (props) => buildParams(props.univId), propTypes: { - univId: PropTypes.number.isRequired - } - }) + univId: PropTypes.number.isRequired, + }, + }), ]) )(SharedUnivFeedback); ``` diff --git a/documentation/index.html b/documentation/index.html index 0999a08b6a7c25b3499e5f530b3fed70cde3c616..28c090e9defaa6dfe31b7b5c8e50e89e55313b1f 100644 --- a/documentation/index.html +++ b/documentation/index.html @@ -19,13 +19,13 @@ name: "Rex-DRI", search: { placeholder: "Search for...", - noData: "No result :(" + noData: "No result :(", // paths: ['/Application', '/GettingStarted', "Technologies", "/Other"] }, alias: { "/": "/GettingStarted/introduction.md", - "/.*/_sidebar.md": "/_sidebar.md" - } + "/.*/_sidebar.md": "/_sidebar.md", + }, }; diff --git a/frontend/.babelrc b/frontend/.babelrc index b9cbf10e4d5080c68b870fef8f63a8abcafa9bfd..69159baf97ed233d2a51eb50f6108f1fcebe15c0 100644 --- a/frontend/.babelrc +++ b/frontend/.babelrc @@ -1,10 +1,7 @@ { - "presets": [ - "@babel/preset-env", - "@babel/preset-react" - ], - "plugins": [ - "react-hot-loader/babel", - "@babel/plugin-proposal-class-properties" - ] + "presets": ["@babel/preset-env", "@babel/preset-react"], + "plugins": [ + "react-hot-loader/babel", + "@babel/plugin-proposal-class-properties" + ] } diff --git a/frontend/.dockerignore b/frontend/.dockerignore new file mode 100644 index 0000000000000000000000000000000000000000..7cd53fdbc084dfe30bf105e6d282ef8a24831c7f --- /dev/null +++ b/frontend/.dockerignore @@ -0,0 +1 @@ +**/node_modules/ diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 90abf6a6fd2003f1491aeab9474872ae1460b0bb..e7c80239cf55fc625106c4cca6e4dc24524e8468 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -2,20 +2,20 @@ module.exports = { env: { browser: true, es6: true, - "jest/globals": true + "jest/globals": true, }, extends: ["airbnb", "prettier"], globals: { Atomics: "readonly", - SharedArrayBuffer: "readonly" + SharedArrayBuffer: "readonly", }, parser: "babel-eslint", parserOptions: { ecmaFeatures: { - jsx: true + jsx: true, }, ecmaVersion: 2018, - sourceType: "module" + sourceType: "module", }, plugins: ["react", "jest", "import"], rules: { @@ -23,8 +23,8 @@ module.exports = { "warn", { terms: ["todo", "fixme"], - location: "anywhere" - } + location: "anywhere", + }, ], "no-console": "error", // Styling choices bellow... @@ -44,6 +44,6 @@ module.exports = { "one-var": "off", camelcase: "off", // hard to do with python convention "max-classes-per-file": "off", - "max-len": "off" - } + "max-len": "off", + }, }; diff --git a/frontend/.postcssrc.json b/frontend/.postcssrc.json deleted file mode 100644 index 42b1f92edcd9a8cdf3b8cbdc9c417fb62abd5945..0000000000000000000000000000000000000000 --- a/frontend/.postcssrc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "plugins": { - "autoprefixer": { - "browsers": ["last 2 versions"] - } - } -} diff --git a/frontend/Dockerfile b/frontend/Dockerfile index 157905b442a636b8debd9ba60c7b8069061b3d02..7512085163230d22fbef809945da073a69ddd679 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -1,13 +1,12 @@ # pull official base image of node -FROM node:10.15.1-alpine +FROM node:12-alpine ENV NODE_ENV = "DEV" # we cache de dependencies in one location, so that we can reuse them easily WORKDIR /usr/src/deps -COPY ./package.json ./package.json -COPY ./yarn.lock ./yarn.lock -RUN yarn install --network-timeout 1000000 +COPY ./package.json ./yarn.lock ./ +RUN yarn install --network-timeout 1000000 && yarn cache clean # And prepare a clean workdir for the project WORKDIR /usr/src/app diff --git a/frontend/package.json b/frontend/package.json index a2ffbff26fa110e381ed89ff7bcf66ab68f51845..1223a3eb19c0bdab3bf3ac07c063d72c2eed5987 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -19,33 +19,33 @@ "author": "", "license": "BSD-2-Clause", "private": true, - "browserslist": [ - "defaults" - ], "husky": { "hooks": { "pre-commit": "pretty-quick --staged" } }, + "browserslist": [ + "defaults" + ], "dependencies": { - "@date-io/date-fns": "^1.3.9", - "@material-ui/core": "^4.4.0", + "@date-io/date-fns": "^2.6.1", + "@material-ui/core": "^4.9.14", "@material-ui/icons": "^4.2.1", - "@material-ui/lab": "^4.0.0-alpha.13", + "@material-ui/lab": "^4.0.0-alpha.53", "@material-ui/pickers": "^3.2.4", - "@material-ui/styles": "^4.3.3", + "@material-ui/styles": "^4.9.14", "axios": "^0.19.0", "core-js": "^3.2.1", "date-fns": "^2.0.1", - "downshift": "^3.2.12", + "downshift": "^5.3.0", "fuzzysort": "^1.1.4", "keycode": "^2.2.0", "lodash": "^4.17.15", "mapbox-gl": "^1.3.0", - "notistack": "^0.8.9", + "notistack": "^0.9.13", "prop-types": "^15.7.2", "react": "^16.9.0", - "react-awesome-slider": "^1.0.1", + "react-awesome-slider": "^4.1.0", "react-dom": "^16.9.0", "react-mapbox-gl": "^4.6.0", "react-markdown": "^4.1.0", @@ -53,7 +53,7 @@ "recompose": "^0.30.0", "regenerator-runtime": "^0.13.3", "typeface-roboto": "0.0.75", - "uuid": "^3.3.3" + "uuid": "^8.0.0" }, "devDependencies": { "@babel/core": "^7.5.5", @@ -62,36 +62,35 @@ "@babel/preset-react": "^7.0.0", "autoprefixer": "^9.6.1", "babel-eslint": "^10.0.3", - "babel-jest": "^24.9.0", + "babel-jest": "^26.0.1", "babel-loader": "^8.0.6", "copy-webpack-plugin": "^5.0.4", "css-loader": "^3.2.0", - "eslint": "^6.3.0", + "eslint": "^7.0.0", "eslint-config-airbnb": "^18.0.1", "eslint-config-prettier": "^6.1.0", "eslint-import-resolver-node": "^0.3.2", "eslint-plugin-import": "^2.18.2", - "eslint-plugin-jest": "^22.16.0", + "eslint-plugin-jest": "^23.11.0", "eslint-plugin-jsx-a11y": "^6.2.3", - "eslint-plugin-react": "^7.14.3", - "eslint-plugin-react-hooks": "^1.7.0", - "file-loader": "^4.2.0", - "husky": "^3.0.5", - "jest": "^24.9.0", + "eslint-plugin-react": "^7.20.0", + "eslint-plugin-react-hooks": "^4.0.2", + "file-loader": "^6.0.0", + "husky": "^4.2.5", + "jest": "^26.0.1", "js-yaml-loader": "^1.2.2", - "mini-css-extract-plugin": "^0.8.0", + "mini-css-extract-plugin": "^0.9.0", "node-sass": "^4.12.0", - "postcss-loader": "^3.0.0", - "prettier": "1.18.2", - "pretty-quick": "^1.11.1", - "raw-loader": "^3.1.0", + "prettier": "2.0.5", + "pretty-quick": "^2.0.1", + "raw-loader": "^4.0.1", "react-hot-loader": "^4.12.12", "react-lorem-component": "^0.13.0", "react-script": "^2.0.5", "sass-loader": "^8.0.0", "webpack": "^4.39.3", "webpack-bundle-analyzer": "^3.4.1", - "webpack-bundle-tracker": "^0.4.2-beta", + "webpack-bundle-tracker": "0.4.3", "webpack-cli": "^3.3.7", "webpack-dev-server": "^3.8.0", "webpack-merge": "^4.2.2" diff --git a/frontend/server.js b/frontend/server.js index d47e04df98cec1f87b0c8207f659c91922c0850b..fbb8b71aa3db73358c3cdf383240d1e3f436725d 100644 --- a/frontend/server.js +++ b/frontend/server.js @@ -17,14 +17,13 @@ var webpack = require("webpack"); var WebpackDevServer = require("webpack-dev-server"); var config = require("./webpack.config.dev"); - new WebpackDevServer(webpack(config), { publicPath: config.output.publicPath, hot: true, inline: true, //progress: true, historyApiFallback: true, - headers: { "Access-Control-Allow-Origin": "*" } + headers: { "Access-Control-Allow-Origin": "*" }, }).listen(3000, "0.0.0.0", (err) => { if (err) { // eslint-disable-next-line no-console diff --git a/frontend/src/components/app/App.jsx b/frontend/src/components/app/App.jsx index ebab9ad959bdc31ca24872424b9ad26f77818493..92006b5328559f5135f15a1e39538e11b633a6e5 100644 --- a/frontend/src/components/app/App.jsx +++ b/frontend/src/components/app/App.jsx @@ -36,7 +36,7 @@ const SERVICES_TO_INITIALIZE = [ CountryService, CurrencyService, LanguageService, - FilterService + FilterService, ]; /** @@ -44,7 +44,7 @@ const SERVICES_TO_INITIALIZE = [ */ function App() { useOnBeforeComponentMount(() => { - SERVICES_TO_INITIALIZE.forEach(service => service.initialize()); + SERVICES_TO_INITIALIZE.forEach((service) => service.initialize()); }); return ( @@ -53,7 +53,7 @@ function App() { display: "flex", flexDirection: "column", justifyItems: "flex-end", - minHeight: "100vh" + minHeight: "100vh", }} > @@ -103,7 +103,7 @@ export default compose( new NetWrapParam("universities", "all"), new NetWrapParam("currencies", "all"), new NetWrapParam("languages", "all"), - new NetWrapParam("serverModerationStatus", "all") // not needed for server moderation status + new NetWrapParam("serverModerationStatus", "all"), // not needed for server moderation status ]), withErrorBoundary() )(App); diff --git a/frontend/src/components/app/BaseTemplate.jsx b/frontend/src/components/app/BaseTemplate.jsx index 12babb28d61ee99dc0bc7dc6be915700e35e7cd1..9b6cb010b576cf4bf8f48bc1e0fe7e05a51fe2ae 100644 --- a/frontend/src/components/app/BaseTemplate.jsx +++ b/frontend/src/components/app/BaseTemplate.jsx @@ -6,28 +6,28 @@ import { makeStyles } from "@material-ui/styles"; import classNames from "../../utils/classNames"; import { appBarHeight, siteMaxWidth } from "../../config/sharedStyles"; -const useStyle = makeStyles(theme => ({ +const useStyle = makeStyles((theme) => ({ root: { - flexGrow: 1 + flexGrow: 1, }, appBar: { width: "100%", - height: appBarHeight(theme) + height: appBarHeight(theme), }, toolBar: { width: "100%", maxWidth: siteMaxWidth(), - display: "flex" + display: "flex", }, content: { - maxWidth: siteMaxWidth() + maxWidth: siteMaxWidth(), }, centered: { - margin: "0 auto" + margin: "0 auto", }, middleBlock: { - flex: 1 - } + flex: 1, + }, })); export default function BaseTemplate({ inBetween, toolbarContent, children }) { @@ -52,9 +52,9 @@ export default function BaseTemplate({ inBetween, toolbarContent, children }) { BaseTemplate.propTypes = { toolbarContent: PropTypes.node.isRequired, children: PropTypes.node.isRequired, - inBetween: PropTypes.node + inBetween: PropTypes.node, }; BaseTemplate.defaultProps = { - inBetween: <> + inBetween: <>, }; diff --git a/frontend/src/components/app/DrawerMenu.jsx b/frontend/src/components/app/DrawerMenu.jsx index 9d5ae2d91b6616f01cd076e5746638395dfeb341..455efa1f5f909c4922c14661a0d1ce0b691d4d2a 100644 --- a/frontend/src/components/app/DrawerMenu.jsx +++ b/frontend/src/components/app/DrawerMenu.jsx @@ -14,7 +14,7 @@ import { mainMenuHome, mainMenuItems, secondaryMenuItems, - settingsMenuItems + settingsMenuItems, } from "./menuItems"; const ListItemHeading = ({ label, Icon }) => ( @@ -28,7 +28,7 @@ const ListItemHeading = ({ label, Icon }) => ( ListItemHeading.propTypes = { label: PropTypes.node.isRequired, - Icon: PropTypes.object.isRequired + Icon: PropTypes.object.isRequired, }; const ListItemsTmp = ({ items, onClick, inset }) => ( @@ -52,15 +52,17 @@ const ListItemsTmp = ({ items, onClick, inset }) => ( ListItemsTmp.propTypes = { items: PropTypes.array.isRequired, onClick: PropTypes.func.isRequired, - inset: PropTypes.bool + inset: PropTypes.bool, }; ListItemsTmp.defaultProps = { - inset: false + inset: false, }; function DrawerMenu({ open, closeDrawer }) { - const ListItems = props => ; + const ListItems = (props) => ( + + ); return (
@@ -95,7 +97,7 @@ function DrawerMenu({ open, closeDrawer }) { DrawerMenu.propTypes = { open: PropTypes.bool.isRequired, - closeDrawer: PropTypes.func.isRequired + closeDrawer: PropTypes.func.isRequired, }; export default React.memo(DrawerMenu); diff --git a/frontend/src/components/app/ExternalDataUpdateInfo.jsx b/frontend/src/components/app/ExternalDataUpdateInfo.jsx index 12b0de49bab1d5124899c7c2cfd09114e30f6bd7..3faa98242e6b187c5d3a007b7afcfff4bdb19a1e 100644 --- a/frontend/src/components/app/ExternalDataUpdateInfo.jsx +++ b/frontend/src/components/app/ExternalDataUpdateInfo.jsx @@ -23,7 +23,7 @@ function ExternalDataUpdateInfo({ updates }) { if (updates.length > 0) { return ( - {updates.map(el => ( + {updates.map((el) => ( ({ +const useStyles = makeStyles((theme) => ({ divider: { marginTop: theme.spacing(4), marginBottom: theme.spacing(0), paddingBottom: theme.spacing(2), - color: theme.palette.text.secondary - } + color: theme.palette.text.secondary, + }, })); function FooterImportantInformation({ location }) { @@ -33,8 +33,8 @@ function FooterImportantInformation({ location }) { FooterImportantInformation.propTypes = { location: PropTypes.shape({ - pathname: PropTypes.string.isRequired - }).isRequired + pathname: PropTypes.string.isRequired, + }).isRequired, }; export default withRouter(FooterImportantInformation); diff --git a/frontend/src/components/app/InformationList.jsx b/frontend/src/components/app/InformationList.jsx index 72902018ae61e6343d258e64b28c9e2198e89c24..f55178eedab220a9c9b4f92d647e7cc09abb5572 100644 --- a/frontend/src/components/app/InformationList.jsx +++ b/frontend/src/components/app/InformationList.jsx @@ -18,7 +18,7 @@ const INFORMATION_ICONS = { success: , info: , error: , - warning: + warning: , }; /** @@ -33,7 +33,7 @@ function InformationList({ includeVariants, informationList }) { return ( - {informationListFiltered.map(el => ( + {informationListFiltered.map((el) => ( {INFORMATION_ICONS[el.variant]} @@ -45,19 +45,19 @@ function InformationList({ includeVariants, informationList }) { InformationList.propTypes = { includeVariants: PropTypes.arrayOf(PropTypes.string.isRequired), - informationList: PropTypes.array.isRequired + informationList: PropTypes.array.isRequired, }; InformationList.defaultProps = { - includeVariants: ["warning", "error", "info", "success"] + includeVariants: ["warning", "error", "info", "success"], }; export default compose( withNetworkWrapper([ new NetWrapParam("information", "all", { addDataToProp: "informationList", - params: RequestParams.Builder.withQueryParam("now", "true").build() - }) + params: RequestParams.Builder.withQueryParam("now", "true").build(), + }), ]), withErrorBoundary() )(InformationList); diff --git a/frontend/src/components/app/Logo.jsx b/frontend/src/components/app/Logo.jsx index 5eff8321b2459cfdf4541e82e978c9fb85cc5274..9784822f18f7248fa0edafbffa27b6fcee51b003 100644 --- a/frontend/src/components/app/Logo.jsx +++ b/frontend/src/components/app/Logo.jsx @@ -1,6 +1,3 @@ -import Chip from "@material-ui/core/Chip"; -import Avatar from "@material-ui/core/Avatar"; -import Typography from "@material-ui/core/Typography"; import React from "react"; import { makeStyles } from "@material-ui/styles"; @@ -8,42 +5,49 @@ import PropTypes from "prop-types"; import CustomNavLink from "../common/CustomNavLink"; import classNames from "../../utils/classNames"; -const useStyle = makeStyles(theme => ({ - siteName: { - fontWeight: 900 - }, +const useStyle = makeStyles((theme) => ({ logoContainer: { position: "relative", - width: "fit-content" + width: "fit-content", }, - iconChip: { - backgroundColor: "transparent", + centered: { + margin: "0 auto", + }, + innerLogoContainer: { + display: "flex", + alignItems: "center", borderRadius: 0, - paddingLeft: 1, - paddingRight: 1, + paddingLeft: 8, + paddingRight: 8, + flexWrap: "nowrap", "&:hover": { - cursor: "pointer" - } + cursor: "pointer", + }, }, - centered: { - margin: "0 auto" + siteName: { + fontWeight: 900, + fontSize: "1.75rem", + whiteSpace: "nowrap", + color: theme.palette.getContrastText(theme.palette.primary.main), + }, + icon: { + position: "relative", + width: "3.6em", + height: "3.6em", + overflow: "initial", + backgroundColor: "transparent", + right: "0.2em", + bottom: "-0.1em", }, logoUnderline: { position: "absolute", left: 0, - bottom: 2, + bottom: 14, height: 9, backgroundColor: theme.palette.secondary.main, width: "100%", - zIndex: -1 + zIndex: -1, }, - iconAvatar: { - width: "2.5em", - height: "2.5em", - overflow: "initial", - backgroundColor: "transparent", - right: -4 - } })); function Core() { @@ -51,23 +55,15 @@ function Core() { return ( <> - - } - label={ - - REX-DRI - - } - className={classes.iconChip} - color="primary" - /> -
+
+ icon + REX-DRI +
+
); } @@ -88,11 +84,11 @@ function Logo({ linkTo }) { } Logo.propTypes = { - linkTo: PropTypes.string + linkTo: PropTypes.string, }; Logo.defaultProps = { - linkTo: "" + linkTo: "", }; export default Logo; diff --git a/frontend/src/components/app/MainAppFrame.jsx b/frontend/src/components/app/MainAppFrame.jsx index 0cbffd99345742b37d0f57a3c735cac4463c58c0..621fc8170c7fc796bfdd5a8c008dcd3f0ddbb54d 100644 --- a/frontend/src/components/app/MainAppFrame.jsx +++ b/frontend/src/components/app/MainAppFrame.jsx @@ -11,7 +11,7 @@ import { infoMenuItems, mainMenuItems, secondaryMenuItems, - settingsMenuItems + settingsMenuItems, } from "./menuItems"; import IconWithMenu from "../common/IconWithMenu"; import DrawerMenu from "./DrawerMenu"; @@ -22,94 +22,94 @@ import Logo from "./Logo"; import BaseTemplate from "./BaseTemplate"; import useOpenClose from "../../hooks/useOpenClose"; -const useStyles = makeStyles(theme => { +const useStyles = makeStyles((theme) => { const onDesktops = "@media (min-width:1375px)"; const onMobiles = "@media (max-width:1375px)"; return { menuButton: { [onDesktops]: { - display: "none" + display: "none", }, marginLeft: -12, - marginRight: 20 + marginRight: 20, }, menuButtonIcon: { - fontSize: "1.5em" + fontSize: "1.5em", }, mainMenuButton: { fontSize: "1.2rem", fontWeight: 700, [onMobiles]: { - display: "none" + display: "none", }, [onDesktops]: { marginLeft: theme.spacing(1), - marginRight: theme.spacing(1) - } + marginRight: theme.spacing(1), + }, }, mainMenuButtonIcon: { marginLeft: theme.spacing(1), fontSize: "1.2em", [onMobiles]: { - display: "none" - } + display: "none", + }, }, contrastTextPrimary: { - color: theme.palette.getContrastText(theme.palette.primary.main) + color: theme.palette.getContrastText(theme.palette.primary.main), }, contrastTextSecondary: { - color: theme.palette.getContrastText(theme.palette.secondary.main) + color: theme.palette.getContrastText(theme.palette.secondary.main), }, mobileIcon: { - color: theme.palette.getContrastText(theme.palette.primary.main) + color: theme.palette.getContrastText(theme.palette.primary.main), }, mobileIconContainer: { marginLeft: theme.spacing(1), - marginRight: theme.spacing(1) + marginRight: theme.spacing(1), }, primaryDark: { backgroundColor: theme.palette.primary.dark, - boxShadow: theme.shadows[1] + boxShadow: theme.shadows[1], }, desktopOnly: { [onMobiles]: { - display: "none" - } + display: "none", + }, }, mobileOnly: { [onDesktops]: { - display: "none" - } + display: "none", + }, }, ifNotTooSmallAndInlined: { "@media (max-width:790px)": { - display: "none" + display: "none", }, - display: "inline" + display: "inline", }, centered: { - margin: "0 auto" + margin: "0 auto", }, leftBlock: { - flex: 2 + flex: 2, }, middleBlock: { - flex: 1 + flex: 1, }, rightBlock: { flex: 2, display: "flex", alignItems: "center", justifyContent: "space-between", - textAlign: "center" + textAlign: "center", }, widthFitContent: { - width: "fit-content" + width: "fit-content", }, filler: { - width: "100%" - } + width: "100%", + }, }; }); @@ -123,7 +123,7 @@ function SecondaryIcons() { fabProps={{ color: "primary", className: classes.mobileIconContainer, - classes: { primary: classes.primaryDark } + classes: { primary: classes.primaryDark }, }} menuItems={infoMenuItems} /> @@ -134,7 +134,7 @@ function SecondaryIcons() { fabProps={{ color: "primary", className: classes.mobileIconContainer, - classes: { primary: classes.primaryDark } + classes: { primary: classes.primaryDark }, }} menuItems={settingsMenuItems} /> @@ -179,7 +179,7 @@ function MenuItems({ items }) { } MenuItems.propTypes = { - items: PropTypes.array.isRequired + items: PropTypes.array.isRequired, }; /** @@ -200,14 +200,12 @@ function SimplifiedItems({ items }) { aria-label={label} className={classes.mobileIconContainer} > - { - - } + ))} @@ -216,7 +214,7 @@ function SimplifiedItems({ items }) { } SimplifiedItems.propTypes = { - items: PropTypes.array.isRequired + items: PropTypes.array.isRequired, }; function SimplifiedLeft({ openDrawer }) { @@ -237,7 +235,7 @@ function SimplifiedLeft({ openDrawer }) { } SimplifiedLeft.propTypes = { - openDrawer: PropTypes.func.isRequired + openDrawer: PropTypes.func.isRequired, }; function SimplifiedRight() { @@ -273,7 +271,7 @@ function MainAppFrame({ children }) {
@@ -282,7 +280,7 @@ function MainAppFrame({ children }) {
@@ -299,7 +297,7 @@ function MainAppFrame({ children }) { } MainAppFrame.propTypes = { - children: PropTypes.node.isRequired + children: PropTypes.node.isRequired, }; export default MainAppFrame; diff --git a/frontend/src/components/app/NotifierImportantInformation.jsx b/frontend/src/components/app/NotifierImportantInformation.jsx index 0515f6845af46ad065380c0002c24c4176f6bf98..4352ae96b1fa5bf36aac3e89a6199e60ceb8b457 100644 --- a/frontend/src/components/app/NotifierImportantInformation.jsx +++ b/frontend/src/components/app/NotifierImportantInformation.jsx @@ -8,11 +8,11 @@ import NotificationService from "../../services/NotificationService"; function NotifierImportantInformation({ informationList }) { informationList - .filter(el => el.should_notify) - .forEach(el => + .filter((el) => el.should_notify) + .forEach((el) => NotificationService.notify(el.message, { variant: el.variant, - autoHideDuration: null + autoHideDuration: null, }) ); @@ -20,7 +20,7 @@ function NotifierImportantInformation({ informationList }) { } NotifierImportantInformation.propTypes = { - informationList: PropTypes.array.isRequired + informationList: PropTypes.array.isRequired, }; export default compose( @@ -28,8 +28,8 @@ export default compose( [ new NetWrapParam("information", "all", { addDataToProp: "informationList", - params: RequestParams.Builder.withQueryParam("now", "true").build() - }) + params: RequestParams.Builder.withQueryParam("now", "true").build(), + }), ], React.Fragment ), diff --git a/frontend/src/components/app/SnackbarCloseButton.jsx b/frontend/src/components/app/SnackbarCloseButton.jsx index 88b620f064e1287621905f91514a3effa85a35b4..e8d3ef1ac7353ee6f7a44b6f3d6bc08269d9eb2c 100644 --- a/frontend/src/components/app/SnackbarCloseButton.jsx +++ b/frontend/src/components/app/SnackbarCloseButton.jsx @@ -13,7 +13,7 @@ function SnackbarCloseButton({ notiKey }) { } SnackbarCloseButton.propTypes = { - notiKey: PropTypes.number.isRequired + notiKey: PropTypes.number.isRequired, }; export default SnackbarCloseButton; diff --git a/frontend/src/components/app/UnlinkedPartners.jsx b/frontend/src/components/app/UnlinkedPartners.jsx index 527d0d9a4f941b8e5dac2f49afd355530d702e57..23cf92cde30522919eba561426bdcbf0d282ac84 100644 --- a/frontend/src/components/app/UnlinkedPartners.jsx +++ b/frontend/src/components/app/UnlinkedPartners.jsx @@ -71,11 +71,11 @@ function UnlinkedPartners({ unlinkedPartners, variant }) { UnlinkedPartners.propTypes = { variant: PropTypes.oneOf(["summary", "detailed"]).isRequired, - unlinkedPartners: PropTypes.array.isRequired + unlinkedPartners: PropTypes.array.isRequired, }; export default withNetworkWrapper([ new NetWrapParam("unlinkedUtcPartners", "all", { - addDataToProp: "unlinkedPartners" - }) + addDataToProp: "unlinkedPartners", + }), ])(UnlinkedPartners); diff --git a/frontend/src/components/app/menuItems.js b/frontend/src/components/app/menuItems.js index 9c86bc48217729dc66aeae2fd6df64792b613e41..d2b0f35298f2e91eccf2c7a7b719681aa8958218 100644 --- a/frontend/src/components/app/menuItems.js +++ b/frontend/src/components/app/menuItems.js @@ -10,31 +10,31 @@ function item(label, route, Icon, hardRedirect = false) { label, route, Icon, - hardRedirect + hardRedirect, }; } export const mainMenuItems = [ item("Carte", APP_ROUTES.map, MapIcon), item("Recherche", APP_ROUTES.search, SearchIcon), - item("Listes", APP_ROUTES.lists, AssignmentIcon) + item("Listes", APP_ROUTES.lists, AssignmentIcon), ]; export const mainMenuHome = item("Accueil", APP_ROUTES.base, HomeIcon); export const secondaryMenuItems = [ - item("Mes échanges", APP_ROUTES.myExchanges, LocationCityIcon) + item("Mes échanges", APP_ROUTES.myExchanges, LocationCityIcon), ]; export const infoMenuItems = [ // item("Mes fichiers", APP_ROUTES.userFilesCurrent, null), // WARNING BETA item("Le projet REX-DRI", APP_ROUTES.aboutProject, null), item("Conditions d'utilisations", APP_ROUTES.aboutCgu, null), - item("Information RGPD", APP_ROUTES.aboutRgpd, null) + item("Information RGPD", APP_ROUTES.aboutRgpd, null), ]; export const settingsMenuItems = [ item("Mes informations", APP_ROUTES.userCurrent, null), item("Personnalisation du thème", APP_ROUTES.themeSettings, null), - item("Se déconnecter", APP_ROUTES.logout, null, true) + item("Se déconnecter", APP_ROUTES.logout, null, true), ]; diff --git a/frontend/src/components/common/Alert.jsx b/frontend/src/components/common/Alert.jsx index c695cc3367737954fb8dbebe655564f04ecbbadf..021286b63b738e8e742c793bc59683834fd3dbda 100644 --- a/frontend/src/components/common/Alert.jsx +++ b/frontend/src/components/common/Alert.jsx @@ -12,9 +12,9 @@ const useStyles = makeStyles({ multilineButton: { display: "block", marginLeft: "auto", - marginRight: "auto" + marginRight: "auto", }, - button: {} + button: {}, }); /** @@ -30,7 +30,7 @@ function Alert({ infoText, multilineButtons, disagreeText, - agreeText + agreeText, }) { const classes = useStyles(); @@ -40,58 +40,56 @@ function Alert({ return ( - { - <> - {title} - - - {description} - - - - {info ? ( + <> + {title} + + + {description} + + + + {info ? ( + + ) : ( +
+ - ) : ( -
- - -
- )} - - - } +
+ )} +
+
); } @@ -106,7 +104,7 @@ Alert.propTypes = { disagreeText: PropTypes.string, // Text display in the "disagree" button multilineButtons: PropTypes.bool, // should the agree/disagree button displayed on multiple lines handleClose: PropTypes.func, // function called when the alert is closed - handleResponse: PropTypes.func // function called allong the previous one with false if the user disagreed and true otherwise. Or no parameters if info. + handleResponse: PropTypes.func, // function called allong the previous one with false if the user disagreed and true otherwise. Or no parameters if info. }; Alert.defaultProps = { @@ -125,7 +123,7 @@ Alert.defaultProps = { handleResponse: () => { // eslint-disable-next-line no-console console.error("Missing function for handling post performClose."); - } + }, }; export default Alert; diff --git a/frontend/src/components/common/CopyToClipboard.jsx b/frontend/src/components/common/CopyToClipboard.jsx index d51d4ab5c768c273c552f32c7c4fb5ee0c808fa1..1724ee1e789fb76e5a5cdb7151f9c18beb44e9f4 100644 --- a/frontend/src/components/common/CopyToClipboard.jsx +++ b/frontend/src/components/common/CopyToClipboard.jsx @@ -17,7 +17,7 @@ function CopyToClipboard({ message, render }) { leaveDelay={1500} onClose={() => setShowTooltip(false)} > - {render(text => { + {render((text) => { clipboardCopy(text); setShowTooltip(true); })} @@ -27,11 +27,11 @@ function CopyToClipboard({ message, render }) { CopyToClipboard.propTypes = { render: PropTypes.func.isRequired, - message: PropTypes.string + message: PropTypes.string, }; CopyToClipboard.defaultProps = { - message: "Lien copié 😁" + message: "Lien copié 😁", }; export default React.memo(CopyToClipboard); diff --git a/frontend/src/components/common/CoverGallery/CoverGallery.jsx b/frontend/src/components/common/CoverGallery/CoverGallery.jsx index c92565152ff0d2e866ad0e7b1d3a7d364f70828b..6a253628def0a58619dfa6fcaf0b9c375b959e36 100644 --- a/frontend/src/components/common/CoverGallery/CoverGallery.jsx +++ b/frontend/src/components/common/CoverGallery/CoverGallery.jsx @@ -1,102 +1,117 @@ import React from "react"; -import withStyles from "@material-ui/core/styles/withStyles"; -import { compose } from "recompose"; -import PropTypes from "prop-types"; -import shuffle from "lodash/shuffle"; -import Typography from "@material-ui/core/Typography"; -import { AwesomeSlider } from "react-awesome-slider"; -import styles from "./CoverGallery.scss"; +import { makeStyles } from "@material-ui/styles"; +// import withStyles from "@material-ui/core/styles/withStyles"; +// import { compose } from "recompose"; +// import PropTypes from "prop-types"; +// import shuffle from "lodash/shuffle"; +// import Typography from "@material-ui/core/Typography"; +// import { AwesomeSlider } from "react-awesome-slider"; +// import styles from "./CoverGallery.scss"; +// +// /** +// * Component to display a cover image gallery with custom styling done in the ./CoverGallery.scss file +// * If no image is provided then a replacement is added :) +// */ +// function CoverGallery({ classes, picturesSrc }) { +// return ( +//
+// {picturesSrc.length === 0 ? ( +//
+// {/* */} +//
+// ) : ( +// +// {shuffle(picturesSrc).map((src) => ( +//
+// ))} +//
+// +// )} +// +//
+// +// Les photos de couverture ne sont pas encore disponibles. +// +// {/* */} +//
+//
+// ); +// } +// +// CoverGallery.propTypes = { +// classes: PropTypes.object.isRequired, +// picturesSrc: PropTypes.arrayOf(PropTypes.string), +// // eslint-disable-next-line react/no-unused-prop-types +// onEditButtonClick: PropTypes.func, +// }; +// +// CoverGallery.defaultProps = { +// picturesSrc: [], +// onEditButtonClick: () => +// // eslint-disable-next-line no-console +// console.log("No function provided to edit cover gallery"), +// }; +// +// const componentStyles = (theme) => ({ +// missingPictureDiv: { +// height: "27vh", +// maxHeight: 150, +// background: `repeating-linear-gradient( +// 45deg, +// ${theme.palette.background.default}, +// ${theme.palette.background.default} 10px, +// ${theme.palette.background.paper} 10px, +// ${theme.palette.background.paper} 20px +// )`, +// }, +// missingPictureIcon: { +// marginLeft: "auto", +// marginRight: "auto", +// width: "100%", +// height: "100%", +// }, +// editButton: { +// position: "absolute", +// zIndex: 1000, +// right: theme.spacing(2), +// bottom: theme.spacing(2), +// }, +// editButtonLabel: { +// [theme.breakpoints.down("sm")]: { +// display: "none", +// }, +// }, +// rightIcon: { +// [theme.breakpoints.up("md")]: { +// marginLeft: theme.spacing(1), +// }, +// }, +// }); +// +// export default compose(withStyles(componentStyles, { withTheme: true }))( +// CoverGallery +// ); -/** - * Component to display a cover image gallery with custom styling done in the ./CoverGallery.scss file - * If no image is provided then a replacement is added :) - */ -function CoverGallery({ classes, picturesSrc }) { - return ( -
- {picturesSrc.length === 0 ? ( -
- {/* */} -
- ) : ( - - {shuffle(picturesSrc).map(src => ( -
- ))} -
- - )} +const useStyles = makeStyles((theme) => ({ + dummyDiv: { + height: theme.spacing(2), + background: "transparent", + }, +})); -
- - Les photos de couverture ne sont pas encore disponibles. - - {/* */} -
-
- ); +function DummyCoverGallery() { + const classes = useStyles(); + return
; } -CoverGallery.propTypes = { - classes: PropTypes.object.isRequired, - picturesSrc: PropTypes.arrayOf(PropTypes.string), - // eslint-disable-next-line react/no-unused-prop-types - onEditButtonClick: PropTypes.func -}; - -CoverGallery.defaultProps = { - picturesSrc: [], - onEditButtonClick: () => - // eslint-disable-next-line no-console - console.log("No function provided to edit cover gallery") -}; - -const componentStyles = theme => ({ - missingPictureDiv: { - height: "27vh", - maxHeight: 150, - background: `repeating-linear-gradient( - 45deg, - ${theme.palette.background.default}, - ${theme.palette.background.default} 10px, - ${theme.palette.background.paper} 10px, - ${theme.palette.background.paper} 20px - )` - }, - missingPictureIcon: { - marginLeft: "auto", - marginRight: "auto", - width: "100%", - height: "100%" - }, - editButton: { - position: "absolute", - zIndex: 1000, - right: theme.spacing(2), - bottom: theme.spacing(2) - }, - editButtonLabel: { - [theme.breakpoints.down("sm")]: { - display: "none" - } - }, - rightIcon: { - [theme.breakpoints.up("md")]: { - marginLeft: theme.spacing(1) - } - } -}); - -export default compose(withStyles(componentStyles, { withTheme: true }))( - CoverGallery -); +export default DummyCoverGallery; diff --git a/frontend/src/components/common/CustomError.jsx b/frontend/src/components/common/CustomError.jsx index a2316d9a43272e615b1ca464098f1f71799f3b23..710635d20a6b5b59f1b9a51f125e2bf3f05dc901 100644 --- a/frontend/src/components/common/CustomError.jsx +++ b/frontend/src/components/common/CustomError.jsx @@ -22,7 +22,7 @@ export default class CustomError { */ static superCombine(arrOfCustomErrors) { return new CustomError( - Array.prototype.concat(arrOfCustomErrors.flatMap(el => el.messages)) + Array.prototype.concat(arrOfCustomErrors.flatMap((el) => el.messages)) ); } diff --git a/frontend/src/components/common/CustomLink.jsx b/frontend/src/components/common/CustomLink.jsx index 144b952113496e3bd40bac3e9ecf54ec6c2ee398..9653f94e95a279ba1dd6e317587a37e125b59bc3 100644 --- a/frontend/src/components/common/CustomLink.jsx +++ b/frontend/src/components/common/CustomLink.jsx @@ -18,7 +18,7 @@ function CustomLink({ classes, to, children }) { CustomLink.propTypes = { to: PropTypes.string.isRequired, children: PropTypes.node.isRequired, - classes: PropTypes.object.isRequired + classes: PropTypes.object.isRequired, }; export default withStyles(styles, { withTheme: true })(CustomLink); diff --git a/frontend/src/components/common/CustomNavLink.jsx b/frontend/src/components/common/CustomNavLink.jsx index 7d4292ebb303b18f9e810bc67b6ff021ff5feb4e..c96422db0d14035b45a74675b629982598575205 100644 --- a/frontend/src/components/common/CustomNavLink.jsx +++ b/frontend/src/components/common/CustomNavLink.jsx @@ -3,11 +3,11 @@ import React from "react"; import PropTypes from "prop-types"; import { makeStyles } from "@material-ui/styles"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ link: { color: theme.palette.text.primary, - textDecoration: "none" - } + textDecoration: "none", + }, })); /** @@ -26,7 +26,7 @@ function CustomNavLink(props) { CustomNavLink.propTypes = { to: PropTypes.string.isRequired, - children: PropTypes.node.isRequired + children: PropTypes.node.isRequired, }; export default CustomNavLink; diff --git a/frontend/src/components/common/DeleteHandler.jsx b/frontend/src/components/common/DeleteHandler.jsx index 4977af28c4cc1abe033726b6e1ddf0f75506b771..3a560faff07f6c7fa9c9586010e0efee66b4b171 100644 --- a/frontend/src/components/common/DeleteHandler.jsx +++ b/frontend/src/components/common/DeleteHandler.jsx @@ -14,10 +14,10 @@ function DeleteHandler({ performClose, route, id }) { agreeText: "Oui", disagreeText: "Non", handleClose: { performClose }, - handleResponse: confirmed => { + handleResponse: (confirmed) => { if (confirmed) performDelete(id, () => performClose()); else performClose(); - } + }, }); }, []); @@ -28,9 +28,9 @@ DeleteHandler.propTypes = { route: PropTypes.string.isRequired, id: PropTypes.oneOfType([ PropTypes.string.isRequired, - PropTypes.number.isRequired + PropTypes.number.isRequired, ]).isRequired, - performClose: PropTypes.func.isRequired + performClose: PropTypes.func.isRequired, }; export default DeleteHandler; diff --git a/frontend/src/components/common/DownshiftMultiple.jsx b/frontend/src/components/common/DownshiftMultiple.jsx index 60183f1244a147bc678f62daab4ff06a8f125778..27d4c2b9f07c42cb53ae4b99d4a66719c7a23d02 100644 --- a/frontend/src/components/common/DownshiftMultiple.jsx +++ b/frontend/src/components/common/DownshiftMultiple.jsx @@ -12,33 +12,33 @@ import fuzzysort from "fuzzysort"; import { makeStyles } from "@material-ui/styles"; import useGlobalState from "../../hooks/useGlobalState"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ root: { - flexGrow: 1 + flexGrow: 1, }, container: { flexGrow: 1, - position: "relative" + position: "relative", }, paper: { position: "absolute", zIndex: 200000, marginTop: theme.spacing(1), left: 0, - right: 0 + right: 0, }, chip: { - margin: theme.spacing(0.5, 0.25) + margin: theme.spacing(0.5, 0.25), }, inputRoot: { - flexWrap: "wrap" + flexWrap: "wrap", }, notSelectedSuggestion: { - fontWeight: 400 + fontWeight: 400, }, selectedSuggestion: { - fontWeight: 500 - } + fontWeight: 500, + }, })); function Input({ inputProps, autoFocus }) { @@ -52,7 +52,7 @@ function Input({ inputProps, autoFocus }) { InputProps={{ inputRef: ref, classes: { root: classes.inputRoot }, - ...InputProps + ...InputProps, }} {...other} /> @@ -61,7 +61,7 @@ function Input({ inputProps, autoFocus }) { Input.propTypes = { inputProps: PropTypes.object.isRequired, - autoFocus: PropTypes.bool.isRequired + autoFocus: PropTypes.bool.isRequired, }; function Suggestion({ @@ -69,7 +69,7 @@ function Suggestion({ index, itemProps, highlightedIndex, - selectedItem + selectedItem, }) { const classes = useStyles(); const isHighlighted = highlightedIndex === index; @@ -96,13 +96,13 @@ Suggestion.propTypes = { selectedItem: PropTypes.string, suggestion: PropTypes.shape({ label: PropTypes.string, - value: PropTypes.string - }).isRequired + value: PropTypes.string, + }).isRequired, }; Suggestion.defaultProps = { highlightedIndex: null, - selectedItem: null + selectedItem: null, }; function DownshiftMultiple({ @@ -114,17 +114,17 @@ function DownshiftMultiple({ multiple, fieldLabel, fieldPlaceholder, - autoFocusInput + autoFocusInput, }) { const reverseOptions = useMemo(() => { const out = new Map(); - optionsFromProps.forEach(el => out.set(el.value, el.label)); + optionsFromProps.forEach((el) => out.set(el.value, el.label)); return out; }, [optionsFromProps]); const [cache, setCache] = useGlobalState(`app-downshift-${cacheId}`, { value: valueFromProps, - inputValue: inputValueFromProps + inputValue: inputValueFromProps, }); const [value, setValue] = useState( @@ -140,15 +140,15 @@ function DownshiftMultiple({ }, [value, inputValue]); const options = useMemo(() => { - return optionsFromProps.map(el => ({ + return optionsFromProps.map((el) => ({ value: el.value, label: el.label, - valueStr: el.value.toString() + valueStr: el.value.toString(), })); }, [optionsFromProps]); const onChange = useCallback( - newValue => { + (newValue) => { if (multiple) { onChangeFromProps(newValue); } else { @@ -160,16 +160,16 @@ function DownshiftMultiple({ ); const getSuggestions = useCallback( - newInputValue => { + (newInputValue) => { // Suggest only unselected options - const possible = options.filter(el => !value.includes(el.value)); + const possible = options.filter((el) => !value.includes(el.value)); const filter = fuzzysort.go(newInputValue, possible, { limit: 5, - keys: ["label", "valueStr"] + keys: ["label", "valueStr"], }); if (filter.length > 0) { - return filter.map(item => item.obj); + return filter.map((item) => item.obj); } return possible.slice(0, 4); }, @@ -177,24 +177,24 @@ function DownshiftMultiple({ ); const handleKeyDown = useCallback( - event => { + (event) => { if ( value.length && !inputValue.length && keycode(event) === "backspace" ) { - setValue(v => v.slice(0, v.length - 1)); + setValue((v) => v.slice(0, v.length - 1)); } }, [value, inputValue] ); - const handleInputChange = useCallback(event => { + const handleInputChange = useCallback((event) => { setInputValue(event.target.value); }, []); const handleChange = useCallback( - val => { + (val) => { if (val === null) return; // on reset will be null let newValue = value; @@ -214,9 +214,9 @@ function DownshiftMultiple({ ); const handleDelete = useCallback( - val => { - setValue(valueInState => { - const newValue = valueInState.filter(v => val !== v); + (val) => { + setValue((valueInState) => { + const newValue = valueInState.filter((v) => val !== v); onChange(newValue); return newValue; }); @@ -236,7 +236,7 @@ function DownshiftMultiple({ inputValue: inputValue2, selectedItem: selectedItem2, highlightedIndex, - clearSelection + clearSelection, }) => (
( + startAdornment: value.map((val) => ( {isOpen ? ( @@ -300,12 +300,12 @@ DownshiftMultiple.propTypes = { label: PropTypes.string.isRequired, value: PropTypes.oneOfType([ PropTypes.string.isRequired, - PropTypes.number.isRequired - ]).isRequired // NEVER PUT A NULL + PropTypes.number.isRequired, + ]).isRequired, // NEVER PUT A NULL }) ).isRequired, multiple: PropTypes.bool, // do we allow multiple values to be selected. - cacheId: PropTypes.string // if not null enable caching of value and input Value + cacheId: PropTypes.string, // if not null enable caching of value and input Value // If multiple is true than null or one value in returned }; @@ -316,7 +316,7 @@ DownshiftMultiple.defaultProps = { multiple: true, value: [], inputValue: "", - cacheId: null + cacheId: null, }; export default React.memo(DownshiftMultiple); diff --git a/frontend/src/components/common/ErrorBoundary.jsx b/frontend/src/components/common/ErrorBoundary.jsx index a7082db051e8b9677302bf037559141b54f84e4b..127ef67f96ca9594cd56b3be88146abb65dae09f 100644 --- a/frontend/src/components/common/ErrorBoundary.jsx +++ b/frontend/src/components/common/ErrorBoundary.jsx @@ -8,7 +8,7 @@ import { useApiCreate } from "../../hooks/wrappers/api"; function clear() { return { error: null, - errorInfo: null + errorInfo: null, }; } @@ -22,7 +22,7 @@ class ErrorBoundary extends React.Component { // Catch errors in any components below and re-render with error message this.setState({ error, - errorInfo + errorInfo, }); const data = "stack" in error ? { componentStack: error.stack } : errorInfo; @@ -45,11 +45,11 @@ class ErrorBoundary extends React.Component { agreeText: "C'est noté, je sais que vous faîtes de votre mieux :)", disagreeText: "Retourner à l'accueil", - handleResponse: agreed => { + handleResponse: (agreed) => { this.setState(clear()); // May need to click twice, but there seem to be no other ways if (!agreed) NavigationService.goHome(); - } + }, }); return <>; @@ -62,7 +62,7 @@ class ErrorBoundary extends React.Component { ErrorBoundary.propTypes = { children: PropTypes.node.isRequired, - logErrorOnServer: PropTypes.func.isRequired + logErrorOnServer: PropTypes.func.isRequired, }; /** @@ -72,7 +72,7 @@ ErrorBoundary.propTypes = { */ // eslint-disable-next-line import/prefer-default-export export function withErrorBoundary() { - return Component => + return (Component) => setDisplayName("error-boundary")( // We need to forward the ref otherwise the styles are not correctly applied. // eslint-disable-next-line react/display-name diff --git a/frontend/src/components/common/FullScreenDialogFrame.jsx b/frontend/src/components/common/FullScreenDialogFrame.jsx index 826ade00450fbd33afd655cc02a086f346acb094..e74276c269425ac0822c82685847a9c038799596 100644 --- a/frontend/src/components/common/FullScreenDialogFrame.jsx +++ b/frontend/src/components/common/FullScreenDialogFrame.jsx @@ -8,24 +8,24 @@ import Paper from "@material-ui/core/Paper"; import PropTypes from "prop-types"; import { makeStyles } from "@material-ui/styles"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ appBar: { - position: "sticky" + position: "sticky", }, flex: { - flex: 1 + flex: 1, }, paper: { padding: theme.spacing(2), - margin: theme.spacing(2) - } + margin: theme.spacing(2), + }, })); function FullScreenDialogFrame({ children, rightButton, handleCloseRequest, - title + title, }) { const classes = useStyles(); @@ -55,11 +55,11 @@ FullScreenDialogFrame.propTypes = { children: PropTypes.node.isRequired, handleCloseRequest: PropTypes.func.isRequired, title: PropTypes.string.isRequired, - rightButton: PropTypes.node + rightButton: PropTypes.node, }; FullScreenDialogFrame.defaultProps = { - rightButton: <> + rightButton: <>, }; export default FullScreenDialogFrame; diff --git a/frontend/src/components/common/IconWithMenu.jsx b/frontend/src/components/common/IconWithMenu.jsx index b5d08f2f6d40e13e3472ce7f5742a51a632ae5f1..495f53779650ee6b34df11b03c0d0f61bec84347 100644 --- a/frontend/src/components/common/IconWithMenu.jsx +++ b/frontend/src/components/common/IconWithMenu.jsx @@ -18,7 +18,7 @@ const ForwardedNavLink = React.forwardRef((props, ref) => ( function IconWithMenu({ fabProps, Icon, menuItems, iconProps }) { const [anchorEl, setAnchorEl] = useState(null); - const handleOpenMenu = useCallback(event => { + const handleOpenMenu = useCallback((event) => { setAnchorEl(event.currentTarget); }, []); @@ -30,17 +30,17 @@ function IconWithMenu({ fabProps, Icon, menuItems, iconProps }) { return ( <> - {} + ({ +const useStyles = makeStyles((theme) => ({ spacer: { - marginBottom: theme.spacing(2) - } + marginBottom: theme.spacing(2), + }, })); /** @@ -31,7 +31,7 @@ function LicenseNotice(props) { } LicenseNotice.propTypes = { - variant: PropTypes.oneOf(["REX-DRI—PRIVATE", "REX-DRI—BY"]).isRequired + variant: PropTypes.oneOf(["REX-DRI—PRIVATE", "REX-DRI—BY"]).isRequired, }; export default LicenseNotice; diff --git a/frontend/src/components/common/LinkToUser.jsx b/frontend/src/components/common/LinkToUser.jsx index 413c2a7dd2eab0a4ec803ad5140765b1fd09370c..e09529374e90146dfc4adae35f6660738fd2a831 100644 --- a/frontend/src/components/common/LinkToUser.jsx +++ b/frontend/src/components/common/LinkToUser.jsx @@ -18,5 +18,5 @@ export default function LinkToUser(props) { LinkToUser.propTypes = { userId: PropTypes.number, - pseudo: PropTypes.string + pseudo: PropTypes.string, }; diff --git a/frontend/src/components/common/Loading.jsx b/frontend/src/components/common/Loading.jsx index d89022ab15ede14e720ee86e64cd71808b9bf05a..b93238fa206933faceeb659f5d01d4634f83d9e9 100644 --- a/frontend/src/components/common/Loading.jsx +++ b/frontend/src/components/common/Loading.jsx @@ -4,10 +4,10 @@ import CircularProgress from "@material-ui/core/CircularProgress"; import { makeStyles } from "@material-ui/styles"; import useInterval from "../../utils/useInterval"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ progress: { - margin: theme.spacing(2) - } + margin: theme.spacing(2), + }, })); /** @@ -32,11 +32,11 @@ function Loading({ size }) { } Loading.propTypes = { - size: PropTypes.number + size: PropTypes.number, }; Loading.defaultProps = { - size: 50 + size: 50, }; export default Loading; diff --git a/frontend/src/components/common/MetricFeedback.jsx b/frontend/src/components/common/MetricFeedback.jsx index d67f810e25ca69d0850c93d0d69cfa9d47130ba8..179eed0b9a001555f056036f8c0d7e377ab2b725 100644 --- a/frontend/src/components/common/MetricFeedback.jsx +++ b/frontend/src/components/common/MetricFeedback.jsx @@ -22,53 +22,53 @@ const possibleIconsOpposite = [ DoneAll, Done, Warning, - Close + Close, ]; const breakPointsOpposite = [11, 22, 33, 44, 55, 66, 77, 88, 100]; const indicatorWidth = 14; const indicatorExtraHeight = 10; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ barContainer: { flexWrap: "nowrap", display: "flex", alignItems: "center", paddingTop: 25, - paddingBottom: 10 + paddingBottom: 10, }, barContent: {}, linearBackground: { - background: getGradient([...viridis].reverse()) + background: getGradient([...viridis].reverse()), }, divergentBackground: { - background: getGradient(Spectral) + background: getGradient(Spectral), }, oppositeBackground: { - background: getGradient([...Spectral, ...[...Spectral].reverse()]) + background: getGradient([...Spectral, ...[...Spectral].reverse()]), }, colorBar: { - height: props => props.height, - borderRadius: props => props.height / 2, + height: (props) => props.height, + borderRadius: (props) => props.height / 2, marginLeft: 10, - marginRight: 10 + marginRight: 10, }, indicator: { - height: props => props.height + indicatorExtraHeight, + height: (props) => props.height + indicatorExtraHeight, width: indicatorWidth, top: -(indicatorExtraHeight / 2), borderRadius: indicatorExtraHeight, position: "relative", background: theme.palette.background.default, borderStyle: "solid", - borderColor: theme.palette.text.primary + borderColor: theme.palette.text.primary, }, indicatorIcon: { left: "50%", transform: "translateX(-50%)", position: "relative", - top: -29 - } + top: -29, + }, })); /** @@ -108,7 +108,7 @@ function MetricFeedback(props) { showBarIcons, type, LeftBarIcon, - RightBarIcon + RightBarIcon, } = props; const minValue = parseFloat(min); const maxValue = parseFloat(max); @@ -144,7 +144,7 @@ function MetricFeedback(props) { className={classes.indicator} style={{ left: `${percent}%`, - transform: `translateX(-${percent}%)` + transform: `translateX(-${percent}%)`, }} > @@ -167,7 +167,7 @@ MetricFeedback.propTypes = { value: PropTypes.number, showBarIcons: PropTypes.bool, LeftBarIcon: PropTypes.object, - RightBarIcon: PropTypes.object + RightBarIcon: PropTypes.object, }; MetricFeedback.defaultProps = { @@ -179,7 +179,7 @@ MetricFeedback.defaultProps = { height: 20, showBarIcons: false, LeftBarIcon: ThumbsDown, - RightBarIcon: ThumbsUp + RightBarIcon: ThumbsUp, }; export default MetricFeedback; diff --git a/frontend/src/components/common/MyBadge.jsx b/frontend/src/components/common/MyBadge.jsx index 69619d9b15a5209d56cfe9cabd918d3279626da5..126a8df9ac8cabf22477a5966626b96a75f10514 100644 --- a/frontend/src/components/common/MyBadge.jsx +++ b/frontend/src/components/common/MyBadge.jsx @@ -3,12 +3,12 @@ import Badge from "@material-ui/core/Badge"; import { withStyles } from "@material-ui/core"; // fix positioning of the badge that was a bit too high -const styles = theme => ({ +const styles = (theme) => ({ badge: { top: "8px", right: "9px", - border: `1px solid ${theme.palette.background.paper}` - } + border: `1px solid ${theme.palette.background.paper}`, + }, }); /** @@ -18,7 +18,7 @@ const styles = theme => ({ * @param {object} props * @returns */ -export default withStyles(styles, { withTheme: true })(props => { +export default withStyles(styles, { withTheme: true })((props) => { if (props.badgeContent >= props.minNumber) { return ( { + const onBlur = useCallback((e) => { const { currentTarget } = e; setTimeout(() => { @@ -24,5 +24,5 @@ export default function OnBlurContainer(props) { OnBlurContainer.propTypes = { children: PropTypes.node.isRequired, - onBlur: PropTypes.func.isRequired + onBlur: PropTypes.func.isRequired, }; diff --git a/frontend/src/components/common/PaginatedData.jsx b/frontend/src/components/common/PaginatedData.jsx index a7e3eb43116f023f74565bc43f62fd39e7723b50..4fa5527097d02a117954fbba4a8483111094c8cb 100644 --- a/frontend/src/components/common/PaginatedData.jsx +++ b/frontend/src/components/common/PaginatedData.jsx @@ -6,25 +6,25 @@ import KeyboardArrowLeft from "@material-ui/icons/KeyboardArrowLeft"; import KeyboardArrowRight from "@material-ui/icons/KeyboardArrowRight"; import PropTypes from "prop-types"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ root: { maxWidth: 800, - margin: "0 auto" + margin: "0 auto", }, stepperContainer: { - width: "100%" + width: "100%", }, progress: { [theme.breakpoints.up("sm")]: { - width: "65%" + width: "65%", }, [theme.breakpoints.down("sm")]: { - width: "60%" + width: "60%", }, [theme.breakpoints.down("xs")]: { - width: "30%" - } - } + width: "30%", + }, + }, })); function PaginatedData(props) { @@ -35,7 +35,7 @@ function PaginatedData(props) { render, stepperOnBottom, stepperOnTop, - EmptyMessageComponent + EmptyMessageComponent, } = props; const { page: activeStep, @@ -43,7 +43,7 @@ function PaginatedData(props) { first, pages_count: nbOfPages, content, - number_elements: totalElements + number_elements: totalElements, } = data; if (totalElements === 0) { @@ -91,7 +91,7 @@ function PaginatedData(props) { return (
{stepperOnTop && renderStepper()} -
{content.map(dataEl => render(dataEl))}
+
{content.map((dataEl) => render(dataEl))}
{stepperOnBottom && renderStepper()}
); @@ -99,7 +99,7 @@ function PaginatedData(props) { PaginatedData.defaultProps = { stepperOnTop: false, - stepperOnBottom: false + stepperOnBottom: false, }; PaginatedData.propTypes = { @@ -110,13 +110,13 @@ PaginatedData.propTypes = { pages_count: PropTypes.number.isRequired, number_elements: PropTypes.number.isRequired, page_size: PropTypes.number.isRequired, - content: PropTypes.array.isRequired + content: PropTypes.array.isRequired, }).isRequired, goToPage: PropTypes.func.isRequired, render: PropTypes.func.isRequired, stepperOnTop: PropTypes.bool, stepperOnBottom: PropTypes.bool, - EmptyMessageComponent: PropTypes.node.isRequired + EmptyMessageComponent: PropTypes.node.isRequired, }; export default PaginatedData; diff --git a/frontend/src/components/common/SameLine.jsx b/frontend/src/components/common/SameLine.jsx index 03cd1d33812535acd400e453c5303ebaec28c1a7..165f879a6a138f4e05ecab88576ce11cc2f48f17 100644 --- a/frontend/src/components/common/SameLine.jsx +++ b/frontend/src/components/common/SameLine.jsx @@ -26,7 +26,7 @@ function SameLine(props) { } SameLine.propTypes = { - children: PropTypes.arrayOf(PropTypes.element).isRequired + children: PropTypes.arrayOf(PropTypes.element).isRequired, }; export default SameLine; diff --git a/frontend/src/components/common/SaveButton.jsx b/frontend/src/components/common/SaveButton.jsx index 9ceddedef174d326a519194a40484fb0b448f004..7e00ae9ad4c709da69127d6de60ca0f1501fba92 100644 --- a/frontend/src/components/common/SaveButton.jsx +++ b/frontend/src/components/common/SaveButton.jsx @@ -10,28 +10,28 @@ import { makeStyles } from "@material-ui/styles"; import useInterval from "../../utils/useInterval"; import classNames from "../../utils/classNames"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ root: { display: "flex", alignItems: "center", - width: "fit-content" + width: "fit-content", }, wrapper: { margin: theme.spacing(1), - position: "relative" + position: "relative", }, buttonSuccess: { backgroundColor: green[500], "&:hover": { - backgroundColor: green[700] - } + backgroundColor: green[700], + }, }, fabProgress: { color: green[500], position: "absolute", top: -6, left: -6, - zIndex: 1 + zIndex: 1, }, buttonProgress: { color: green[500], @@ -39,8 +39,8 @@ const useStyles = makeStyles(theme => ({ top: "50%", left: "50%", marginTop: -12, - marginLeft: -12 - } + marginLeft: -12, + }, })); /** @@ -134,7 +134,7 @@ SaveButton.propTypes = { * Time in millisecond to wait before an auto save is triggered. * If null, no auto save is enabled. */ - autoSaveTimeout: PropTypes.number + autoSaveTimeout: PropTypes.number, }; SaveButton.defaultProps = { @@ -143,7 +143,7 @@ SaveButton.defaultProps = { label: "Enregistrer", extraRootClass: "", autoResetSuccessTimeout: 0, - autoSaveTimeout: null + autoSaveTimeout: null, }; export default SaveButton; diff --git a/frontend/src/components/common/SimplePopupMenu.jsx b/frontend/src/components/common/SimplePopupMenu.jsx index 5bf7b294cca640fa8b72730f81130d33ec3680fa..e9462f94b1289988509f84866ad5fe5908751df8 100644 --- a/frontend/src/components/common/SimplePopupMenu.jsx +++ b/frontend/src/components/common/SimplePopupMenu.jsx @@ -22,7 +22,7 @@ function SimplePopupMenu(props) { return ( <> - {props.renderHolder({ onClick: e => handleClick(e) })} + {props.renderHolder({ onClick: (e) => handleClick(e) })} ({ +export const styles = (theme) => ({ link: { color: theme.palette.text.primary, - textDecoration: `underline ${getLinkColor(theme)}` + textDecoration: `underline ${getLinkColor(theme)}`, // boxShadow: `0px 0.08em 0.01em -0.01em ${getLinkColor( // theme // )}, inset 0px -0.1em 0.03em -0.03em ${getLinkColor(theme)}`, @@ -19,7 +19,7 @@ export const styles = theme => ({ // borderTopLeftRadius: "100%", // borderBottomLeftRadius: "10%", // borderBottomRightRadius: "30%" - } + }, }); const useStyles = makeStyles(styles); @@ -44,7 +44,7 @@ function TextLink({ href, children }) { TextLink.propTypes = { href: PropTypes.string.isRequired, - children: PropTypes.node.isRequired + children: PropTypes.node.isRequired, }; export default TextLink; diff --git a/frontend/src/components/common/markdown/BaseMarkdown.jsx b/frontend/src/components/common/markdown/BaseMarkdown.jsx index dab00ab1cd9a2a0afbdda11957d10779f5a103fe..3dd4d86a778b9fc68372dd50290eb27ea06782a8 100644 --- a/frontend/src/components/common/markdown/BaseMarkdown.jsx +++ b/frontend/src/components/common/markdown/BaseMarkdown.jsx @@ -21,7 +21,7 @@ import TextLink, { getLinkColor } from "../TextLink"; // Custom styling for the rendered markdown // To be used in hooks based components only -const useStyles = makeStyles(theme => { +const useStyles = makeStyles((theme) => { const { palette } = theme; const backgroundTable = palette.type === "dark" @@ -35,13 +35,13 @@ const useStyles = makeStyles(theme => { return { list: { color: palette.text.primary, - marginBottom: theme.spacing(2) + marginBottom: theme.spacing(2), }, code: { - fontFamily: "monospace" + fontFamily: "monospace", }, listItem: { - marginTop: theme.spacing(0.75) + marginTop: theme.spacing(0.75), }, blockquote: { color: palette.text.secondary, @@ -53,25 +53,25 @@ const useStyles = makeStyles(theme => { paddingTop: "0px", paddingBottom: "0px", paddingRight: "10px", - paddingLeft: "10px" + paddingLeft: "10px", }, table: { // color: palette.text.primary, }, tableHead: { fontSize: "14px", - background: headerTable + background: headerTable, }, backgroundTable: { - background: backgroundTable + background: backgroundTable, }, bold: { - fontWeight: 700 + fontWeight: 700, }, divider: { paddingBottom: theme.spacing(1), - marginBottom: theme.spacing(1) - } + marginBottom: theme.spacing(1), + }, }; }); @@ -157,7 +157,7 @@ function getRenderers(headingOffset) { list: ListRenderer, listItem: ListItemRenderer, paragraph: ({ children }) => {children}, - link: props => , + link: (props) => , code: CodeRenderer, inlineCode: InlineCodeRenderer, blockquote: BlockquoteRenderer, @@ -166,7 +166,7 @@ function getRenderers(headingOffset) { tableBody: ({ children }) => {children}, tableRow: ({ children }) => {children}, tableCell: ({ children }) => {children}, - thematicBreak: () => + thematicBreak: () => , }; } @@ -186,7 +186,7 @@ function BaseMarkdown({ compileSource, source, headingOffset }) { "text", "emphasis", "root", - "strong" + "strong", ]} // Only allow custom nodes and basic ones mode="escape" source={compiledSource} @@ -201,12 +201,12 @@ BaseMarkdown.propTypes = { /** * Shift heading so that they are not too big */ - headingOffset: PropTypes.number + headingOffset: PropTypes.number, }; BaseMarkdown.defaultProps = { headingOffset: 4, - compileSource: source => source + compileSource: (source) => source, }; export default React.memo(BaseMarkdown); diff --git a/frontend/src/components/common/markdown/Markdown.jsx b/frontend/src/components/common/markdown/Markdown.jsx index 4a8243b0cb87e928e3bbd2959b95560b43450a18..16096d9099fab6f1107b2b5cecccbf1f3739fef0 100644 --- a/frontend/src/components/common/markdown/Markdown.jsx +++ b/frontend/src/components/common/markdown/Markdown.jsx @@ -9,7 +9,7 @@ import CurrencyService from "../../../services/data/CurrencyService"; function compileSource(source) { let compiled = ""; - parseMoney(source).forEach(el => { + parseMoney(source).forEach((el) => { if (!el.isMoney) { compiled += el.text; } else { @@ -41,6 +41,6 @@ function compileSource(source) { * * @return {string} */ -export default React.memo(props => ( - compileSource(s)} /> +export default React.memo((props) => ( + compileSource(s)} /> )); diff --git a/frontend/src/components/common/markdown/TruncatedMarkdown.jsx b/frontend/src/components/common/markdown/TruncatedMarkdown.jsx index eee2a310aac9b5aac003d47db016d0124cfcfaa3..80682f76d3cdb711bdda6dbe58bd56147717cddb 100644 --- a/frontend/src/components/common/markdown/TruncatedMarkdown.jsx +++ b/frontend/src/components/common/markdown/TruncatedMarkdown.jsx @@ -37,17 +37,17 @@ function TruncatedMarkdown(props) { TruncatedMarkdown.propTypes = { classes: PropTypes.object.isRequired, source: PropTypes.string.isRequired, - truncateFromLength: PropTypes.number + truncateFromLength: PropTypes.number, }; TruncatedMarkdown.defaultProps = { - truncateFromLength: 100 + truncateFromLength: 100, }; -const styles = theme => ({ +const styles = (theme) => ({ truncated: { maxHeight: "6rem", - overflow: "hidden" + overflow: "hidden", }, gradientBorder: { position: "relative", @@ -55,12 +55,12 @@ const styles = theme => ({ bottom: 0, width: "100%", height: "3rem", - background: `linear-gradient(to bottom, transparent, ${theme.palette.background.paper})` + background: `linear-gradient(to bottom, transparent, ${theme.palette.background.paper})`, }, moreButton: { display: "block", - margin: "0 auto" - } + margin: "0 auto", + }, }); export default compose(withStyles(styles))(TruncatedMarkdown); diff --git a/frontend/src/components/common/theme/OfflineThemeProvider.jsx b/frontend/src/components/common/theme/OfflineThemeProvider.jsx index 8efe2d1ada3f9907ffb19c50ec3e601f6af47f3c..cd77e820e2239a624aaba505e48fcd4740681be8 100644 --- a/frontend/src/components/common/theme/OfflineThemeProvider.jsx +++ b/frontend/src/components/common/theme/OfflineThemeProvider.jsx @@ -1,7 +1,7 @@ -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"; +import defaultTheme from "../../../config/defaultTheme.json"; import { getTheme, updatePhoneStatusBarColor } from "./utils"; /** @@ -16,5 +16,5 @@ export default function OfflineThemeProvider(props) { } OfflineThemeProvider.propTypes = { - children: PropTypes.node.isRequired + children: PropTypes.node.isRequired, }; diff --git a/frontend/src/components/common/theme/ThemeProvider.jsx b/frontend/src/components/common/theme/ThemeProvider.jsx index 40ba606b6c250632e606f9d837b975c43ff79e7a..bf90bf818d355e84303ab5f83d5614d2bd7aeef1 100644 --- a/frontend/src/components/common/theme/ThemeProvider.jsx +++ b/frontend/src/components/common/theme/ThemeProvider.jsx @@ -1,12 +1,12 @@ 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); diff --git a/frontend/src/components/common/theme/utils.js b/frontend/src/components/common/theme/utils.js index e832f059bf6a9f3a42ff2fbf4ad992a84706b6fb..d9a2f190062e9cafd87a4cd491fa84c68d0a114b 100644 --- a/frontend/src/components/common/theme/utils.js +++ b/frontend/src/components/common/theme/utils.js @@ -5,18 +5,18 @@ import { createMuiTheme, responsiveFontSizes, - rgbToHex + rgbToHex, } from "@material-ui/core/styles"; import "typeface-roboto"; const siteSettings = { typography: { fontSize: 13, - htmlFontSize: 13 + htmlFontSize: 13, }, myPaper: { - padding: 16 - } + padding: 16, + }, }; /** @@ -53,12 +53,12 @@ export function getTheme(themeData) { const palette = { type, primary: { main: themeData[type].primary }, - secondary: { main: themeData[type].secondary } + secondary: { main: themeData[type].secondary }, }; const themeObj = { ...siteSettings, - palette + palette, }; const theme = createMuiTheme(themeObj); return responsiveFontSizes(theme); diff --git a/frontend/src/components/edition/Editor.jsx b/frontend/src/components/edition/Editor.jsx index 1db1ab4859b5934db8151d261210b7fb0ef7b719..9d85163a5036fd7c1dc86435a356cddf705fc1d1 100644 --- a/frontend/src/components/edition/Editor.jsx +++ b/frontend/src/components/edition/Editor.jsx @@ -60,7 +60,7 @@ class Editor extends React.Component { */ parseRawModelData() { const out = {}; - this.formManager.getFieldsMapping().forEach(fieldMapping => { + this.formManager.getFieldsMapping().forEach((fieldMapping) => { out[fieldMapping] = this.props.rawModelData[fieldMapping]; }); @@ -88,7 +88,7 @@ class Editor extends React.Component { // So that we don't forget anything. this.performSave({ ...this.parseRawModelData(this.props.rawModelData), - ...formData + ...formData, }); } else { this.editorManager.notifyNoChangesDetected(); @@ -106,7 +106,7 @@ class Editor extends React.Component { */ performSave(data) { this.editorManager.notifyIsSaving(); - this.props.saveData(data, newData => + this.props.saveData(data, (newData) => this.handleSaveRequestWasSuccessful(newData) ); } @@ -210,7 +210,7 @@ class Editor extends React.Component { infoText: "J'ai compris", handleResponse: () => { this.props.clearSaveError(); - } + }, }); } @@ -222,13 +222,13 @@ class Editor extends React.Component { "Vous avez des modifications qui n'ont pas été sauvegardées. Voulez-vous les enregistrer ?", agreeText: "Oui, je les enregistre", disagreeText: "Non", - handleResponse: agree => { + handleResponse: (agree) => { if (agree) { this.handleSaveEditorRequest(); } else { this.closeEditor(); } - } + }, }); } } @@ -247,7 +247,7 @@ Editor.propTypes = { formLevelErrors: PropTypes.array, license: PropTypes.string, - onClose: PropTypes.func + onClose: PropTypes.func, }; Editor.defaultProps = { @@ -257,7 +257,7 @@ Editor.defaultProps = { lastUpdateTimeInModel: undefined, hasPendingModeration: undefined, // eslint-disable-next-line no-unused-vars - onClose: somethingWasSaved => {} + onClose: (somethingWasSaved) => {}, }; export default React.memo(Editor); diff --git a/frontend/src/components/edition/History.jsx b/frontend/src/components/edition/History.jsx index d97af8d77259f0d19ff171204f40f91253d30dec..164e0394b62740bf0e4f06c6f9f12285fb4787db 100644 --- a/frontend/src/components/edition/History.jsx +++ b/frontend/src/components/edition/History.jsx @@ -18,14 +18,14 @@ import dateTimeStrToStr from "../../utils/dateTimeStrToStr"; import withNetworkWrapper, { NetWrapParam } from "../../hoc/withNetworkWrapper"; import { useApiInvalidateAll } from "../../hooks/wrappers/api"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ editButton: { display: "block", marginLeft: "auto", marginRight: "auto", marginTop: theme.spacing(2), - marginBottom: theme.spacing(2) - } + marginBottom: theme.spacing(2), + }, })); function VersionInfo({ rawModelData, versionNumber, editFromVersion }) { @@ -61,7 +61,7 @@ function VersionInfo({ rawModelData, versionNumber, editFromVersion }) { VersionInfo.propTypes = { rawModelData: PropTypes.object.isRequired, versionNumber: PropTypes.number.isRequired, - editFromVersion: PropTypes.func.isRequired + editFromVersion: PropTypes.func.isRequired, }; function History({ @@ -69,7 +69,7 @@ function History({ renderTitle, renderCore, editFromVersion, - rawModelDataEx + rawModelDataEx, }) { const resetVersions = useApiInvalidateAll("versions"); @@ -85,7 +85,7 @@ function History({ const newRawModelData = { ...rawModelDataEx, - ...versions[currentVersion].data + ...versions[currentVersion].data, }; return ( @@ -141,10 +141,10 @@ History.propTypes = { versions: PropTypes.array.isRequired, renderCore: PropTypes.func.isRequired, renderTitle: PropTypes.func.isRequired, - rawModelDataEx: PropTypes.object.isRequired + rawModelDataEx: PropTypes.object.isRequired, }; -const buildParams = modelInfo => { +const buildParams = (modelInfo) => { const { contentTypeId, id } = modelInfo; return RequestParams.Builder.withEndPointAttrs([contentTypeId, id]).build(); }; @@ -153,13 +153,13 @@ export default compose( withNetworkWrapper([ new NetWrapParam("versions", "all", { addDataToProp: "versions", - params: props => buildParams(props.modelInfo), + params: (props) => buildParams(props.modelInfo), propTypes: { modelInfo: PropTypes.shape({ contentTypeId: PropTypes.number.isRequired, - id: PropTypes.number.isRequired - }).isRequired - } - }) + id: PropTypes.number.isRequired, + }).isRequired, + }, + }), ]) )(History); diff --git a/frontend/src/components/edition/PendingModeration.jsx b/frontend/src/components/edition/PendingModeration.jsx index 9e28d386fd944cc13567d5534311d0776f7ba260..448cc9ec45aa4896c51b05dc2c76b5c72f1cfaef 100644 --- a/frontend/src/components/edition/PendingModeration.jsx +++ b/frontend/src/components/edition/PendingModeration.jsx @@ -13,14 +13,14 @@ import withNetworkWrapper, { NetWrapParam } from "../../hoc/withNetworkWrapper"; import { useApiInvalidateAll } from "../../hooks/wrappers/api"; import useOnComponentUnMount from "../../hooks/useOnComponentUnMount"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ editButton: { display: "block", marginLeft: "auto", marginRight: "auto", marginTop: theme.spacing(2), - marginBottom: theme.spacing(2) - } + marginBottom: theme.spacing(2), + }, })); function PendingModerationInfo({ userCanModerate, moderate, editFromPending }) { @@ -57,7 +57,7 @@ function PendingModerationInfo({ userCanModerate, moderate, editFromPending }) { PendingModerationInfo.propTypes = { userCanModerate: PropTypes.bool.isRequired, moderate: PropTypes.func.isRequired, - editFromPending: PropTypes.func.isRequired + editFromPending: PropTypes.func.isRequired, }; function PendingModeration({ @@ -65,7 +65,7 @@ function PendingModeration({ editFromPendingModeration, renderTitle, renderCore, - userCanModerate + userCanModerate, }) { const resetData = useApiInvalidateAll("pendingModerationObj"); @@ -77,7 +77,7 @@ function PendingModeration({ const pending = pendingModeration[0]; return { ...pending.new_object, - id: pending.object_id + id: pending.object_id, }; }, [pendingModeration]); @@ -110,16 +110,16 @@ function PendingModeration({ PendingModeration.propTypes = { modelInfo: PropTypes.shape({ contentTypeId: PropTypes.number.isRequired, - id: PropTypes.number.isRequired + id: PropTypes.number.isRequired, }).isRequired, editFromPendingModeration: PropTypes.func.isRequired, userCanModerate: PropTypes.bool.isRequired, pendingModeration: PropTypes.array.isRequired, renderTitle: PropTypes.func.isRequired, - renderCore: PropTypes.func.isRequired + renderCore: PropTypes.func.isRequired, }; -const buildParams = modelInfo => { +const buildParams = (modelInfo) => { const { contentTypeId, id } = modelInfo; return RequestParams.Builder.withEndPointAttrs([contentTypeId, id]).build(); }; @@ -128,13 +128,13 @@ export default compose( withNetworkWrapper([ new NetWrapParam("pendingModerationObj", "all", { addDataToProp: "pendingModeration", - params: props => buildParams(props.modelInfo), + params: (props) => buildParams(props.modelInfo), propTypes: { modelInfo: PropTypes.shape({ contentTypeId: PropTypes.number.isRequired, - id: PropTypes.number.isRequired - }).isRequired - } - }) + id: PropTypes.number.isRequired, + }).isRequired, + }, + }), ]) )(PendingModeration); diff --git a/frontend/src/components/edition/fields/BooleanField.jsx b/frontend/src/components/edition/fields/BooleanField.jsx index 1b5efaa581658215309db4633c30ffdaec120731..96e67aa058949575dc60aab74d19e93914c303c2 100644 --- a/frontend/src/components/edition/fields/BooleanField.jsx +++ b/frontend/src/components/edition/fields/BooleanField.jsx @@ -15,10 +15,10 @@ function BooleanField({ label, comment, labelIfTrue, - labelIfFalse + labelIfFalse, }) { const [checked, setCheckedInt, error] = useField(fieldMapping); - const setChecked = useCallback(e => { + const setChecked = useCallback((e) => { setCheckedInt(e.target.checked); }, []); @@ -42,13 +42,13 @@ function BooleanField({ BooleanField.defaultProps = { ...Field.defaultProps, labelIfTrue: "", - labelIfFalse: "" + labelIfFalse: "", }; BooleanField.propTypes = { ...Field.propTypes, labelIfTrue: PropTypes.string, - labelIfFalse: PropTypes.string + labelIfFalse: PropTypes.string, }; export default BooleanField; diff --git a/frontend/src/components/edition/fields/DateField.jsx b/frontend/src/components/edition/fields/DateField.jsx index f668666ec20ff718d06cbabcea5778e3ea4cb582..762269fce58876ab85bfe0eb27ac9de8ea5202fe 100644 --- a/frontend/src/components/edition/fields/DateField.jsx +++ b/frontend/src/components/edition/fields/DateField.jsx @@ -26,7 +26,7 @@ class LocalizedUtils extends DateFnsUtils { * Form field for dates */ function DateField({ fieldMapping, required, label, comment }) { - const getError = useCallback(v => { + const getError = useCallback((v) => { const messages = []; if (required && !v) { messages.push("Date requise."); @@ -36,7 +36,7 @@ function DateField({ fieldMapping, required, label, comment }) { }); const [date, setDateInt, error] = useField(fieldMapping, { serializeFromField: dateToDateStr, - getError + getError, }); return ( @@ -63,11 +63,11 @@ function DateField({ fieldMapping, required, label, comment }) { } DateField.defaultProps = { - ...Field.defaultProps + ...Field.defaultProps, }; DateField.propTypes = { - ...Field.propTypes + ...Field.propTypes, }; export default DateField; diff --git a/frontend/src/components/edition/fields/Field.jsx b/frontend/src/components/edition/fields/Field.jsx index b550f57d14c7a9de36d2c9298944b4b5f011f449..00197f713e5d52cccff25c026015a1863ed72d0c 100644 --- a/frontend/src/components/edition/fields/Field.jsx +++ b/frontend/src/components/edition/fields/Field.jsx @@ -6,13 +6,13 @@ Field.propTypes = { required: PropTypes.bool, // is the field required ? label: PropTypes.string, // text to go along the field comment: PropTypes.string, // text to give more information on what is expected - fieldMapping: PropTypes.string.isRequired // name of the field in the data + fieldMapping: PropTypes.string.isRequired, // name of the field in the data }; Field.defaultProps = { required: false, label: "mon label", - comment: "" + comment: "", }; export default Field; diff --git a/frontend/src/components/edition/fields/FieldWrapper.jsx b/frontend/src/components/edition/fields/FieldWrapper.jsx index 19c2262456181caee41c9b508f758ad9fc2cac05..4539fc08a435b243ab51315d6d7693531b1d0d5b 100644 --- a/frontend/src/components/edition/fields/FieldWrapper.jsx +++ b/frontend/src/components/edition/fields/FieldWrapper.jsx @@ -6,10 +6,10 @@ import FormHelperText from "@material-ui/core/FormHelperText"; import { makeStyles } from "@material-ui/styles"; import CustomError from "../../common/CustomError"; -const useStyles = makeStyles(theme => ({ +const useStyles = makeStyles((theme) => ({ formElement: { - marginBottom: theme.spacing(3) - } + marginBottom: theme.spacing(3), + }, })); /** @@ -40,7 +40,7 @@ FieldWrapper.defaultProps = { label: "LABEL", required: false, errorObj: new CustomError(), - commentText: "" + commentText: "", }; FieldWrapper.propTypes = { @@ -48,7 +48,7 @@ FieldWrapper.propTypes = { commentText: PropTypes.string, required: PropTypes.bool, errorObj: PropTypes.instanceOf(CustomError), // Error state of the field - children: PropTypes.node.isRequired + children: PropTypes.node.isRequired, }; export default FieldWrapper; diff --git a/frontend/src/components/edition/fields/FileField.jsx b/frontend/src/components/edition/fields/FileField.jsx index 19ce33bf3619b9d66c97968fb78317ddd5afa6bf..c02f89226f3fbce0d58129f4ea82b77570438428 100644 --- a/frontend/src/components/edition/fields/FileField.jsx +++ b/frontend/src/components/edition/fields/FileField.jsx @@ -17,7 +17,7 @@ import Field from "./Field"; function FileField({ fieldMapping, required, label, comment, type }) { const id = useId(); - const getError = useCallback(v => { + const getError = useCallback((v) => { const messages = []; if (typeof v === "undefined" || v === "") { messages.push("Aucun fichier n'est sélectioné."); @@ -67,7 +67,7 @@ function FileField({ fieldMapping, required, label, comment, type }) { FileField.propTypes = { ...Field.propTypes, - type: PropTypes.oneOf(["picture", "file"]).isRequired + type: PropTypes.oneOf(["picture", "file"]).isRequired, }; export default FileField; diff --git a/frontend/src/components/edition/fields/HiddenField.jsx b/frontend/src/components/edition/fields/HiddenField.jsx index 1a43b8fed33ee7d4da3164c5065c07f8119736b4..df55c078a59fa5db027efa2c6a4fdedb2a6db97d 100644 --- a/frontend/src/components/edition/fields/HiddenField.jsx +++ b/frontend/src/components/edition/fields/HiddenField.jsx @@ -9,7 +9,7 @@ function HiddenField({ fieldMapping }) { } HiddenField.propTypes = { - fieldMapping: PropTypes.string.isRequired + fieldMapping: PropTypes.string.isRequired, }; export default HiddenField; diff --git a/frontend/src/components/edition/fields/MarkdownField.jsx b/frontend/src/components/edition/fields/MarkdownField.jsx index 2e60a79576ee61d7f5b2f54225b76ddf6d1d06a2..32b347292ec6775b3dd8ae1393e79da13bdd4a86 100644 --- a/frontend/src/components/edition/fields/MarkdownField.jsx +++ b/frontend/src/components/edition/fields/MarkdownField.jsx @@ -22,7 +22,7 @@ const defaultNullValue = ""; * A `maxLength` can be set to limit the length of the text. */ function MarkdownField({ fieldMapping, required, label, comment, maxLength }) { - const getError = useCallback(value => { + const getError = useCallback((value) => { const messages = []; if (required && (value === "" || value === null)) { messages.push("Ce champ est requis mais il est vide."); @@ -36,10 +36,10 @@ function MarkdownField({ fieldMapping, required, label, comment, maxLength }) { const [valueToDisplay, setValue, error] = useField(fieldMapping, { defaultNullValue, - getError + getError, }); - const handleChangeValue = useCallback(e => { + const handleChangeValue = useCallback((e) => { let { value } = e.target; if (maxLength && value.length > maxLength + 1) { @@ -100,12 +100,12 @@ function MarkdownField({ fieldMapping, required, label, comment, maxLength }) { MarkdownField.defaultProps = { ...Field.defaultProps, - maxLength: 0 + maxLength: 0, }; MarkdownField.propTypes = { ...Field.propTypes, - maxLength: PropTypes.number + maxLength: PropTypes.number, }; export default MarkdownField; diff --git a/frontend/src/components/edition/fields/MultiSelectField.jsx b/frontend/src/components/edition/fields/MultiSelectField.jsx index d0875191f581c5fd113c78934d16d6a72c1cecad..5f8f4bed3b3ee77248fec5cf48f297690af47a92 100644 --- a/frontend/src/components/edition/fields/MultiSelectField.jsx +++ b/frontend/src/components/edition/fields/MultiSelectField.jsx @@ -17,11 +17,11 @@ import FieldWrapper from "./FieldWrapper"; */ function MultiSelectField({ fieldMapping, required, label, comment, options }) { const optionsByValue = useMemo( - () => new Map(options.map(opt => [opt.value, opt.label])), + () => new Map(options.map((opt) => [opt.value, opt.label])), [] ); - const getError = useCallback(v => { + const getError = useCallback((v) => { const messages = []; if (required && v.length === 0) { messages.push("Ce champ est requis."); @@ -30,10 +30,10 @@ function MultiSelectField({ fieldMapping, required, label, comment, options }) { }, []); const [value, setValueInt, error] = useField(fieldMapping, { getError }); - const setValue = useCallback(e => setValueInt(e.target.value), []); + const setValue = useCallback((e) => setValueInt(e.target.value), []); const renderSelected = useCallback( - selected => selected.map(el => optionsByValue.get(el)).join(", "), + (selected) => selected.map((el) => optionsByValue.get(el)).join(", "), [] ); @@ -46,7 +46,7 @@ function MultiSelectField({ fieldMapping, required, label, comment, options }) { multiple renderValue={renderSelected} > - {options.map(el => ( + {options.map((el) => ( -1} /> @@ -76,7 +76,7 @@ function MultiSelectField({ fieldMapping, required, label, comment, options }) { } MultiSelectField.defaultProps = { - ...Field.defaultProps + ...Field.defaultProps, }; MultiSelectField.propTypes = { @@ -86,11 +86,11 @@ MultiSelectField.propTypes = { label: PropTypes.string.isRequired, value: PropTypes.oneOfType([ PropTypes.number.isRequired, - PropTypes.string.isRequired + PropTypes.string.isRequired, ]), - disabled: PropTypes.bool + disabled: PropTypes.bool, }) - ) + ), }; export default MultiSelectField; diff --git a/frontend/src/components/edition/fields/NumberField.jsx b/frontend/src/components/edition/fields/NumberField.jsx index 23529522c61ad173b1f5c9c7108c14cbc517d50a..6273a793bf243a43e51a161f205b6001f212d5b2 100644 --- a/frontend/src/components/edition/fields/NumberField.jsx +++ b/frontend/src/components/edition/fields/NumberField.jsx @@ -18,9 +18,9 @@ function NumberField({ label, comment, minValue, - maxValue + maxValue, }) { - const getError = useCallback(v => { + const getError = useCallback((v) => { const messages = []; if (required && (v === "" || v === null)) { messages.push("Ce champ est requis mais il est vide."); @@ -34,7 +34,7 @@ function NumberField({ return new CustomError(messages); }, []); - const serializeFromField = useCallback(v => { + const serializeFromField = useCallback((v) => { const parsed = parseFloat(v); if (isNaN(parsed)) return null; return parsed; @@ -43,10 +43,10 @@ function NumberField({ const [number, setNumberInt, error] = useField(fieldMapping, { defaultNullValue: null, serializeFromField, - getError + getError, }); - const setNumber = useCallback(e => { + const setNumber = useCallback((e) => { const v = e.target.value; const regex = /[^\d.-]*/gi; setNumberInt(v.replace(regex, "")); @@ -84,13 +84,13 @@ function NumberField({ NumberField.defaultProps = { ...Field.defaultProps, maxValue: null, - minValue: null + minValue: null, }; NumberField.propTypes = { ...Field.propTypes, maxValue: PropTypes.number, - minValue: PropTypes.number + minValue: PropTypes.number, }; export default NumberField; diff --git a/frontend/src/components/edition/fields/SelectField.jsx b/frontend/src/components/edition/fields/SelectField.jsx index 874461439d931ae33a112bb8cc41b287033fb273..4bbf39e9953f854ebe513ac7f1b130f455385ef5 100644 --- a/frontend/src/components/edition/fields/SelectField.jsx +++ b/frontend/src/components/edition/fields/SelectField.jsx @@ -14,7 +14,7 @@ import useField from "../../../hooks/useField"; * Form field for select (not multiple, use the other one for such thing). */ function SelectField({ fieldMapping, required, label, comment, options }) { - const getError = useCallback(v => { + const getError = useCallback((v) => { const messages = []; if (required && (v === null || typeof v === "undefined")) { @@ -24,12 +24,12 @@ function SelectField({ fieldMapping, required, label, comment, options }) { }, []); const [value, setValueInt, error] = useField(fieldMapping, { getError }); - const setValue = useCallback(e => setValueInt(e.target.value), []); + const setValue = useCallback((e) => setValueInt(e.target.value), []); const RenderComp = () => options.length < 10 ? ( setMajor(e.target.value)} + onChange={(e) => setMajor(e.target.value)} inputProps={{ - id: "major-select" + id: "major-select", }} > Pas de filtre {univMajorMinors - .filter(el => el.major !== null) - .map(el => ( + .filter((el) => el.major !== null) + .map((el) => ( {el.major} @@ -85,15 +86,15 @@ function PreviousExchangesTab({