From 726e2fc6c17d18c779b8efdc24379ba1fa0e9f9c Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 20 Aug 2024 10:34:29 -0700 Subject: [PATCH 1/8] Remove unused lines from NetworkService --- Client/src/Utils/NetworkService.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Client/src/Utils/NetworkService.js b/Client/src/Utils/NetworkService.js index 21f1c1845..32fcb6aa8 100644 --- a/Client/src/Utils/NetworkService.js +++ b/Client/src/Utils/NetworkService.js @@ -1,7 +1,6 @@ import axios from "axios"; -import { clearAuthState } from "../Features/Auth/authSlice"; const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL; - +import { logger } from "./Logger"; class NetworkService { constructor(store) { this.store = store; @@ -9,10 +8,9 @@ class NetworkService { this.axiosInstance.interceptors.response.use( (response) => response, (error) => { - console.error(error); + logger.error(error); if (error.response && error.response.status === 401) { - console.log("Invalid token revoked"); - networkService; + logger.error("Invalid token received"); } return Promise.reject(error); } From 1076c2377c92c0367d506fb6058bef5e005ba36a Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 20 Aug 2024 10:42:20 -0700 Subject: [PATCH 2/8] Add proptypes and missing dependency to Register --- Client/src/Pages/Auth/Register/Register.jsx | 31 ++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Client/src/Pages/Auth/Register/Register.jsx b/Client/src/Pages/Auth/Register/Register.jsx index 225fb16f0..046aad64b 100644 --- a/Client/src/Pages/Auth/Register/Register.jsx +++ b/Client/src/Pages/Auth/Register/Register.jsx @@ -69,6 +69,11 @@ const LandingPage = ({ isAdmin, onSignup }) => { ); }; +LandingPage.propTypes = { + isAdmin: PropTypes.bool, + onSignup: PropTypes.func, +}; + /** * Renders the first step of the sign up process. * @@ -152,6 +157,14 @@ const StepOne = ({ form, errors, onSubmit, onChange, onBack }) => { ); }; +StepOne.propTypes = { + form: PropTypes.object, + errors: PropTypes.object, + onSubmit: PropTypes.func, + onChange: PropTypes.func, + onBack: PropTypes.func, +}; + /** * Renders the second step of the sign up process. * @@ -224,6 +237,14 @@ const StepTwo = ({ form, errors, onSubmit, onChange, onBack }) => { ); }; +StepTwo.propTypes = { + form: PropTypes.object, + errors: PropTypes.object, + onSubmit: PropTypes.func, + onChange: PropTypes.func, + onBack: PropTypes.func, +}; + /** * Renders the third step of the sign up process. * @@ -369,6 +390,14 @@ const StepThree = ({ form, errors, onSubmit, onChange, onBack }) => { ); }; +StepThree.propTypes = { + form: PropTypes.object, + errors: PropTypes.object, + onSubmit: PropTypes.func, + onChange: PropTypes.func, + onBack: PropTypes.func, +}; + const Register = ({ isAdmin }) => { const dispatch = useDispatch(); const navigate = useNavigate(); @@ -407,7 +436,7 @@ const Register = ({ isAdmin }) => { } }; fetchInvite(); - }, [token]); + }, [token, form]); /** * Validates the form data against the validation schema. From b1a0b11bbc42e3b9d8276367cce5fe21e8cb986b Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 20 Aug 2024 10:44:03 -0700 Subject: [PATCH 3/8] Escaped apostrophe --- Client/src/Pages/Auth/CheckEmail.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/src/Pages/Auth/CheckEmail.jsx b/Client/src/Pages/Auth/CheckEmail.jsx index 0ede66831..4a0daf68a 100644 --- a/Client/src/Pages/Auth/CheckEmail.jsx +++ b/Client/src/Pages/Auth/CheckEmail.jsx @@ -145,7 +145,7 @@ const CheckEmail = () => { }} /> - Didn't receive the email?{" "} + Didn't receive the email?{" "} Date: Tue, 20 Aug 2024 10:44:35 -0700 Subject: [PATCH 4/8] Escaped apostrophe --- Client/src/Pages/Auth/ForgotPassword.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/src/Pages/Auth/ForgotPassword.jsx b/Client/src/Pages/Auth/ForgotPassword.jsx index c51417c91..06afb05fa 100644 --- a/Client/src/Pages/Auth/ForgotPassword.jsx +++ b/Client/src/Pages/Auth/ForgotPassword.jsx @@ -131,7 +131,7 @@ const ForgotPassword = () => { Forgot password? - No worries, we'll send you reset instructions. + No worries, we'll send you reset instructions. From 7a8ea60e659f9afb1b67b66ff55b62fbf9aad1e1 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 20 Aug 2024 10:47:27 -0700 Subject: [PATCH 5/8] Escaped apostrophe --- Client/src/Pages/Auth/Login.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Client/src/Pages/Auth/Login.jsx b/Client/src/Pages/Auth/Login.jsx index 79e8d7e12..00de688f6 100644 --- a/Client/src/Pages/Auth/Login.jsx +++ b/Client/src/Pages/Auth/Login.jsx @@ -427,7 +427,9 @@ const Login = () => { )} - Don't have an account? — + + Don't have an account? — + Date: Tue, 20 Aug 2024 10:54:28 -0700 Subject: [PATCH 6/8] Remove unused imports, add missing dependencies --- Client/src/Pages/Home/index.css | 1 - Client/src/Pages/Home/index.jsx | 16 ---------------- .../src/Pages/Incidents/IncidentTable/index.jsx | 2 +- .../CreateMaintenanceWindow/index.jsx | 2 +- Client/src/Pages/Maintenance/index.jsx | 3 --- .../src/Pages/Monitors/CreateMonitor/index.jsx | 2 +- .../Monitors/Details/PaginationTable/index.jsx | 2 +- Client/src/Pages/Monitors/Details/index.jsx | 13 ++++++------- Client/src/Pages/Monitors/index.jsx | 1 - Client/src/Pages/PageSpeed/Configure/index.jsx | 2 +- 10 files changed, 11 insertions(+), 33 deletions(-) delete mode 100644 Client/src/Pages/Home/index.css delete mode 100644 Client/src/Pages/Home/index.jsx diff --git a/Client/src/Pages/Home/index.css b/Client/src/Pages/Home/index.css deleted file mode 100644 index fdb4ddd1b..000000000 --- a/Client/src/Pages/Home/index.css +++ /dev/null @@ -1 +0,0 @@ -/* Home Page Styles*/ \ No newline at end of file diff --git a/Client/src/Pages/Home/index.jsx b/Client/src/Pages/Home/index.jsx deleted file mode 100644 index 161650512..000000000 --- a/Client/src/Pages/Home/index.jsx +++ /dev/null @@ -1,16 +0,0 @@ -import DropdownTeamMember from "../../Components/DropdownTeamMember"; -import Search from "../../Components/Search"; -import "./index.css"; -import DashboardMenu from "../../Components/DashboardMenu"; -import Integrations from "../../Components/Integrations"; - -const Home = () => { - const token = localStorage.getItem("token"); - return ( - <> -
Home
- - ); -}; - -export default Home; diff --git a/Client/src/Pages/Incidents/IncidentTable/index.jsx b/Client/src/Pages/Incidents/IncidentTable/index.jsx index 705daa70c..741ee144a 100644 --- a/Client/src/Pages/Incidents/IncidentTable/index.jsx +++ b/Client/src/Pages/Incidents/IncidentTable/index.jsx @@ -36,7 +36,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => { ...paginationController, page: 0, }); - }, [filter, selectedMonitor]); + }, [filter, selectedMonitor, paginationController]); useEffect(() => { const fetchPage = async () => { diff --git a/Client/src/Pages/Maintenance/CreateMaintenanceWindow/index.jsx b/Client/src/Pages/Maintenance/CreateMaintenanceWindow/index.jsx index 8fff6e4a1..d207bfc98 100644 --- a/Client/src/Pages/Maintenance/CreateMaintenanceWindow/index.jsx +++ b/Client/src/Pages/Maintenance/CreateMaintenanceWindow/index.jsx @@ -1,6 +1,6 @@ import { Box, Stack, Typography } from "@mui/material"; import "./index.css"; -import React, { useState } from "react"; +import { useState } from "react"; import Button from "../../../Components/Button"; import Back from "../../../assets/icons/left-arrow-long.svg?react"; import Select from "../../../Components/Inputs/Select"; diff --git a/Client/src/Pages/Maintenance/index.jsx b/Client/src/Pages/Maintenance/index.jsx index c589552f7..e9c28d905 100644 --- a/Client/src/Pages/Maintenance/index.jsx +++ b/Client/src/Pages/Maintenance/index.jsx @@ -1,10 +1,7 @@ -import { useTheme } from "@emotion/react"; import Fallback from "../../Components/Fallback"; import "./index.css"; const Maintenance = () => { - const theme = useTheme(); - return (
{ ...paginationController, page: 0, }); - }, [dateRange]); + }, [dateRange, paginationController]); useEffect(() => { const fetchPage = async () => { diff --git a/Client/src/Pages/Monitors/Details/index.jsx b/Client/src/Pages/Monitors/Details/index.jsx index 7a04a24e2..b636444bd 100644 --- a/Client/src/Pages/Monitors/Details/index.jsx +++ b/Client/src/Pages/Monitors/Details/index.jsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState, useCallback } from "react"; +import { useEffect, useState, useCallback } from "react"; import PropTypes from "prop-types"; import { Box, Skeleton, Stack, Typography, useTheme } from "@mui/material"; import { useSelector } from "react-redux"; @@ -144,15 +144,14 @@ const DetailsPage = () => { useEffect(() => { const fetchCertificate = async () => { try { - const res = await networkService.getCertificateExpiry( - authToken, - monitorId - ); - setCertificateExpiry(res?.data?.data?.certificateDate ?? "N/A"); + const res = await networkService.getCertificateExpiry( + authToken, + monitorId + ); + setCertificateExpiry(res?.data?.data?.certificateDate ?? "N/A"); } catch (error) { console.error(error); } - }; fetchCertificate(); }, [authToken, monitorId]); diff --git a/Client/src/Pages/Monitors/index.jsx b/Client/src/Pages/Monitors/index.jsx index 0aae47984..198cdc716 100644 --- a/Client/src/Pages/Monitors/index.jsx +++ b/Client/src/Pages/Monitors/index.jsx @@ -28,7 +28,6 @@ import { import Settings from "../../assets/icons/settings-bold.svg?react"; import PropTypes from "prop-types"; -import { logger } from "../../Utils/Logger"; const ActionsMenu = ({ monitor }) => { const [anchorEl, setAnchorEl] = useState(null); diff --git a/Client/src/Pages/PageSpeed/Configure/index.jsx b/Client/src/Pages/PageSpeed/Configure/index.jsx index 1cb164fcf..bc759db17 100644 --- a/Client/src/Pages/PageSpeed/Configure/index.jsx +++ b/Client/src/Pages/PageSpeed/Configure/index.jsx @@ -99,7 +99,7 @@ const PageSpeedConfigure = () => { setMonitor({ ...data, }); - }, [monitorId]); + }, [monitorId, monitors, navigate]); const handleChange = (event, id) => { let { value } = event.target; From a11202d6120d376239db85b116415c9ef421d585 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Tue, 20 Aug 2024 10:55:54 -0700 Subject: [PATCH 7/8] Add proptypes, remove unused imports --- Client/src/Pages/PageSpeed/index.jsx | 7 ++++++- Client/src/Pages/Status/index.jsx | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Client/src/Pages/PageSpeed/index.jsx b/Client/src/Pages/PageSpeed/index.jsx index 771a692c1..368ae2062 100644 --- a/Client/src/Pages/PageSpeed/index.jsx +++ b/Client/src/Pages/PageSpeed/index.jsx @@ -11,6 +11,7 @@ import "./index.css"; import Button from "../../Components/Button"; import { useNavigate } from "react-router"; import { getLastChecked } from "../../Utils/monitorUtils"; +import PropTypes from "prop-types"; const Card = ({ data }) => { const theme = useTheme(); @@ -57,6 +58,10 @@ const Card = ({ data }) => { ); }; +Card.propTypes = { + data: PropTypes.object.isRequired, +}; + /** * Renders a skeleton layout. * @@ -129,7 +134,7 @@ const PageSpeed = () => { ); useEffect(() => { dispatch(getPageSpeedByUserId(authToken)); - }, []); + }, [authToken, dispatch]); // will show skeletons only on initial load // since monitor state is being added to redux persist, there's no reason to display skeletons on every render diff --git a/Client/src/Pages/Status/index.jsx b/Client/src/Pages/Status/index.jsx index 474375ede..d280132c4 100644 --- a/Client/src/Pages/Status/index.jsx +++ b/Client/src/Pages/Status/index.jsx @@ -1,9 +1,6 @@ import Fallback from "../../Components/Fallback"; -import { useTheme } from "@emotion/react"; const Status = () => { - const theme = useTheme(); - return (
Date: Tue, 20 Aug 2024 11:07:34 -0700 Subject: [PATCH 8/8] Fixed useEffect infinite render loops --- Client/src/Pages/Incidents/IncidentTable/index.jsx | 8 ++++---- .../src/Pages/Monitors/Details/PaginationTable/index.jsx | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Client/src/Pages/Incidents/IncidentTable/index.jsx b/Client/src/Pages/Incidents/IncidentTable/index.jsx index 741ee144a..7a77208f8 100644 --- a/Client/src/Pages/Incidents/IncidentTable/index.jsx +++ b/Client/src/Pages/Incidents/IncidentTable/index.jsx @@ -32,11 +32,11 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => { }); useEffect(() => { - setPaginationController({ - ...paginationController, + setPaginationController((prevPaginationController) => ({ + ...prevPaginationController, page: 0, - }); - }, [filter, selectedMonitor, paginationController]); + })); + }, [filter, selectedMonitor]); useEffect(() => { const fetchPage = async () => { diff --git a/Client/src/Pages/Monitors/Details/PaginationTable/index.jsx b/Client/src/Pages/Monitors/Details/PaginationTable/index.jsx index b9416e961..ad8248ab0 100644 --- a/Client/src/Pages/Monitors/Details/PaginationTable/index.jsx +++ b/Client/src/Pages/Monitors/Details/PaginationTable/index.jsx @@ -29,11 +29,11 @@ const PaginationTable = ({ monitorId, dateRange }) => { }); useEffect(() => { - setPaginationController({ - ...paginationController, + setPaginationController((prevPaginationController) => ({ + ...prevPaginationController, page: 0, - }); - }, [dateRange, paginationController]); + })); + }, [dateRange]); useEffect(() => { const fetchPage = async () => {