adding route that works with creating user and such

This commit is contained in:
talksik
2022-03-17 22:45:53 -04:00
parent 4b2a7f7043
commit 013d2fcb16
10 changed files with 87 additions and 49 deletions
@@ -5,24 +5,27 @@ import { nirvanaApi } from "../../controller/nirvanaApi";
import { useEffect } from "react";
import { useGetUserDetails } from "../../controller/index";
export default function ProtectedRoute({ ...children }) {
export default function ProtectedRoute({
children,
}: {
children?: React.ReactNode;
}) {
const { isLoading, isError } = useGetUserDetails();
useEffect(() => {
// console.log(window.electronAPI.store.get(STORE_ITEMS.AUTH_TOKENS));
// nirvanaApi.getUserDetails();
}, []);
const navigate = useNavigate();
if (isLoading) return <span>please wait while we authenticate you</span>;
useEffect(() => {
if (isError) {
navigate("/login");
}
}, [isError]);
useEffect(() => {
// console.log(window.electronAPI.store.get(STORE_ITEMS.AUTH_TOKENS));
// nirvanaApi.getUserDetails();
}, []);
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}</>;