refactor team panel to get rid of error of unused code, and add generic modals

This commit is contained in:
Caio Cabral committed 2024-10-22 08:54:12 -04:00
1 parent effc6dac3a
commit 7752e52fcd
2 files changed
+32 -85

No files matched your search

@@ -1,7 +1,7 @@
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import { useRef, useState } from "react"; import { useRef, useState } from "react";
import TabPanel from "@mui/lab/TabPanel"; 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 Avatar from "../../Avatar";
import Field from "../../Inputs/Field"; import Field from "../../Inputs/Field";
import ImageField from "../../Inputs/Image"; import ImageField from "../../Inputs/Image";
@@ -15,6 +15,7 @@ import { clearUptimeMonitorState } from "../../../Features/UptimeMonitors/uptime
import { createToast } from "../../../Utils/toastUtils"; import { createToast } from "../../../Utils/toastUtils";
import { logger } from "../../../Utils/Logger"; import { logger } from "../../../Utils/Logger";
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
import { GenericDialog } from "../../Dialog/genericDialog";
/** /**
* ProfilePanel component displays a form for editing user profile information * ProfilePanel component displays a form for editing user profile information
@@ -369,31 +370,13 @@ const ProfilePanel = () => {
</Box> </Box>
)} )}
{/* TODO - Update ModalPopup Component with @mui for reusability */} {/* TODO - Update ModalPopup Component with @mui for reusability */}
<Modal <GenericDialog
aria-labelledby="modal-delete-account" title={"modal-delete-account"}
aria-describedby="delete-account-confirmation" description={"delete-account-confirmation"}
open={isModalOpen("delete")} open={isModalOpen("delete")}
onClose={() => setIsOpen("")} close={() => setIsOpen("")}
disablePortal theme={theme}
> /* disablePortal ? */
<Stack
gap={theme.spacing(5)}
sx={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 500,
bgcolor: theme.palette.background.main,
border: 1,
borderColor: theme.palette.border.light,
borderRadius: theme.shape.borderRadius,
boxShadow: 24,
p: theme.spacing(15),
"&:focus": {
outline: "none",
},
}}
> >
<Typography <Typography
id="modal-delete-account" id="modal-delete-account"
@@ -431,31 +414,13 @@ const ProfilePanel = () => {
Delete account Delete account
</LoadingButton> </LoadingButton>
</Stack> </Stack>
</Stack> </GenericDialog>
</Modal> <GenericDialog
<Modal title={"modal-update-picture"}
aria-labelledby="modal-update-picture" description={"update-profile-picture"}
aria-describedby="update-profile-picture"
open={isModalOpen("picture")} open={isModalOpen("picture")}
onClose={closePictureModal} close={closePictureModal}
> theme={theme}
<Stack
sx={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 475,
bgcolor: theme.palette.background.main,
border: 1,
borderColor: theme.palette.border.light,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shape.boxShadow,
p: theme.spacing(15),
"&:focus": {
outline: "none",
},
}}
> >
<Typography <Typography
id="modal-update-picture" id="modal-update-picture"
@@ -519,8 +484,7 @@ const ProfilePanel = () => {
Update Update
</Button> </Button>
</Stack> </Stack>
</Stack> </GenericDialog>
</Modal>
</TabPanel> </TabPanel>
); );
}; };
@@ -1,6 +1,6 @@
import { useTheme } from "@emotion/react"; import { useTheme } from "@emotion/react";
import TabPanel from "@mui/lab/TabPanel"; 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 { useEffect, useState } from "react";
import Field from "../../Inputs/Field"; import Field from "../../Inputs/Field";
import { credentials } from "../../../Validation/validation"; import { credentials } from "../../../Validation/validation";
@@ -10,6 +10,7 @@ import { useSelector } from "react-redux";
import BasicTable from "../../BasicTable"; import BasicTable from "../../BasicTable";
import Select from "../../Inputs/Select"; import Select from "../../Inputs/Select";
import LoadingButton from "@mui/lab/LoadingButton"; import LoadingButton from "@mui/lab/LoadingButton";
import { GenericDialog } from "../../Dialog/genericDialog";
/** /**
* TeamPanel component manages the organization and team members, * TeamPanel component manages the organization and team members,
@@ -31,10 +32,10 @@ const TeamPanel = () => {
const { authToken, user } = useSelector((state) => state.auth); const { authToken, user } = useSelector((state) => state.auth);
//TODO //TODO
const [orgStates, setOrgStates] = useState({ // const [orgStates, setOrgStates] = useState({
name: "Bluewave Labs", // name: "Bluewave Labs",
isEdit: false, // isEdit: false,
}); // });
const [toInvite, setToInvite] = useState({ const [toInvite, setToInvite] = useState({
email: "", email: "",
role: ["0"], role: ["0"],
@@ -134,10 +135,10 @@ const TeamPanel = () => {
}, [errors, toInvite.email]); }, [errors, toInvite.email]);
// RENAME ORGANIZATION // RENAME ORGANIZATION
const toggleEdit = () => { // const toggleEdit = () => {
setOrgStates((prev) => ({ ...prev, isEdit: !prev.isEdit })); // setOrgStates((prev) => ({ ...prev, isEdit: !prev.isEdit }));
}; // };
const handleRename = () => {}; // const handleRename = () => {};
// INVITE MEMBER // INVITE MEMBER
const [isOpen, setIsOpen] = useState(false); const [isOpen, setIsOpen] = useState(false);
@@ -327,30 +328,13 @@ const TeamPanel = () => {
table={"team"} table={"team"}
/> />
</Stack> </Stack>
<Modal
aria-labelledby="modal-invite-member" <GenericDialog
aria-describedby="invite-member-to-team" title={"modal-invite-member"}
description={"invite-member-to-team"}
open={isOpen} open={isOpen}
onClose={closeInviteModal} close={closeInviteModal}
> theme={theme}
<Stack
gap={theme.spacing(5)}
sx={{
position: "absolute",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
width: 450,
bgcolor: theme.palette.background.main,
border: 1,
borderColor: theme.palette.border.light,
borderRadius: theme.shape.borderRadius,
boxShadow: theme.shape.boxShadow,
p: theme.spacing(15),
"&:focus": {
outline: "none",
},
}}
> >
<Box> <Box>
<Typography <Typography
@@ -419,8 +403,7 @@ const TeamPanel = () => {
Send invite Send invite
</LoadingButton> </LoadingButton>
</Stack> </Stack>
</Stack> </GenericDialog>
</Modal>
</TabPanel> </TabPanel>
); );
}; };