From 7752e52fcdefbd7ab625b362e23f5a69cf069bab Mon Sep 17 00:00:00 2001 From: Caio Cabral Date: Tue, 22 Oct 2024 08:54:12 -0400 Subject: [PATCH] refactor team panel to get rid of error of unused code, and add generic modals --- .../TabPanels/Account/ProfilePanel.jsx | 242 ++++++++---------- .../TabPanels/Account/TeamPanel.jsx | 181 ++++++------- 2 files changed, 185 insertions(+), 238 deletions(-) diff --git a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx index 999e026c7..f5ac95bc8 100644 --- a/Client/src/Components/TabPanels/Account/ProfilePanel.jsx +++ b/Client/src/Components/TabPanels/Account/ProfilePanel.jsx @@ -1,7 +1,7 @@ import { useTheme } from "@emotion/react"; import { useRef, useState } from "react"; import TabPanel from "@mui/lab/TabPanel"; -import { Box, Button, Divider, Modal, Stack, Typography } from "@mui/material"; +import { Box, Button, Divider, Stack, Typography } from "@mui/material"; import Avatar from "../../Avatar"; import Field from "../../Inputs/Field"; import ImageField from "../../Inputs/Image"; @@ -15,6 +15,7 @@ import { clearUptimeMonitorState } from "../../../Features/UptimeMonitors/uptime import { createToast } from "../../../Utils/toastUtils"; import { logger } from "../../../Utils/Logger"; import LoadingButton from "@mui/lab/LoadingButton"; +import { GenericDialog } from "../../Dialog/genericDialog"; /** * ProfilePanel component displays a form for editing user profile information @@ -369,158 +370,121 @@ const ProfilePanel = () => { )} {/* TODO - Update ModalPopup Component with @mui for reusability */} - setIsOpen("")} - disablePortal + close={() => setIsOpen("")} + theme={theme} + /* disablePortal ? */ > + + Really delete this account? + + + If you delete your account, you will no longer be able to sign in, and all of + your data will be deleted. Deleting your account is permanent and + non-recoverable action. + - setIsOpen("")} > - Really delete this account? - - + - If you delete your account, you will no longer be able to sign in, and all of - your data will be deleted. Deleting your account is permanent and - non-recoverable action. - - - - - Delete account - - + Delete account + - - + - - - Upload Image - - + + {progress.isLoading || progress.value !== 0 || errors["picture"] ? ( + } + label={file?.name} + size={file?.size} + progress={progress.value} + onClick={removePicture} + error={errors["picture"]} /> - {progress.isLoading || progress.value !== 0 || errors["picture"] ? ( - } - label={file?.name} - size={file?.size} - progress={progress.value} - onClick={removePicture} - error={errors["picture"]} - /> - ) : ( - "" - )} - + - - + Remove + + - + ); }; diff --git a/Client/src/Components/TabPanels/Account/TeamPanel.jsx b/Client/src/Components/TabPanels/Account/TeamPanel.jsx index 33218bcbb..d1d67d253 100644 --- a/Client/src/Components/TabPanels/Account/TeamPanel.jsx +++ b/Client/src/Components/TabPanels/Account/TeamPanel.jsx @@ -1,6 +1,6 @@ import { useTheme } from "@emotion/react"; import TabPanel from "@mui/lab/TabPanel"; -import { Box, Button, ButtonGroup, Modal, Stack, Typography } from "@mui/material"; +import { Box, Button, ButtonGroup, Stack, Typography } from "@mui/material"; import { useEffect, useState } from "react"; import Field from "../../Inputs/Field"; import { credentials } from "../../../Validation/validation"; @@ -10,6 +10,7 @@ import { useSelector } from "react-redux"; import BasicTable from "../../BasicTable"; import Select from "../../Inputs/Select"; import LoadingButton from "@mui/lab/LoadingButton"; +import { GenericDialog } from "../../Dialog/genericDialog"; /** * TeamPanel component manages the organization and team members, @@ -31,10 +32,10 @@ const TeamPanel = () => { const { authToken, user } = useSelector((state) => state.auth); //TODO - const [orgStates, setOrgStates] = useState({ - name: "Bluewave Labs", - isEdit: false, - }); + // const [orgStates, setOrgStates] = useState({ + // name: "Bluewave Labs", + // isEdit: false, + // }); const [toInvite, setToInvite] = useState({ email: "", role: ["0"], @@ -134,10 +135,10 @@ const TeamPanel = () => { }, [errors, toInvite.email]); // RENAME ORGANIZATION - const toggleEdit = () => { - setOrgStates((prev) => ({ ...prev, isEdit: !prev.isEdit })); - }; - const handleRename = () => {}; + // const toggleEdit = () => { + // setOrgStates((prev) => ({ ...prev, isEdit: !prev.isEdit })); + // }; + // const handleRename = () => {}; // INVITE MEMBER const [isOpen, setIsOpen] = useState(false); @@ -327,100 +328,82 @@ const TeamPanel = () => { table={"team"} /> - - - - - Invite new team member - - - When you add a new team member, they will get access to all monitors. - - - - + setToInvite((prev) => ({ + ...prev, + role: [event.target.value], + })) + } + items={[ + { _id: "admin", name: "Admin" }, + { _id: "user", name: "User" }, + ]} + /> + + + Cancel + + + Send invite + - + ); };