mirror of
https://github.com/lemeow125/Ivy-Frontend.git
synced 2025-05-14 10:31:07 +08:00
Added individual product views and fixed login session checker
This commit is contained in:
parent
f411ea00a4
commit
48ed8f45c6
8 changed files with 83 additions and 26 deletions
|
@ -5,7 +5,8 @@ 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";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { LoginState } from "../../Interfaces/Interfaces";
|
||||
|
||||
export interface props {
|
||||
children: React.ReactNode;
|
||||
|
@ -13,11 +14,14 @@ export interface props {
|
|||
|
||||
export default function Container(props: props) {
|
||||
const dispatch = useDispatch();
|
||||
const logged_in = useSelector((state: LoginState) => state.logged_in.value);
|
||||
// Function to check for previous login session
|
||||
async function CheckPreviousSession() {
|
||||
if (await CheckSavedSession()) {
|
||||
await dispatch(toggle_login());
|
||||
await dispatch(SetUser(await UserInfo()));
|
||||
if (logged_in !== true) {
|
||||
await dispatch(toggle_login());
|
||||
await dispatch(SetUser(await UserInfo()));
|
||||
}
|
||||
}
|
||||
}
|
||||
useEffect(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue