import {createRootRoute, redirect} from "@tanstack/react-router";
import RootPage from "../pages/RootPage/RootPage.tsx";

export const Route = createRootRoute({
    component: RootPage,
    beforeLoad: async ({location}) => {
        const isAuthorized = JSON.parse(localStorage.getItem('authState') || '{}')['isAuthorized'];
        if (!isAuthorized && location.pathname !== '/login') {
            throw redirect({
                to: '/login',
            })
        }
    }
})