crap
This commit is contained in:
35
src/pages/RootPage/RootPage.tsx
Normal file
35
src/pages/RootPage/RootPage.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import {Outlet} from "@tanstack/react-router";
|
||||
import {useEffect} from "react";
|
||||
import {useSelector} from "react-redux";
|
||||
import {RootState} from "../../redux/store.ts";
|
||||
import {OpenAPI} from "../../client";
|
||||
import PageWrapper from "../PageWrapper/PageWrapper.tsx";
|
||||
|
||||
const RootPage = () => {
|
||||
const authState = useSelector((state: RootState) => state.auth);
|
||||
const rewriteLocalStorage = () => {
|
||||
const jsonData = JSON.stringify(authState);
|
||||
localStorage.setItem('authState', jsonData);
|
||||
}
|
||||
const setOpenApiToken = () => {
|
||||
OpenAPI.TOKEN = authState.accessToken;
|
||||
}
|
||||
useEffect(() => {
|
||||
rewriteLocalStorage();
|
||||
setOpenApiToken();
|
||||
}, [authState]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<PageWrapper>
|
||||
<Outlet/>
|
||||
</PageWrapper>
|
||||
|
||||
|
||||
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default RootPage;
|
||||
Reference in New Issue
Block a user