simpler routing without react router...better for me
This commit is contained in:
@@ -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}</>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user