fix merge issues

This commit is contained in:
Taehee Choi 2022-03-30 04:42:50 -07:00
parent 4d4278b958
commit 59d7df1437

View File

@ -3,14 +3,11 @@ import useAuth from "./hooks/useAuth";
import Navbar from "./components/navbar/Navbar"; import Navbar from "./components/navbar/Navbar";
import Sidebar from "./components/sidebar/Sidebar"; import Sidebar from "./components/sidebar/Sidebar";
import { Alert, AlertTitle, Box, Snackbar, Typography } from "@mui/material"; import { Alert, AlertTitle, Box, Snackbar, Typography } from "@mui/material";
import { store } from "./redux/store"; import { selectMeetings } from "./redux/slices/meetingsAndUserStatusSlice";
import { fetchFavorites } from "./redux/slices/favoritesSlice"; import { selectMe } from "./redux/slices/usersSlice";
import { fetchMeetings, selectMeetings } from "./redux/slices/meetingsAndUserStatusSlice";
import { fetchUsers, selectMe } from "./redux/slices/usersSlice";
import { useAppDispatch, useAppSelector, useInterval } from "./redux/hooks"; import { useAppDispatch, useAppSelector, useInterval } from "./redux/hooks";
import DetailedMeeting from "./api-bodies/DetailedMeeting"; import DetailedMeeting from "./api-bodies/DetailedMeeting";
import React, { useState } from "react"; import React, { useState } from "react";
import { Box } from "@mui/material";
const ProtectedRoute = () => { const ProtectedRoute = () => {
const auth = useAuth(); const auth = useAuth();
@ -19,7 +16,9 @@ const ProtectedRoute = () => {
useAppDispatch(); useAppDispatch();
const currentUserUuid: string = useAppSelector(selectMe); const currentUserUuid: string = useAppSelector(selectMe);
const meetings: DetailedMeeting[] = useAppSelector(selectMeetings); const meetings: DetailedMeeting[] = useAppSelector(selectMeetings);
const currentUserMeetings = meetings.filter((m) => m.registrantIds.includes(currentUserUuid)); const currentUserMeetings = meetings.filter((m) =>
m.registrantIds.includes(currentUserUuid)
);
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [notifMeetings, setNotifMeetings] = useState([""]); const [notifMeetings, setNotifMeetings] = useState([""]);
@ -30,14 +29,20 @@ const ProtectedRoute = () => {
() => { () => {
console.log("polling"); console.log("polling");
const currentTime = Math.floor(Date.now() / sixtySec); // in minutes const currentTime = Math.floor(Date.now() / sixtySec); // in minutes
const upcomingMeetings = currentUserMeetings.filter((meeting) => const upcomingMeetings = currentUserMeetings.filter(
(currentTime == Math.floor(Date.parse(meeting.start) / sixtySec) - 15) || // 15 mins before meeting time (meeting) =>
(currentTime == Math.floor(Date.parse(meeting.start) / sixtySec) - 30) // or 30 mins before meeting time currentTime ==
Math.floor(Date.parse(meeting.startTime) / sixtySec) - 15 || // 15 mins before meeting time
currentTime ==
Math.floor(Date.parse(meeting.startTime) / sixtySec) - 30 // or 30 mins before meeting time
); );
if (upcomingMeetings.length != 0) { if (upcomingMeetings.length != 0) {
setOpen(true); setOpen(true);
const newNotifMeetings: string[] = upcomingMeetings.map((m) => { const newNotifMeetings: string[] = upcomingMeetings.map((m) => {
if (currentTime == Math.floor(Date.parse(m.start) / sixtySec) - 15) { if (
currentTime ==
Math.floor(Date.parse(m.startTime) / sixtySec) - 15
) {
return m.topic + " in 15 minutes"; return m.topic + " in 15 minutes";
} else { } else {
return m.topic + " in 30 minutes"; return m.topic + " in 30 minutes";
@ -49,7 +54,10 @@ const ProtectedRoute = () => {
sixtySec // poll time sixtySec // poll time
); );
const handleClose = (event?: React.SyntheticEvent | Event, reason?: string) => { const handleClose = (
event?: React.SyntheticEvent | Event,
reason?: string
) => {
if (reason == "clickaway") { if (reason == "clickaway") {
return; return;
} }
@ -62,9 +70,9 @@ const ProtectedRoute = () => {
<Snackbar open={open} onClose={handleClose}> <Snackbar open={open} onClose={handleClose}>
<Alert onClose={handleClose} severity="info" sx={{ width: "100%" }}> <Alert onClose={handleClose} severity="info" sx={{ width: "100%" }}>
<AlertTitle>Upcoming Meetings</AlertTitle> <AlertTitle>Upcoming Meetings</AlertTitle>
{notifMeetings.map((m, i) => {notifMeetings.map((m, i) => (
<Typography key={i}>{m}</Typography> <Typography key={i}>{m}</Typography>
)} ))}
</Alert> </Alert>
</Snackbar> </Snackbar>
{/* ----- */} {/* ----- */}