From 67483026a1ce90dfbf96cd37c292f8e91a6d5bb8 Mon Sep 17 00:00:00 2001 From: hppanpaliya Date: Fri, 25 Aug 2023 22:32:36 -0400 Subject: [PATCH] warnings fixes --- react/src/components/AllEmailList/index.js | 47 ++++++++++------------ react/src/components/ButtonSection.js | 8 ++-- react/src/components/EmailList/index.js | 7 +--- react/src/components/Generate/index.js | 7 +--- react/src/components/Inbox/index.js | 7 ++-- react/src/components/InboxEmail/index.js | 8 +--- react/src/components/Main/index.js | 5 +-- react/src/components/TitleBar.js | 5 +-- react/src/context/ThemeContext.js | 1 - react/src/theme/index.js | 1 - 10 files changed, 37 insertions(+), 59 deletions(-) diff --git a/react/src/components/AllEmailList/index.js b/react/src/components/AllEmailList/index.js index f415013..0368b20 100644 --- a/react/src/components/AllEmailList/index.js +++ b/react/src/components/AllEmailList/index.js @@ -1,10 +1,8 @@ import React, { useEffect, useState } from "react"; import { Grid, Typography, Paper, Box, Chip, Tooltip, IconButton } from "@mui/material"; -import { useParams, useNavigate } from "react-router-dom"; +import { useNavigate } from "react-router-dom"; import axios from "axios"; import ButtonSection from "../ButtonSection"; -import TitleBar from "../TitleBar"; -import InfoIcon from "@mui/icons-material/Info"; import { useRef } from "react"; import FiberNewOutlinedIcon from "@mui/icons-material/FiberNewOutlined"; import DeleteIcon from "@mui/icons-material/Delete"; @@ -12,13 +10,13 @@ import ConfirmModal from "../ConfirmModal"; const AllEmailList = () => { const [emailData, setEmailData] = useState([]); + // eslint-disable-next-line no-unused-vars const [loading, setLoading] = useState(true); const [isMobile, setIsMobile] = useState(false); const [emailToDelete, setEmailToDelete] = useState(null); const [openModal, setOpenModal] = useState(false); const [reload, setReload] = useState(false); - useEffect(() => { const handleResize = () => { setIsMobile(window.innerWidth <= 700); @@ -69,9 +67,7 @@ const AllEmailList = () => { return () => { stopPolling(); }; - }, [ - reload - ]); + }, [reload]); const handleEmailClick = (email, email_Id) => { navigate(`/inbox/${email}/${email_Id}`); @@ -157,9 +153,9 @@ const AllEmailList = () => { > {!email.readStatus ? : null} - - - + + + { sx={{ alignSelf: "flex-end", justifySelf: "flex-end", - }} > - + @@ -191,8 +186,8 @@ const AllEmailList = () => { > From: {email.from.text} - - + + { { - handleDeleteEmail(); - setOpenModal(false); - }} - onCancel={() => setOpenModal(false)} - /> + open={openModal} + setOpen={setOpenModal} + title="Delete Email" + body="Are you sure you want to delete this email?" + confirmText="Delete" + cancelText="Cancel" + onConfirm={() => { + handleDeleteEmail(); + setOpenModal(false); + }} + onCancel={() => setOpenModal(false)} + /> ); }; diff --git a/react/src/components/ButtonSection.js b/react/src/components/ButtonSection.js index d16ff23..660e5f7 100644 --- a/react/src/components/ButtonSection.js +++ b/react/src/components/ButtonSection.js @@ -48,11 +48,11 @@ const ButtonSection = () => { }; const location = useLocation(); - const [activePage, setActivePage] = useState(""); + // const [activePage, setActivePage] = useState(""); - useEffect(() => { - setActivePage(location.pathname); - }, [location]); + // useEffect(() => { + // setActivePage(location.pathname); + // }, [location]); const isActivePage = (path) => { const { pathname } = location; diff --git a/react/src/components/EmailList/index.js b/react/src/components/EmailList/index.js index 9dd72bd..e7f6722 100644 --- a/react/src/components/EmailList/index.js +++ b/react/src/components/EmailList/index.js @@ -1,14 +1,11 @@ import React, { useEffect, useState } from "react"; -import { Grid, Typography, Paper, Box, Chip, Tooltip, IconButton } from "@mui/material"; +import { Grid, Typography, Paper, Box, Tooltip, IconButton } from "@mui/material"; import { useParams, useNavigate } from "react-router-dom"; import axios from "axios"; import ButtonSection from "../ButtonSection"; -import TitleBar from "../TitleBar"; import { useRef } from "react"; import DeleteIcon from "@mui/icons-material/Delete"; import ConfirmModal from "../ConfirmModal"; -import { theme } from "../../theme"; -import { darkTheme } from "../../theme/darkTheme"; import { ThemeContext } from "../../context/ThemeContext"; import { useContext } from "react"; import FiberNewOutlinedIcon from "@mui/icons-material/FiberNewOutlined"; @@ -97,7 +94,7 @@ const EmailList = () => { }; const handleNoEmails = () => { - if (loading == true) { + if (loading === true) { return ( diff --git a/react/src/components/Generate/index.js b/react/src/components/Generate/index.js index 735b389..a335728 100644 --- a/react/src/components/Generate/index.js +++ b/react/src/components/Generate/index.js @@ -1,20 +1,17 @@ import React from "react"; import ButtonSection from "../ButtonSection"; -import TitleBar from "../TitleBar"; -import { Grid, Box, Typography, TextField, Button } from "@mui/material"; +import { Grid, Box, TextField, Button } from "@mui/material"; import { useNavigate } from "react-router-dom"; import { useState, useEffect } from "react"; import { FileCopyOutlined } from "@mui/icons-material"; import { InputAdornment } from "@mui/material"; -import { theme } from "../../theme"; -import { darkTheme } from "../../theme/darkTheme"; import { ThemeContext } from "../../context/ThemeContext"; import { useContext } from "react"; const Generate = () => { const navigate = useNavigate(); const [email, setEmail] = useState(window.localStorage.getItem("lastEmailId") || ""); - const [error, setError] = useState(false); + // const [error, setError] = useState(false); const [isMobile, setIsMobile] = useState(false); const [width, setWidth] = useState(window.innerWidth); const domains = JSON.parse(process.env.REACT_APP_DOMAINS); diff --git a/react/src/components/Inbox/index.js b/react/src/components/Inbox/index.js index 8f885cc..d8f9ff1 100644 --- a/react/src/components/Inbox/index.js +++ b/react/src/components/Inbox/index.js @@ -1,6 +1,4 @@ import React from "react"; -import TitleBar from "../TitleBar"; -import ButtonSection from "../ButtonSection"; import Generate from "../Generate"; import { useEffect, useState } from "react"; import { useNavigate } from "react-router-dom"; @@ -12,13 +10,14 @@ const Inbox = () => { useEffect(() => { setLastEmail(localStorage.getItem("lastEmailId")); console.log(lastEmail); - }, []); + }, [lastEmail]); useEffect(() => { if (lastEmail) { navigate(`/inbox/${lastEmail}`); } - }, [lastEmail]); + + }, [lastEmail, navigate]); return ( diff --git a/react/src/components/InboxEmail/index.js b/react/src/components/InboxEmail/index.js index e0cac11..3456a79 100644 --- a/react/src/components/InboxEmail/index.js +++ b/react/src/components/InboxEmail/index.js @@ -1,18 +1,14 @@ import React, { useEffect, useState } from "react"; import { Grid, Typography, Paper, Box, Chip, Tooltip, IconButton } from "@mui/material"; -import { useNavigate, useParams } from "react-router-dom"; +import { useParams } from "react-router-dom"; import axios from "axios"; import ButtonSection from "../ButtonSection"; -import TitleBar from "../TitleBar"; import InfoIcon from "@mui/icons-material/Info"; -import { theme } from "../../theme"; -import { darkTheme } from "../../theme/darkTheme"; import { ThemeContext } from "../../context/ThemeContext"; import { useContext } from "react"; const InboxEmail = () => { - const navigate = useNavigate(); const { emailId } = useParams(); const { email_id } = useParams(); const [emailData, setEmailData] = useState(); @@ -52,7 +48,7 @@ const InboxEmail = () => { }; fetchEmailData(); - }, [email_id]); + }, [email_id, emailId]); if (emailHeaders) { headers = emailHeaders.map((header, i) => { diff --git a/react/src/components/Main/index.js b/react/src/components/Main/index.js index 23c691a..6e4cfd7 100644 --- a/react/src/components/Main/index.js +++ b/react/src/components/Main/index.js @@ -1,10 +1,7 @@ import React from "react"; -import { Button, Grid, Box, Typography } from "@mui/material"; +import { Grid, Box, Typography } from "@mui/material"; import ButtonSection from "../ButtonSection"; -import TitleBar from "../TitleBar"; import { useEffect, useState } from "react"; -import { theme } from "../../theme"; -import { darkTheme } from "../../theme/darkTheme"; import { ThemeContext } from "../../context/ThemeContext"; import { useContext } from "react"; diff --git a/react/src/components/TitleBar.js b/react/src/components/TitleBar.js index b3d3643..276a31b 100644 --- a/react/src/components/TitleBar.js +++ b/react/src/components/TitleBar.js @@ -1,8 +1,7 @@ -import React, { useState, useEffect, useRef, useContext } from "react"; +import React, { useState, useEffect, useContext } from "react"; import { Box, Typography, Grid } from "@mui/material"; import { useNavigate } from "react-router-dom"; -import { darkTheme } from "../theme/darkTheme"; -import { theme } from "../theme"; + import { ThemeContext } from "../context/ThemeContext"; const TitleBar = () => { diff --git a/react/src/context/ThemeContext.js b/react/src/context/ThemeContext.js index a887c0c..0c4ea80 100644 --- a/react/src/context/ThemeContext.js +++ b/react/src/context/ThemeContext.js @@ -1,4 +1,3 @@ -import React from "react"; import { createContext } from "react"; export const ThemeContext = createContext(); diff --git a/react/src/theme/index.js b/react/src/theme/index.js index a34ad6c..a276cc2 100644 --- a/react/src/theme/index.js +++ b/react/src/theme/index.js @@ -1,5 +1,4 @@ import { createTheme } from "@mui/material/styles"; -import { teal, green } from "@mui/material/colors"; const theme = createTheme({ palette: {