From dfd522a33a76eb71b8c170094fa4a02905653201 Mon Sep 17 00:00:00 2001 From: Gabriel Hall Date: Mon, 22 Jan 2024 22:44:02 -0500 Subject: [PATCH] feat: add user action dropdown and reset pwd button --- .../admin/ParticipantTable/index.tsx | 109 +++++++++++++++--- 1 file changed, 92 insertions(+), 17 deletions(-) diff --git a/src/components/admin/ParticipantTable/index.tsx b/src/components/admin/ParticipantTable/index.tsx index 17f67ba..a44bf24 100644 --- a/src/components/admin/ParticipantTable/index.tsx +++ b/src/components/admin/ParticipantTable/index.tsx @@ -8,7 +8,12 @@ import { DialogContent, DialogContentText, DialogTitle, + Divider, IconButton, + ListItemIcon, + ListItemText, + Menu, + MenuItem, Modal, Snackbar, Table, @@ -31,6 +36,12 @@ import { Participant } from "types/Participant" import RectangleButton from "../../design/RectangleButton" import ProfileBox from "../ProfileBox" import styles from "./index.module.scss" +import { + CheckOutlined, + ClearOutlined, + LockResetOutlined, + MoreHorizRounded +} from "@mui/icons-material" enum BulkAction { ADMIT_ALL = "Admit all", @@ -171,6 +182,15 @@ const ParticipantTable = (): ReactElement => { } } + const sendResetPassword = async (userId: string) => { + try { + // await dispatch(actions.user.sendResetPassword(userId)) + openSnackbar("Sent reset password email!") + } catch (err) { + openSnackbar("Error sending reset password email") + } + } + const admitAll = async () => { try { await dispatch(actions.user.admitAll()) @@ -261,24 +281,79 @@ const ParticipantTable = (): ReactElement => { Cell: ({ cell }: { cell: any }) => { const original: Participant = cell.row.original const { _id, status } = original - if (status == Status.COMPLETED_PROFILE) { - return ( -
- admitUser(_id)} - > - Admit - - rejectUser(_id)}> - Reject - -
- ) - } else { - return <> + + const [anchorEl, setAnchorEl] = React.useState( + null + ) + const open = Boolean(anchorEl) + const handleClick = (event: React.MouseEvent) => { + setAnchorEl(event.currentTarget) + } + const handleClose = () => { + setAnchorEl(null) } + + return ( +
+ + + + + {status === Status.COMPLETED_PROFILE && ( + <> + { + await admitUser(_id) + handleClose() + }} + > + + + + Accept + + { + await rejectUser(_id) + handleClose() + }} + > + + + + Reject + + + )} + + { + await sendResetPassword(_id) + handleClose + }} + > + + + + Reset Password + + +
+ ) } } ],