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