Skip to content

Commit

Permalink
warnings fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
hppanpaliya committed Aug 26, 2023
1 parent 06b2f78 commit 6748302
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 59 deletions.
47 changes: 21 additions & 26 deletions react/src/components/AllEmailList/index.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
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";
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);
Expand Down Expand Up @@ -69,9 +67,7 @@ const AllEmailList = () => {
return () => {
stopPolling();
};
}, [
reload
]);
}, [reload]);

const handleEmailClick = (email, email_Id) => {
navigate(`/inbox/${email}/${email_Id}`);
Expand Down Expand Up @@ -157,9 +153,9 @@ const AllEmailList = () => {
>
{!email.readStatus ? <FiberNewOutlinedIcon /> : null}
</IconButton>
</Tooltip>
<Tooltip title="Delete">
</Tooltip>

<Tooltip title="Delete">
<IconButton
aria-label="delete"
size="small"
Expand All @@ -171,12 +167,11 @@ const AllEmailList = () => {
sx={{
alignSelf: "flex-end",
justifySelf: "flex-end",

}}
>
<DeleteIcon />
</IconButton>
</Tooltip>
</Tooltip>
</Typography>

<Box display="flex" alignItems="center" gap={2} mb={2}>
Expand All @@ -191,8 +186,8 @@ const AllEmailList = () => {
>
From: {email.from.text}
</Typography>
</Box>
<Box display="flex" alignItems="center" gap={2} mb={2}>
</Box>
<Box display="flex" alignItems="center" gap={2} mb={2}>
<Typography
variant="subtitle1"
sx={{
Expand All @@ -214,18 +209,18 @@ const AllEmailList = () => {
</Grid>
</Grid>
<ConfirmModal
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)}
/>
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)}
/>
</>
);
};
Expand Down
8 changes: 4 additions & 4 deletions react/src/components/ButtonSection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions react/src/components/EmailList/index.js
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -97,7 +94,7 @@ const EmailList = () => {
};

const handleNoEmails = () => {
if (loading == true) {
if (loading === true) {
return (
<Box sx={{ textAlign: "center", marginTop: "10vh" }}>
<Paper elevation={3} sx={{ p: 2, marginBottom: 2, margin: isMobile ? "2vh" : "" }}>
Expand Down
7 changes: 2 additions & 5 deletions react/src/components/Generate/index.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
7 changes: 3 additions & 4 deletions react/src/components/Inbox/index.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 (
Expand Down
8 changes: 2 additions & 6 deletions react/src/components/InboxEmail/index.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down Expand Up @@ -52,7 +48,7 @@ const InboxEmail = () => {
};

fetchEmailData();
}, [email_id]);
}, [email_id, emailId]);

if (emailHeaders) {
headers = emailHeaders.map((header, i) => {
Expand Down
5 changes: 1 addition & 4 deletions react/src/components/Main/index.js
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
5 changes: 2 additions & 3 deletions react/src/components/TitleBar.js
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand Down
1 change: 0 additions & 1 deletion react/src/context/ThemeContext.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from "react";
import { createContext } from "react";

export const ThemeContext = createContext();
1 change: 0 additions & 1 deletion react/src/theme/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createTheme } from "@mui/material/styles";
import { teal, green } from "@mui/material/colors";

const theme = createTheme({
palette: {
Expand Down

0 comments on commit 6748302

Please sign in to comment.