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