Merge pull request #46 from CPSC319-Winter-term-2/meetingspanel-fix
fixed the meetings panel bug
This commit is contained in:
commit
c35acb91d6
@ -3,12 +3,21 @@ import useAuth from "./hooks/useAuth";
|
||||
import Navbar from "./components/navbar/Navbar";
|
||||
import Sidebar from "./components/sidebar/Sidebar";
|
||||
import { Box } from "@mui/material";
|
||||
import { store } from "./redux/store";
|
||||
import { fetchFavorites } from "./redux/slices/favoritesSlice";
|
||||
import { fetchMeetings } from "./redux/slices/meetingsAndUserStatusSlice";
|
||||
import { fetchUsers } from "./redux/slices/usersSlice";
|
||||
|
||||
const ProtectedRoute = () => {
|
||||
const auth = useAuth();
|
||||
const location = useLocation();
|
||||
|
||||
/* Temporary data */
|
||||
if (auth?.isLoggedIn != undefined && auth?.isLoggedIn == true) {
|
||||
store.dispatch(fetchMeetings(auth?.uuid));
|
||||
store.dispatch(fetchUsers(auth?.uuid));
|
||||
store.dispatch(fetchFavorites(auth?.uuid));
|
||||
}
|
||||
return auth?.isLoggedIn ? (
|
||||
<>
|
||||
<Navbar />
|
||||
|
||||
@ -29,7 +29,11 @@ const MeetingsPanel: React.FC = () => {
|
||||
// );
|
||||
// participants.push(userLite);
|
||||
// });
|
||||
const [currentDate, setCurrentDate] = useState<Date>(new Date());
|
||||
|
||||
useEffect(() => {
|
||||
setInterval(() => setCurrentDate(new Date()), 1000);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="meetings-panel">
|
||||
@ -59,10 +63,6 @@ const MeetingsPanel: React.FC = () => {
|
||||
const startDatemil = startDate.getTime();
|
||||
const endDatemil = startDatemil + meeting.duration * 60000;
|
||||
const endDate = new Date(endDatemil);
|
||||
const [currentDate, setCurrentDate] = useState<Date>(new Date());
|
||||
useEffect(() => {
|
||||
setInterval(() => setCurrentDate(new Date()), 1000);
|
||||
}, []);
|
||||
|
||||
const currentDatemil = currentDate.getTime();
|
||||
|
||||
|
||||
@ -8,10 +8,6 @@ import hsbcLogo from "../../assets/logo-png.png";
|
||||
import zoomLogo from "../../assets/zoom.png";
|
||||
import LoginIcon from "@mui/icons-material/Login";
|
||||
import useAuth from "../../hooks/useAuth";
|
||||
import { store } from "../../redux/store";
|
||||
import { fetchFavorites } from "../../redux/slices/favoritesSlice";
|
||||
import { fetchMeetings } from "../../redux/slices/meetingsAndUserStatusSlice";
|
||||
import { fetchUsers } from "../../redux/slices/usersSlice";
|
||||
import axios from "../../api/axios";
|
||||
|
||||
interface LocationState {
|
||||
@ -27,7 +23,6 @@ const Login: React.FC = () => {
|
||||
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [logedInUser, setLogedInUser] = useState("");
|
||||
// const [errMsg, setErrMsg] = useState('');
|
||||
|
||||
// const userRef = useRef();
|
||||
@ -41,16 +36,12 @@ const Login: React.FC = () => {
|
||||
// setErrMsg('');
|
||||
// }, [user, pwd])
|
||||
|
||||
store.dispatch(fetchMeetings("1")); // temp fix
|
||||
store.dispatch(fetchUsers("1")); // temp fix
|
||||
store.dispatch(fetchFavorites("1")); // temp fix
|
||||
|
||||
const handleLogin = async(e: React.SyntheticEvent) => {
|
||||
e.preventDefault();
|
||||
|
||||
try {
|
||||
if (email === "" && password === "") {
|
||||
setAuth["email"] = email;
|
||||
setAuth["uuid"] = "";
|
||||
setAuth["isLoggedIn"] = true;
|
||||
navigate(from, { replace: true });
|
||||
}
|
||||
@ -69,9 +60,8 @@ const Login: React.FC = () => {
|
||||
console.log(response?.data);
|
||||
|
||||
if (logedInUserId != undefined) {
|
||||
setAuth["email"] = email;
|
||||
setAuth["uuid"] = logedInUserId;
|
||||
setAuth["isLoggedIn"] = true;
|
||||
// setLogedInUser(logedInUserId);
|
||||
navigate(from, { replace: true });
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
import { createContext, useState } from "react";
|
||||
|
||||
interface loginInfo {
|
||||
email: string;
|
||||
uuid: string;
|
||||
isLoggedIn: boolean;
|
||||
}
|
||||
|
||||
const AuthContext = createContext<loginInfo>({
|
||||
email: "",
|
||||
uuid: "",
|
||||
isLoggedIn: false,
|
||||
});
|
||||
|
||||
export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
const [auth] = useState<loginInfo>({ email: "", isLoggedIn: false });
|
||||
const [auth] = useState<loginInfo>({ uuid: "", isLoggedIn: false });
|
||||
|
||||
return <AuthContext.Provider value={auth}>{children}</AuthContext.Provider>;
|
||||
};
|
||||
|
||||
@ -2,7 +2,7 @@ import { useContext } from "react";
|
||||
import AuthContext from "../context/AuthProvider";
|
||||
|
||||
interface loginInfo {
|
||||
email: string;
|
||||
uuid: string;
|
||||
isLoggedIn: boolean;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user