Archived
Merge pull request #70 from CPSC319-Winter-term-2/home
Implemented Schedule Meeting and Call Group
This commit is contained in:
@@ -15,6 +15,10 @@ import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectFavorites } from "../../redux/slices/favoritesSlice";
|
||||
import { selectTeam, selectUsers } from "../../redux/slices/usersSlice";
|
||||
import GroupSelect from "../sidebar/GroupSelect";
|
||||
import axios from "../../api/axios";
|
||||
import useAuth from "../../hooks/useAuth";
|
||||
import DetailedMeeting from "../../api-bodies/DetailedMeeting";
|
||||
import NewMeeting from "../../api-bodies/NewMeeting";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
@@ -51,7 +55,21 @@ const CallFavouritesDialog: React.FC<Props> = ({
|
||||
selectUsers(state, groupMembersUuids)
|
||||
);
|
||||
|
||||
const handleCall = () => {
|
||||
const auth = useAuth();
|
||||
|
||||
const handleCall = async(e: React.SyntheticEvent) => {
|
||||
const newMeeting: NewMeeting ={
|
||||
startTime: new Date().toISOString(),
|
||||
duration: 60,
|
||||
topic: "Quick Call to Group",
|
||||
registrantIds: checkedUuids
|
||||
};
|
||||
const response = await axios.post(
|
||||
`/users/${auth?.uuid}/meetings`,
|
||||
JSON.stringify(newMeeting)
|
||||
);
|
||||
const meeting: DetailedMeeting = response?.data;
|
||||
console.log("create meeting response: " + meeting.startTime + ":" + meeting.duration);
|
||||
handleClose();
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,178 @@
|
||||
import {
|
||||
Button,
|
||||
Checkbox,
|
||||
Dialog,
|
||||
DialogActions,
|
||||
DialogContent,
|
||||
DialogTitle,
|
||||
FormControlLabel,
|
||||
FormGroup,
|
||||
TextField,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import LocalizationProvider from '@mui/lab/LocalizationProvider';
|
||||
import AdapterDateFns from '@mui/lab/AdapterDateFns';
|
||||
import DateTimePicker from '@mui/lab/DateTimePicker';
|
||||
import React, { useState } from "react";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectFavorites } from "../../redux/slices/favoritesSlice";
|
||||
import { selectTeam, selectUsers } from "../../redux/slices/usersSlice";
|
||||
import GroupSelect from "../sidebar/GroupSelect";
|
||||
import axios from "../../api/axios";
|
||||
import useAuth from "../../hooks/useAuth";
|
||||
import DetailedMeeting from "../../api-bodies/DetailedMeeting";
|
||||
import NewMeeting from "../../api-bodies/NewMeeting";
|
||||
|
||||
interface Props {
|
||||
open: boolean;
|
||||
handleClose: () => void;
|
||||
}
|
||||
|
||||
const CallFavouritesDialog: React.FC<Props> = ({
|
||||
open,
|
||||
handleClose,
|
||||
}: Props) => {
|
||||
|
||||
const [meetingStartDate, setMeetingStartDate] = React.useState<Date | null>(new Date());
|
||||
const [meetingTopic, setMeetingTopic] = useState<string>("");
|
||||
const [meetingDuration, setMeetingDuration] = useState<number>(60);
|
||||
const [group, setGroup] = useState<string>("Favorites");
|
||||
const [inputText, setInputText] = useState<string>("");
|
||||
const [checkedUuids, setCheckedUuids] = useState<string[]>([]);
|
||||
|
||||
const handleCheck = (uuid: string, checked: boolean) => {
|
||||
if (checked) {
|
||||
setCheckedUuids(checkedUuids.concat([uuid]));
|
||||
} else {
|
||||
setCheckedUuids(checkedUuids.filter((id) => id != uuid));
|
||||
}
|
||||
};
|
||||
|
||||
const handleGroupChange = () => {
|
||||
setCheckedUuids([]);
|
||||
};
|
||||
|
||||
const handleDateChange = (startDate: Date | null, keyboardInputValue?: string | undefined) => {
|
||||
setMeetingStartDate(startDate);
|
||||
};
|
||||
|
||||
|
||||
const favoritesUuids = useAppSelector(selectFavorites);
|
||||
const teamUuids = useAppSelector(selectTeam);
|
||||
|
||||
const groupMembersUuids: string[] =
|
||||
group === "Favorites" ? favoritesUuids : teamUuids;
|
||||
const groupMembers = useAppSelector((state) =>
|
||||
selectUsers(state, groupMembersUuids)
|
||||
);
|
||||
|
||||
const auth = useAuth();
|
||||
|
||||
const handleCall = async(e: React.SyntheticEvent) => {
|
||||
const newMeeting: NewMeeting ={
|
||||
startTime: meetingStartDate ? meetingStartDate.toISOString() : new Date().toISOString(),
|
||||
duration: meetingDuration,
|
||||
topic: meetingTopic,
|
||||
registrantIds: checkedUuids
|
||||
};
|
||||
const response = await axios.post(
|
||||
`/users/${auth?.uuid}/meetings`,
|
||||
JSON.stringify(newMeeting)
|
||||
);
|
||||
const meeting: DetailedMeeting = response?.data;
|
||||
console.log("create meeting response: " + meeting.startTime + ":" + meeting.duration);
|
||||
handleClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog onClose={handleClose} open={open} fullWidth maxWidth="sm">
|
||||
<DialogTitle>Schedule A Meeting</DialogTitle>
|
||||
<DialogContent dividers>
|
||||
<LocalizationProvider dateAdapter={AdapterDateFns}>
|
||||
<DateTimePicker
|
||||
label="Meeting Start Date&Time"
|
||||
value={meetingStartDate}
|
||||
onChange={handleDateChange}
|
||||
renderInput={(params) => <TextField {...params} />}
|
||||
/>
|
||||
</LocalizationProvider>
|
||||
<TextField
|
||||
className="meetingDuration-input"
|
||||
id="outlined-number"
|
||||
label="Duration"
|
||||
variant="outlined"
|
||||
value={meetingDuration}
|
||||
type="number"
|
||||
onChange={(event) => {
|
||||
setMeetingDuration(parseInt(event.target.value));
|
||||
}}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogContent dividers>
|
||||
<TextField
|
||||
fullWidth
|
||||
className="meetingTopic-input"
|
||||
id="outlined-basic"
|
||||
label="Meeting Topic"
|
||||
variant="outlined"
|
||||
value={meetingTopic}
|
||||
onChange={(event) => {
|
||||
setMeetingTopic(event.target.value);
|
||||
}}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogContent>
|
||||
<GroupSelect
|
||||
group={group}
|
||||
setGroup={setGroup}
|
||||
onGroupChange={handleGroupChange}
|
||||
/>
|
||||
</DialogContent>
|
||||
<DialogContent sx={{ height: "40vh" }} dividers>
|
||||
<TextField
|
||||
label="Search"
|
||||
variant="outlined"
|
||||
placeholder="Person"
|
||||
fullWidth
|
||||
sx={{ pb: 1 }}
|
||||
onChange={(e) => {
|
||||
setInputText(e.target.value);
|
||||
}}
|
||||
/>
|
||||
<FormGroup>
|
||||
{groupMembers
|
||||
.filter((member) =>
|
||||
member.name.toLowerCase().includes(inputText.toLowerCase())
|
||||
)
|
||||
.map((member) => (
|
||||
<FormControlLabel
|
||||
key={member.uuid}
|
||||
label={member.name}
|
||||
sx={{ pl: 1 }}
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
onChange={(e: any) => {
|
||||
handleCheck(member.uuid, e.target.checked);
|
||||
}}
|
||||
control={
|
||||
<Checkbox
|
||||
color="success"
|
||||
checked={checkedUuids.includes(member.uuid)}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</FormGroup>
|
||||
</DialogContent>
|
||||
|
||||
<DialogActions>
|
||||
<Button color="success" onClick={handleCall}>
|
||||
<Typography variant="button" color="black">
|
||||
Call
|
||||
</Typography>
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Dialog>
|
||||
);
|
||||
};
|
||||
|
||||
export default CallFavouritesDialog;
|
||||
@@ -4,37 +4,51 @@ import Button from "@mui/material/Button";
|
||||
import Grid from "@mui/material/Grid";
|
||||
import Typography from "@mui/material/Typography";
|
||||
import CallFavouritesDialog from "./CallFavouritesDialog";
|
||||
import ScheduleMeetingDialog from "./ScheduleMeetingDialog";
|
||||
import { useState } from "react";
|
||||
|
||||
const ShortCuts: React.FC = () => {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [openScheduleMeeting, setOpenScheduleMeeting] = useState(false);
|
||||
const [openCallGroup, setOpenCallGroup] = useState(false);
|
||||
|
||||
const handleClickOpen = () => {
|
||||
setOpen(true);
|
||||
const handleClickOpenCallGroup = () => {
|
||||
setOpenCallGroup(true);
|
||||
};
|
||||
|
||||
const handleClose = () => {
|
||||
setOpen(false);
|
||||
const handleCloseCallGroup = () => {
|
||||
setOpenCallGroup(false);
|
||||
};
|
||||
|
||||
const handleClickOpenScheduleMeeting = () => {
|
||||
setOpenScheduleMeeting(true);
|
||||
};
|
||||
|
||||
const handleCloseScheduleMeeting = () => {
|
||||
setOpenScheduleMeeting(false);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="short-cuts">
|
||||
<Grid className="row-1" container spacing={1}>
|
||||
<Grid item sm={6}>
|
||||
<Button className="tile">
|
||||
<Button className="tile" onClick={handleClickOpenScheduleMeeting}>
|
||||
<PeopleIcon className="icon" />
|
||||
</Button>
|
||||
<ScheduleMeetingDialog
|
||||
open={openScheduleMeeting}
|
||||
handleClose={handleCloseScheduleMeeting}
|
||||
/>
|
||||
<Typography variant="h6" className="mylabel" sx={{ ml: 1 }}>
|
||||
Schedule Meeting
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item sm={6}>
|
||||
<Button className="tile" onClick={handleClickOpen}>
|
||||
<Button className="tile" onClick={handleClickOpenCallGroup}>
|
||||
<PhoneEnabledIcon className="icon" />
|
||||
</Button>
|
||||
<CallFavouritesDialog
|
||||
open={open}
|
||||
handleClose={handleClose}
|
||||
open={openCallGroup}
|
||||
handleClose={handleCloseCallGroup}
|
||||
/>
|
||||
<Typography variant="h6" className="mylabel" sx={{ ml: 1 }}>
|
||||
Call Group
|
||||
|
||||
Reference in New Issue
Block a user