From a474e43c0bda86c939f969001caa0f7c3f6f9c16 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?L=C3=A9o=20Banno-Cloutier?=
 <leo.banno-cloutier@savoirfairelinux.com>
Date: Mon, 12 Jun 2023 13:37:23 -0400
Subject: [PATCH] jams-react-client: fix various warnings and remove
 eslint-disable

Change-Id: Idc1900eb12c14151ea5cd3354530c294a855eaef
---
 jams-react-client/.env                        |  1 -
 jams-react-client/package.json                |  2 +-
 .../components/devicesStyle.js                |  1 -
 .../components/sidebarStyle.js                |  1 -
 .../src/components/Devices/Devices.js         |  6 +++---
 .../src/components/Drawer/Drawer.js           |  2 +-
 .../src/components/Footer/Footer.js           |  5 +----
 .../LanguagePicker/LanguagePicker.js          | 11 +++++------
 .../src/components/Sidebar/Sidebar.js         |  3 +--
 jams-react-client/src/layouts/BaseLayout.js   |  8 ++------
 jams-react-client/src/layouts/ListLayout.js   |  8 ++------
 .../src/views/Blueprints/Blueprints.js        |  7 +++----
 .../src/views/Contacts/Contacts.js            |  6 +++---
 .../src/views/Groups/EditGroup.js             | 10 ++++------
 jams-react-client/src/views/Groups/Groups.js  |  1 -
 .../src/views/Settings/Settings.js            | 19 -------------------
 .../views/UserProfile/DisplayUserProfile.js   |  2 +-
 .../UserProfile/EditCreateUserProfile.js      |  6 +++---
 .../src/views/UserProfile/UserProfile.js      |  4 +---
 jams-react-client/src/views/Users/Users.js    |  7 +------
 20 files changed, 32 insertions(+), 78 deletions(-)
 delete mode 100644 jams-react-client/.env

