mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2025-05-14 10:31:07 +08:00
Allow querying for saved login session
This commit is contained in:
parent
1f668be499
commit
f411ea00a4
11 changed files with 107 additions and 32 deletions
|
@ -1,13 +1,29 @@
|
|||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import Sidebar from "../Sidebar/Sidebar";
|
||||
import Header from "../Header/Header";
|
||||
import styles from "../../styles";
|
||||
import { CheckSavedSession, UserInfo } from "../Api/Api";
|
||||
import { toggle_login } from "../../Features/Redux/Slices/Login/LoginSlice";
|
||||
import { SetUser } from "../../Features/Redux/Slices/LoggedInUserSlice/LoggedInUserSlice";
|
||||
import { useDispatch } from "react-redux";
|
||||
|
||||
export interface props {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export default function Container(props: props) {
|
||||
const dispatch = useDispatch();
|
||||
// Function to check for previous login session
|
||||
async function CheckPreviousSession() {
|
||||
if (await CheckSavedSession()) {
|
||||
await dispatch(toggle_login());
|
||||
await dispatch(SetUser(await UserInfo()));
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
CheckPreviousSession();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Header />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue