simpler routing without react router...better for me

This commit is contained in:
talksik
2022-03-18 10:29:53 -04:00
parent aca9c5a12d
commit 9950a69efa
7 changed files with 14 additions and 55 deletions
@@ -1,5 +1,4 @@
import { Route, useNavigate } from "react-router-dom";
import Login from "../../pages/Login";
import { STORE_ITEMS } from "../../electron/store";
import { nirvanaApi } from "../../controller/nirvanaApi";
import { useEffect } from "react";
@@ -10,21 +9,20 @@ export default function ProtectedRoute({
}: {
children?: React.ReactNode;
}) {
const { isLoading, isError } = useGetUserDetails();
const navigate = useNavigate();
const { isLoading, isError, refetch } = useGetUserDetails();
useEffect(() => {
// console.log(window.electronAPI.store.get(STORE_ITEMS.AUTH_TOKENS));
// nirvanaApi.getUserDetails();
}, []);
if (isLoading || true)
return <span>please wait while we authenticate you</span>;
if (isError) {
navigate("/login");
return <Login onReady={() => refetch()} />;
}
if (isLoading) return <span>please wait while we authenticate you</span>;
// if we can successfully get user details, we are good to continue
return <>{children}</>;
}