diff --git a/jams-react-client/.env b/jams-react-client/.env
deleted file mode 100644
index b885521b..00000000
--- a/jams-react-client/.env
+++ /dev/null
@@ -1 +0,0 @@
-NODE_PATH=./src
diff --git a/jams-react-client/package.json b/jams-react-client/package.json
index 456e7b1c..a1e773da 100644
--- a/jams-react-client/package.json
+++ b/jams-react-client/package.json
@@ -34,7 +34,7 @@
     "yup": "^0.29.3"
   },
   "scripts": {
-    "start": "export SET NODE_OPTIONS=--openssl-legacy-provider && NODE_PATH=./src react-scripts start",
+    "start": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
     "build": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build && ./node_modules/.bin/i18next-scanner",
     "test": "react-scripts test --env=jsdom",
     "eject": "react-scripts eject",
diff --git a/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js b/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js
index 710cc0fb..e3ef2f6f 100644
--- a/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js
+++ b/jams-react-client/src/assets/jss/material-dashboard-react/components/devicesStyle.js
@@ -1,6 +1,5 @@
 import {
   defaultFont,
-  primaryColor,
   dangerColor,
   grayColor,
   infoColor,
diff --git a/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js b/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js
index eb2a6ca5..3866e6b4 100644
--- a/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js
+++ b/jams-react-client/src/assets/jss/material-dashboard-react/components/sidebarStyle.js
@@ -10,7 +10,6 @@ import {
   warningColor,
   dangerColor,
   whiteColor,
-  grayColor,
   blackColor,
   hexToRgb,
 } from "assets/jss/material-dashboard-react.js";
diff --git a/jams-react-client/src/components/Devices/Devices.js b/jams-react-client/src/components/Devices/Devices.js
index 3a2d3ed7..cbeef3ce 100755
--- a/jams-react-client/src/components/Devices/Devices.js
+++ b/jams-react-client/src/components/Devices/Devices.js
@@ -58,7 +58,7 @@ export default function Devices(props) {
       if (auth.hasAdminScope()) {
         axios(configApiCall(api_path_get_admin_devices, "GET", userData, null))
           .then((response) => {
-            if (response.data.length == 0) {
+            if (response.data.length === 0) {
               setDevices([]);
             } else {
               var resultSet = JSON.parse(
@@ -77,7 +77,7 @@ export default function Devices(props) {
       } else {
         axios(configApiCall(api_path_get_auth_devices, "GET", null, null))
           .then((response) => {
-            if (response.data.length == 0) {
+            if (response.data.length === 0) {
               setDevices([]);
             } else {
               var resultSet = JSON.parse(
@@ -94,7 +94,7 @@ export default function Devices(props) {
           });
       }
     });
-  }, [selectedDevice]);
+  }, [history, selectedDevice, userData]);
 
   function getDeviceStatus(device) {
     if (!device.revoked) {
diff --git a/jams-react-client/src/components/Drawer/Drawer.js b/jams-react-client/src/components/Drawer/Drawer.js
index f063cb9c..d1f6ab5e 100644
--- a/jams-react-client/src/components/Drawer/Drawer.js
+++ b/jams-react-client/src/components/Drawer/Drawer.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useCallback } from "react";
+import React, { useCallback } from "react";
 import clsx from "clsx";
 import { makeStyles } from "@material-ui/core/styles";
 import CustomInput from "components/CustomInput/CustomInput.js";
diff --git a/jams-react-client/src/components/Footer/Footer.js b/jams-react-client/src/components/Footer/Footer.js
index 8dc03ebc..bade958c 100755
--- a/jams-react-client/src/components/Footer/Footer.js
+++ b/jams-react-client/src/components/Footer/Footer.js
@@ -1,10 +1,6 @@
-/*eslint-disable*/
 import React from "react";
-import PropTypes from "prop-types";
 // @material-ui/core components
 import { makeStyles } from "@material-ui/core/styles";
-import ListItem from "@material-ui/core/ListItem";
-import List from "@material-ui/core/List";
 // core components
 import styles from "assets/jss/material-dashboard-react/components/footerStyle.js";
 
@@ -24,6 +20,7 @@ export default function Footer(props) {
             <a
               href="https://savoirfairelinux.com"
               target="_blank"
+              rel="noopener noreferrer"
               className={classes.a}
             >
               Savoir-faire Linux Inc.
diff --git a/jams-react-client/src/components/LanguagePicker/LanguagePicker.js b/jams-react-client/src/components/LanguagePicker/LanguagePicker.js
index 826b6fda..bafb5212 100644
--- a/jams-react-client/src/components/LanguagePicker/LanguagePicker.js
+++ b/jams-react-client/src/components/LanguagePicker/LanguagePicker.js
@@ -36,16 +36,15 @@ export default function LanguagePicker(props) {
           { code: "en", name: "English" },
         ];
 
-        let exists = false;
-        translates_languages.map((option) => {
-          if (option.code === language) {
-            exists = true;
-          }
-        });
+        const exists = translates_languages
+          .map((option) => option.code)
+          .includes(language);
+
         if (!exists) {
           setLanguage("en");
           i18n.changeLanguage("en");
         }
+
         setLanguages(translates_languages);
       });
   }, [language]);
diff --git a/jams-react-client/src/components/Sidebar/Sidebar.js b/jams-react-client/src/components/Sidebar/Sidebar.js
index 8b35ed69..06f49395 100755
--- a/jams-react-client/src/components/Sidebar/Sidebar.js
+++ b/jams-react-client/src/components/Sidebar/Sidebar.js
@@ -1,4 +1,3 @@
-/*eslint-disable*/
 import React, { useEffect, useState } from "react";
 import { Link, useHistory } from "react-router-dom";
 import classNames from "classnames";
@@ -46,7 +45,7 @@ export default function Sidebar(props) {
   function activeRoute(routeName) {
     return window.location.href.indexOf(routeName) > -1 ? true : false;
   }
-  const { color, logo, image, logoText, routes } = props;
+  const { color, logo, image, routes } = props;
 
   var brand = (
     <Link to={"/"}>
diff --git a/jams-react-client/src/layouts/BaseLayout.js b/jams-react-client/src/layouts/BaseLayout.js
index a2678595..31478b81 100644
--- a/jams-react-client/src/layouts/BaseLayout.js
+++ b/jams-react-client/src/layouts/BaseLayout.js
@@ -1,5 +1,4 @@
 import React, { useEffect, useState } from "react";
-import { Switch, Route, Redirect } from "react-router-dom";
 // creates a beautiful scrollbar
 import PerfectScrollbar from "perfect-scrollbar";
 import "perfect-scrollbar/css/perfect-scrollbar.css";
@@ -52,9 +51,6 @@ export default function Admin(props) {
   // ref to help us initialize PerfectScrollbar on windows devices
   const mainPanel = React.createRef();
   // states and functions
-  const [image, setImage] = useState(bgImage);
-  const [color, setColor] = useState("blue");
-  const [fixedClasses, setFixedClasses] = useState("dropdown");
   const [mobileOpen, setMobileOpen] = useState(false);
   const [open, setOpen] = useState(false);
   const [message, setMessage] = useState(false);
@@ -242,10 +238,10 @@ export default function Admin(props) {
         routes={Routes}
         logoText={"Jams"}
         logo={logo}
-        image={image}
+        image={bgImage}
         handleDrawerToggle={handleDrawerToggle}
         open={mobileOpen}
-        color={color}
+        color="blue"
         handleQuery={handleQuery}
         updating={updating}
         snackbarMessage={snackbarMessage}
diff --git a/jams-react-client/src/layouts/ListLayout.js b/jams-react-client/src/layouts/ListLayout.js
index 74dc94e0..9d35c245 100644
--- a/jams-react-client/src/layouts/ListLayout.js
+++ b/jams-react-client/src/layouts/ListLayout.js
@@ -1,5 +1,4 @@
 import React, { useEffect, useState } from "react";
-import { Switch, Route, Redirect } from "react-router-dom";
 // creates a beautiful scrollbar
 import PerfectScrollbar from "perfect-scrollbar";
 import "perfect-scrollbar/css/perfect-scrollbar.css";
@@ -53,9 +52,6 @@ export default function Admin(props) {
   // ref to help us initialize PerfectScrollbar on windows devices
   const mainPanel = React.createRef();
   // states and functions
-  const [image, setImage] = useState(bgImage);
-  const [color, setColor] = useState("blue");
-  const [fixedClasses, setFixedClasses] = useState("dropdown");
   const [mobileOpen, setMobileOpen] = useState(false);
   const [open, setOpen] = useState(false);
   const [message, setMessage] = useState(false);
@@ -245,10 +241,10 @@ export default function Admin(props) {
         routes={Routes}
         logoText={"Jams"}
         logo={logo}
-        image={image}
+        image={bgImage}
         handleDrawerToggle={handleDrawerToggle}
         open={mobileOpen}
-        color={color}
+        color="blue"
         handleQuery={handleQuery}
         updating={updating}
         snackbarMessage={snackbarMessage}
diff --git a/jams-react-client/src/views/Blueprints/Blueprints.js b/jams-react-client/src/views/Blueprints/Blueprints.js
index 4eb1f5d9..8e944601 100644
--- a/jams-react-client/src/views/Blueprints/Blueprints.js
+++ b/jams-react-client/src/views/Blueprints/Blueprints.js
@@ -35,8 +35,6 @@ import LinearProgress from "@material-ui/core/LinearProgress";
 
 import headerLinksStyle from "assets/jss/material-dashboard-react/components/headerLinksStyle.js";
 
-import Blueprint from "views/Blueprint/Blueprint";
-
 import Dialog from "@material-ui/core/Dialog";
 import DialogActions from "@material-ui/core/DialogActions";
 import DialogContent from "@material-ui/core/DialogContent";
@@ -135,7 +133,7 @@ export default function Blueprints() {
     return () => {
       clearInterval(timer);
     };
-  }, [open, openRemoveDialog]);
+  }, [history, open, openRemoveDialog]);
 
   function redirectToBlueprint(e, blueprintNameRedirect) {
     e.preventDefault();
@@ -397,7 +395,8 @@ export default function Blueprints() {
                     </h3>
                     <ul>
                       <li>
-                        {JSON.parse(blueprint.policyData).rendezVous == true ? (
+                        {JSON.parse(blueprint.policyData).rendezVous ===
+                        true ? (
                           <p>
                             <GroupIcon
                               fontSize="small"
diff --git a/jams-react-client/src/views/Contacts/Contacts.js b/jams-react-client/src/views/Contacts/Contacts.js
index 65d04d00..c169a52e 100644
--- a/jams-react-client/src/views/Contacts/Contacts.js
+++ b/jams-react-client/src/views/Contacts/Contacts.js
@@ -1,5 +1,5 @@
 import React, { useEffect, useState } from "react";
-import { Link, useHistory } from "react-router-dom";
+import { useHistory } from "react-router-dom";
 // @material-ui/core components
 import { makeStyles } from "@material-ui/core/styles";
 // core components
@@ -147,7 +147,7 @@ export default function Users(props) {
                     at the moment the admin sees his contacts in each user profile he visits
                 */
           let orginalContacts = response.data;
-          orginalContacts.map((contact) => {
+          for (const contact of orginalContacts) {
             contact.display = "";
             axios(
               configApiCall(
@@ -171,7 +171,7 @@ export default function Users(props) {
                 contact.organization = response.data.organization;
               });
             });
-          });
+          }
           setContacts(orginalContacts);
           setLoading(false);
         })
diff --git a/jams-react-client/src/views/Groups/EditGroup.js b/jams-react-client/src/views/Groups/EditGroup.js
index a31cab71..0c0c24e8 100644
--- a/jams-react-client/src/views/Groups/EditGroup.js
+++ b/jams-react-client/src/views/Groups/EditGroup.js
@@ -146,11 +146,9 @@ export default function EditGroup(props) {
         axios(configApiCall(api_path_blueprints + "?name=*", "GET", null, null))
           .then((response) => {
             setBlueprints(response.data);
-            let index = 0;
-            response.data.map((blueprint) => {
-              if (blueprint.name == group["blueprint"])
-                setSelectedBlueprint({ value: index, label: blueprint.name });
-              index += 1;
+            response.data.forEach((blueprint, i) => {
+              if (blueprint.name === group["blueprint"])
+                setSelectedBlueprint({ value: i, label: blueprint.name });
             });
           })
           .catch((error) => {
@@ -427,7 +425,7 @@ export default function EditGroup(props) {
                             onClick={() => {
                               updateGroup();
                             }}
-                            disabled={groupNameExits || name == newName}
+                            disabled={groupNameExits || name === newName}
                           >
                             <SaveIcon />
                           </IconButton>
diff --git a/jams-react-client/src/views/Groups/Groups.js b/jams-react-client/src/views/Groups/Groups.js
index f97d87c9..ac133643 100644
--- a/jams-react-client/src/views/Groups/Groups.js
+++ b/jams-react-client/src/views/Groups/Groups.js
@@ -36,7 +36,6 @@ import {
 } from "globalUrls";
 
 import AddCircleOutlineIcon from "@material-ui/icons/AddCircleOutline";
-import EditGroup from "views/Groups/EditGroup";
 
 import FormControl from "@material-ui/core/FormControl";
 import Input from "@material-ui/core/Input";
diff --git a/jams-react-client/src/views/Settings/Settings.js b/jams-react-client/src/views/Settings/Settings.js
index d58e0d1b..60b331e1 100644
--- a/jams-react-client/src/views/Settings/Settings.js
+++ b/jams-react-client/src/views/Settings/Settings.js
@@ -54,25 +54,6 @@ function Alert(props) {
   return <MuiAlert elevation={6} variant="filled" {...props} />;
 }
 
-const styles = {
-  cardCategoryWhite: {
-    color: "rgba(255,255,255,.62)",
-    margin: "0",
-    fontSize: "14px",
-    marginTop: "0",
-    marginBottom: "0",
-  },
-  cardTitleWhite: {
-    color: "#FFFFFF",
-    marginTop: "0px",
-    minHeight: "auto",
-    fontWeight: "300",
-    fontFamily: "'Roboto', 'Helvetica', 'Arial', sans-serif",
-    marginBottom: "3px",
-    textDecoration: "none",
-  },
-};
-
 export default function Settings(props) {
   const [value, setValue] = useState(0);
   const [error, setError] = useState(false);
diff --git a/jams-react-client/src/views/UserProfile/DisplayUserProfile.js b/jams-react-client/src/views/UserProfile/DisplayUserProfile.js
index ed7b2b0d..519ed68c 100644
--- a/jams-react-client/src/views/UserProfile/DisplayUserProfile.js
+++ b/jams-react-client/src/views/UserProfile/DisplayUserProfile.js
@@ -450,7 +450,7 @@ export default function DisplayUserProfile(props) {
     return () => {
       clearInterval(timer);
     };
-  }, []);
+  }, [history, props.username]);
 
   const getUserStatus = () => {
     if (revoked === false) {
diff --git a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js
index fedd866d..58b3e3d6 100644
--- a/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js
+++ b/jams-react-client/src/views/UserProfile/EditCreateUserProfile.js
@@ -505,16 +505,16 @@ export default function EditCreateUserProfile(props) {
       )
     ),
     faxNumber: Yup.string().matches(
-      /^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
+      /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
       i18next.t("fax_not_valid", "Fax number not valid!")
     ),
     phoneNumber: Yup.string().matches(
-      /^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
+      /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
       i18next.t("phone_not_valid", "Phone number not valid!")
     ),
     phoneNumberExtension: Yup.number().positive().integer(),
     mobileNumber: Yup.string().matches(
-      /^(\+\d{1,2}\s?)?1?\-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
+      /^(\+\d{1,2}\s?)?1?-?\.?\s?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4}$/,
       i18next.t("mobile_not_valid", "Mobile number not valid!")
     ),
   });
diff --git a/jams-react-client/src/views/UserProfile/UserProfile.js b/jams-react-client/src/views/UserProfile/UserProfile.js
index 10106460..a84be1bb 100755
--- a/jams-react-client/src/views/UserProfile/UserProfile.js
+++ b/jams-react-client/src/views/UserProfile/UserProfile.js
@@ -19,8 +19,6 @@ import DisplayUserProfile from "./DisplayUserProfile";
 
 import i18next from "i18next";
 
-import auth from "auth.js";
-
 function TabPanel(props) {
   const { children, value, index, ...other } = props;
 
@@ -68,7 +66,7 @@ export default function UserProfile(props) {
     if (props.username === "null") {
       history.push("/");
     }
-  }, []);
+  }, [history, props.username]);
 
   return (
     <div>
diff --git a/jams-react-client/src/views/Users/Users.js b/jams-react-client/src/views/Users/Users.js
index 65a0429d..15723108 100644
--- a/jams-react-client/src/views/Users/Users.js
+++ b/jams-react-client/src/views/Users/Users.js
@@ -14,12 +14,10 @@ import Card from "components/Card/Card.js";
 import CardAvatar from "components/Card/CardAvatar.js";
 import CardBody from "components/Card/CardBody.js";
 
-import UserProfile from "views/UserProfile/UserProfile.js";
 import InfoIcon from "@material-ui/icons/Info";
 import BusinessOutlinedIcon from "@material-ui/icons/BusinessOutlined";
 import Search from "@material-ui/icons/Search";
 import Checkbox from "@material-ui/core/Checkbox";
-import FormGroup from "@material-ui/core/FormGroup";
 import FormControlLabel from "@material-ui/core/FormControlLabel";
 import axios from "axios";
 import configApiCall from "api.js";
@@ -28,7 +26,6 @@ import { api_path_get_user_directory_search } from "globalUrls";
 import AddCircleOutlineIcon from "@material-ui/icons/AddCircleOutline";
 import jami from "assets/img/faces/jami.png";
 import noProfilePicture from "assets/img/faces/no-profile-picture.png";
-import EditCreateUserProfile from "views/UserProfile/EditCreateUserProfile";
 import LinearProgress from "@material-ui/core/LinearProgress";
 import headerLinksStyle from "assets/jss/material-dashboard-react/components/headerLinksStyle.js";
 import { debounce } from "lodash";
@@ -78,8 +75,6 @@ export default function Users(props) {
   const [users, setUsers] = useState([]);
   const [noUsersFound, setNoUsersFound] = useState(false);
   const [noMatchFound, setNoMatchFound] = useState(false);
-  const [selectedUsername, setSelectedUsername] = useState("");
-  const [createUser, setCreateUser] = useState(false);
   const [loading, setLoading] = useState(false);
   const [progress, setProgress] = useState(0);
   const [showRevokedUsers, setShowRevokedUsers] = useState(false);
@@ -128,7 +123,7 @@ export default function Users(props) {
     return () => {
       clearInterval(timer);
     };
-  }, []);
+  }, [history]);
 
   const searchUsers = (value, page = "1") => {
     setSelectedPage(page);
-- 
GitLab