Archived
redux updates
This commit is contained in:
@@ -16,10 +16,22 @@ const returnStatusColor = (
|
||||
}
|
||||
};
|
||||
|
||||
const getMeetingDuration = (meeting: DetailedMeeting) => {
|
||||
const getUpcomingMeetingTime = (meeting: DetailedMeeting) => {
|
||||
const startDate = new Date(meeting.start);
|
||||
const endDate = new Date(startDate.getTime() + meeting.duration * 60000);
|
||||
return `${startDate.toTimeString()} - ${endDate.toTimeString()}`;
|
||||
const startTime = startDate
|
||||
.toTimeString()
|
||||
.split(" ")[0]
|
||||
.split(":")
|
||||
.slice(0, 2)
|
||||
.join(":");
|
||||
const endTime = endDate
|
||||
.toTimeString()
|
||||
.split(" ")[0]
|
||||
.split(":")
|
||||
.slice(0, 2)
|
||||
.join(":");
|
||||
return `${startTime} - ${endTime}`;
|
||||
};
|
||||
|
||||
export { returnStatusColor, getMeetingDuration };
|
||||
export { returnStatusColor, getUpcomingMeetingTime };
|
||||
|
||||
@@ -16,6 +16,7 @@ const Body: React.FC<Props> = (props) => {
|
||||
flexDirection: "column",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
mt: 2,
|
||||
}}
|
||||
>
|
||||
<Toolbar />
|
||||
|
||||
@@ -11,10 +11,7 @@ import React from "react";
|
||||
import { ExpandLess, ExpandMore } from "@mui/icons-material";
|
||||
import ContactItem from "./sidebar-components/ContactItem";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
selectFavoritesJSON,
|
||||
selectTeamJSON,
|
||||
} from "../../../redux/slices/peopleSlice";
|
||||
import { selectUsers, selectTeam } from "../../../redux/slices/usersSlice";
|
||||
import { selectFavorites } from "../../../redux/slices/favoritesSlice";
|
||||
import UserLite from "../../../api-bodies/UserLite";
|
||||
|
||||
@@ -28,11 +25,11 @@ const Sidebar: React.FC<Props> = (props) => {
|
||||
const [favoritesOpen, setFavoritesOpen] = React.useState<boolean>(true);
|
||||
const [teamOpen, setTeamOpen] = React.useState<boolean>(false);
|
||||
|
||||
const favorites = useAppSelector(selectFavorites);
|
||||
const favoritesJSON = useAppSelector((state) =>
|
||||
selectFavoritesJSON(state, favorites)
|
||||
const favoritesUuids = useAppSelector(selectFavorites);
|
||||
const favorites = useAppSelector((state) =>
|
||||
selectUsers(state, favoritesUuids)
|
||||
);
|
||||
const teamJSON = useAppSelector(selectTeamJSON);
|
||||
const team = useAppSelector(selectTeam);
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
@@ -54,13 +51,13 @@ const Sidebar: React.FC<Props> = (props) => {
|
||||
{favoritesOpen ? <ExpandLess /> : <ExpandMore />}
|
||||
<ListItemText primary="Favorites" sx={{ textAlign: "center" }} />
|
||||
<ListItemText
|
||||
primary={favoritesJSON.length}
|
||||
primary={favorites.length}
|
||||
sx={{ textAlign: "right" }}
|
||||
/>
|
||||
</ListItemButton>
|
||||
<Collapse in={favoritesOpen} timeout="auto" unmountOnExit>
|
||||
<List disablePadding>
|
||||
{favoritesJSON.map((favorite, i) => (
|
||||
{favorites.map((favorite, i) => (
|
||||
<ContactItem
|
||||
contactInfo={favorite}
|
||||
key={i}
|
||||
@@ -72,11 +69,11 @@ const Sidebar: React.FC<Props> = (props) => {
|
||||
<ListItemButton onClick={() => setTeamOpen(!teamOpen)}>
|
||||
{teamOpen ? <ExpandLess /> : <ExpandMore />}
|
||||
<ListItemText primary="Team" sx={{ textAlign: "center" }} />
|
||||
<ListItemText primary={teamJSON.length} sx={{ textAlign: "right" }} />
|
||||
<ListItemText primary={team.length} sx={{ textAlign: "right" }} />
|
||||
</ListItemButton>
|
||||
<Collapse in={teamOpen} timeout="auto" unmountOnExit>
|
||||
<List disablePadding>
|
||||
{teamJSON.map((member, i) => (
|
||||
{team.map((member, i) => (
|
||||
<ContactItem
|
||||
contactInfo={member}
|
||||
key={i}
|
||||
|
||||
@@ -3,8 +3,8 @@ import React from "react";
|
||||
import UserLite from "../../../../api-bodies/UserLite";
|
||||
import { useAppSelector, useAppDispatch } from "../../../../redux/hooks";
|
||||
import { open } from "../../../../redux/slices/meetingDetailsOpenSlice";
|
||||
import { selectUserUpcomingMeetings } from "../../../../redux/slices/meetingsSlice";
|
||||
import { getMeetingDuration } from "../../Utils";
|
||||
import { selectUserUpcomingMeetings } from "../../../../redux/slices/meetingsAndUserStatusSlice";
|
||||
import { getUpcomingMeetingTime } from "../../Utils";
|
||||
|
||||
interface Props {
|
||||
contactInfo: UserLite;
|
||||
@@ -53,7 +53,7 @@ const LowerBody: React.FC<Props> = (props) => {
|
||||
{meeting.topic}
|
||||
</Button>
|
||||
<Typography sx={{ pt: 1.5 }}>
|
||||
{getMeetingDuration(meeting)}
|
||||
{getUpcomingMeetingTime(meeting)}
|
||||
</Typography>
|
||||
</Box>
|
||||
))}
|
||||
|
||||
@@ -6,12 +6,34 @@ import GroupsIcon from "@mui/icons-material/Groups";
|
||||
import AddIcon from "@mui/icons-material/Add";
|
||||
import Status from "../../Status";
|
||||
import UserLite from "../../../../api-bodies/UserLite";
|
||||
import UserStatus from "../../../../api-bodies/UserStatus";
|
||||
import { useAppSelector, useAppDispatch } from "../../../../redux/hooks";
|
||||
import {
|
||||
selectUserStatus,
|
||||
selectMeeting,
|
||||
} from "../../../../redux/slices/meetingsAndUserStatusSlice";
|
||||
import {
|
||||
selectFavorites,
|
||||
addFavorite,
|
||||
removeFavorite,
|
||||
} from "../../../../redux/slices/favoritesSlice";
|
||||
import RemoveIcon from "@mui/icons-material/Remove";
|
||||
|
||||
interface Props {
|
||||
contactInfo: UserLite;
|
||||
}
|
||||
|
||||
const UpperBody: React.FC<Props> = (props) => {
|
||||
const dispatch = useAppDispatch();
|
||||
const userStatus: UserStatus | null = useAppSelector((state) =>
|
||||
selectUserStatus(state, props.contactInfo.uuid)
|
||||
);
|
||||
const favoritesUuids = useAppSelector(selectFavorites);
|
||||
const detailedMeeting = useAppSelector((state) =>
|
||||
selectMeeting(state, userStatus.meetingID)
|
||||
);
|
||||
const status: Status =
|
||||
userStatus && userStatus.inMeeting ? Status.Online : Status.Offline;
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -34,9 +56,25 @@ const UpperBody: React.FC<Props> = (props) => {
|
||||
}}
|
||||
>
|
||||
<Typography variant="h3">{props.contactInfo.name}</Typography>
|
||||
<Button variant="outlined" color="success" startIcon={<AddIcon />}>
|
||||
favorites
|
||||
</Button>
|
||||
{!favoritesUuids.includes(props.contactInfo.uuid) ? (
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="success"
|
||||
startIcon={<AddIcon />}
|
||||
onClick={() => dispatch(addFavorite(props.contactInfo.uuid))}
|
||||
>
|
||||
favorites
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
variant="outlined"
|
||||
color="secondary"
|
||||
startIcon={<RemoveIcon />}
|
||||
onClick={() => dispatch(removeFavorite(props.contactInfo.uuid))}
|
||||
>
|
||||
favorites
|
||||
</Button>
|
||||
)}
|
||||
</Box>
|
||||
<Box
|
||||
sx={{
|
||||
@@ -64,8 +102,10 @@ const UpperBody: React.FC<Props> = (props) => {
|
||||
</IconButton>
|
||||
</Box>
|
||||
<Box sx={{ display: "flex", flexDirection: "column" }}>
|
||||
<Typography sx={{ textAlign: "right" }}>{Status.Online}</Typography>
|
||||
<Typography>MeetingName-1372</Typography>
|
||||
<Typography sx={{ textAlign: "right" }}>{status}</Typography>
|
||||
{detailedMeeting ? (
|
||||
<Typography>{detailedMeeting.topic}</Typography>
|
||||
) : null}
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
@@ -5,6 +5,9 @@ import CircleIcon from "@mui/icons-material/Circle";
|
||||
import { returnStatusColor } from "../../Utils";
|
||||
import UserLite from "../../../../api-bodies/UserLite";
|
||||
import Status from "../../Status";
|
||||
import { useAppSelector } from "../../../../redux/hooks";
|
||||
import { selectUserStatus } from "../../../../redux/slices/meetingsAndUserStatusSlice";
|
||||
import UserStatus from "../../../../api-bodies/UserStatus";
|
||||
|
||||
interface Props {
|
||||
contactInfo: UserLite;
|
||||
@@ -12,6 +15,11 @@ interface Props {
|
||||
}
|
||||
|
||||
const ContactItem: React.FC<Props> = (props) => {
|
||||
const userStatus: UserStatus | null = useAppSelector((state) =>
|
||||
selectUserStatus(state, props.contactInfo.uuid)
|
||||
);
|
||||
const status: Status =
|
||||
userStatus && userStatus.inMeeting ? Status.Online : Status.Offline;
|
||||
return (
|
||||
<ListItemButton
|
||||
onClick={() => {
|
||||
@@ -23,10 +31,10 @@ const ContactItem: React.FC<Props> = (props) => {
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
primary={props.contactInfo.name}
|
||||
secondary={Status.Online}
|
||||
secondary={status}
|
||||
sx={{ flexGrow: 1 }}
|
||||
/>
|
||||
<CircleIcon color={returnStatusColor(Status.Online)} />
|
||||
<CircleIcon color={returnStatusColor(status)} />
|
||||
</ListItemButton>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ const MeetingDetails: React.FC = () => {
|
||||
const meetingDetailsOpen = useAppSelector(selectMeetingDetailsOpen);
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
return (
|
||||
return meetingDetailsOpen.meeting ? (
|
||||
<Dialog
|
||||
fullScreen
|
||||
open={meetingDetailsOpen.open}
|
||||
@@ -21,7 +21,7 @@ const MeetingDetails: React.FC = () => {
|
||||
<Header meeting={meetingDetailsOpen.meeting} />
|
||||
<Body meeting={meetingDetailsOpen.meeting} />
|
||||
</Dialog>
|
||||
);
|
||||
) : null;
|
||||
};
|
||||
|
||||
export default MeetingDetails;
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
import DetailedMeeting from "../../api-bodies/DetailedMeeting";
|
||||
|
||||
const getMeetingStatus = (meeting: DetailedMeeting) => {
|
||||
const startDate = new Date(meeting.start);
|
||||
const endDate = new Date(startDate.getTime() + meeting.duration * 60000);
|
||||
const currentDate = new Date();
|
||||
if (currentDate > startDate && currentDate < endDate) return "Live";
|
||||
else if (currentDate < startDate) return "Scheduled";
|
||||
else return "Finished";
|
||||
};
|
||||
|
||||
const getUpcomingMeetingTime = (meeting: DetailedMeeting) => {
|
||||
const startDate = new Date(meeting.start);
|
||||
const endDate = new Date(startDate.getTime() + meeting.duration * 60000);
|
||||
const startTime = startDate
|
||||
.toTimeString()
|
||||
.split(" ")[0]
|
||||
.split(":")
|
||||
.slice(0, 2)
|
||||
.join(":");
|
||||
const endTime = endDate
|
||||
.toTimeString()
|
||||
.split(" ")[0]
|
||||
.split(":")
|
||||
.slice(0, 2)
|
||||
.join(":");
|
||||
return `${startTime} - ${endTime}`;
|
||||
};
|
||||
|
||||
export { getMeetingStatus, getUpcomingMeetingTime };
|
||||
@@ -9,12 +9,20 @@ import {
|
||||
import React from "react";
|
||||
import PersonOutlineIcon from "@mui/icons-material/PersonOutline";
|
||||
import DetailedMeeting from "../../../api-bodies/DetailedMeeting";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { selectUsers } from "../../../redux/slices/usersSlice";
|
||||
import { getMeetingStatus } from "../Utils";
|
||||
import UserLite from "../../../api-bodies/UserLite";
|
||||
|
||||
interface Props {
|
||||
meeting: DetailedMeeting | null;
|
||||
meeting: DetailedMeeting;
|
||||
}
|
||||
|
||||
const Body: React.FC<Props> = () => {
|
||||
const Body: React.FC<Props> = (props) => {
|
||||
const registrants: UserLite[] = useAppSelector((state) =>
|
||||
selectUsers(state, props.meeting.registrantIds)
|
||||
);
|
||||
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
@@ -34,7 +42,7 @@ const Body: React.FC<Props> = () => {
|
||||
}}
|
||||
>
|
||||
<Typography>Feb 10, 2022 10:45 am - 11:00 am</Typography>
|
||||
<Typography>Status: Live</Typography>
|
||||
<Typography>Status: {getMeetingStatus(props.meeting)}</Typography>
|
||||
<Typography>
|
||||
Topic: Lorem Ipsum is simply dummy text of the printing and
|
||||
typesetting industry. Lorem Ipsum has been the industrys standard
|
||||
@@ -56,20 +64,14 @@ const Body: React.FC<Props> = () => {
|
||||
<ListItem sx={{ borderBottom: 1 }}>
|
||||
<ListItemText primary="Invited" />
|
||||
</ListItem>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<PersonOutlineIcon />
|
||||
</ListItemIcon>
|
||||
<ListItemText primary="Taehee Choi" />
|
||||
</ListItem>
|
||||
</List>
|
||||
<List>
|
||||
<ListItem>
|
||||
<ListItemIcon>
|
||||
<PersonOutlineIcon />
|
||||
</ListItemIcon>
|
||||
<ListItemText primary="Taehee Choi" />
|
||||
</ListItem>
|
||||
{registrants.map((registrant, i) => (
|
||||
<ListItem key={i}>
|
||||
<ListItemIcon>
|
||||
<PersonOutlineIcon />
|
||||
</ListItemIcon>
|
||||
<ListItemText primary={registrant.name} />
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user