|
| 1 | +/* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */ |
| 2 | +import { |
| 3 | + Button, |
| 4 | + DialogActions, |
| 5 | + DialogContent, |
| 6 | + DialogTitle, |
| 7 | + IconButton, |
| 8 | + List, |
| 9 | + ListItem, |
| 10 | + ListItemText, |
| 11 | + Tooltip, |
| 12 | +} from "@material-ui/core"; |
| 13 | +import { createStyles, Theme, makeStyles } from "@material-ui/core/styles"; |
| 14 | +import Dialog from "@material-ui/core/Dialog"; |
| 15 | +import { Assignment } from "@material-ui/icons"; |
| 16 | +import React from "react"; |
| 17 | +import { meetingType } from "../MeetingTabs"; |
| 18 | + |
| 19 | +const useStyles = makeStyles((theme: Theme) => |
| 20 | + createStyles({ |
| 21 | + root: { |
| 22 | + width: "70vh", |
| 23 | + [theme.breakpoints.down("sm")]: { |
| 24 | + width: "60vw", |
| 25 | + }, |
| 26 | + }, |
| 27 | + btn: { |
| 28 | + background: "var(--golden)", |
| 29 | + padding: 2, |
| 30 | + color: "white", |
| 31 | + margin: "2vh", |
| 32 | + "&:hover": { |
| 33 | + background: "var(--dark-golden)", |
| 34 | + }, |
| 35 | + }, |
| 36 | + }) |
| 37 | +); |
| 38 | + |
| 39 | +interface RegisterDialogProps { |
| 40 | + meetingData?: meetingType; |
| 41 | + open: boolean; |
| 42 | + close: () => void; |
| 43 | +} |
| 44 | +const RegistersDialog: React.FC<RegisterDialogProps> = ({ |
| 45 | + meetingData, |
| 46 | + open, |
| 47 | + close, |
| 48 | +}) => { |
| 49 | + const classes = useStyles(); |
| 50 | + const copyToClipboard = () => { |
| 51 | + const arr = meetingData?.registered.map((e) => e.email); |
| 52 | + const data = arr?.join(" "); |
| 53 | + navigator.clipboard.writeText(data ? data : ""); |
| 54 | + }; |
| 55 | + return ( |
| 56 | + <Dialog onClose={close} aria-labelledby="registers-title" open={open}> |
| 57 | + <DialogTitle id="registers-dialog-title">Registers</DialogTitle> |
| 58 | + <DialogContent className={classes.root} dividers> |
| 59 | + <List> |
| 60 | + {meetingData?.registered.map((e, key) => ( |
| 61 | + <ListItem key={key}> |
| 62 | + <ListItemText primary={e.name} secondary={e.email} /> |
| 63 | + </ListItem> |
| 64 | + ))} |
| 65 | + </List> |
| 66 | + </DialogContent> |
| 67 | + <DialogActions> |
| 68 | + <Tooltip title="Copy emails to clipboard"> |
| 69 | + <IconButton onClick={copyToClipboard} color="inherit"> |
| 70 | + <Assignment /> |
| 71 | + </IconButton> |
| 72 | + </Tooltip> |
| 73 | + <Button |
| 74 | + className={classes.btn} |
| 75 | + autoFocus |
| 76 | + onClick={close} |
| 77 | + color="inherit" |
| 78 | + > |
| 79 | + Close |
| 80 | + </Button> |
| 81 | + </DialogActions> |
| 82 | + </Dialog> |
| 83 | + ); |
| 84 | +}; |
| 85 | + |
| 86 | +export default RegistersDialog; |
0 commit comments