Skip to content
Snippets Groups Projects
Verified Commit 53d79418 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Rename state, delete import.

parent e25a8ef4
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!44New route type (RestrictedRoute) and better api calls.
Pipeline #12195 failed
import React, { useState, useEffect, useContext } from 'react';
import React, { useState, useEffect } from 'react';
import { Route, Redirect, RouteProps } from 'react-router-dom';
import { AuthRoutes, NonAuthRoutes } from 'api/routes';
import { AuthRoutes } from 'api/routes';
import { isAuthenticated } from 'api/isAuthenticated';
import { CircularProgress } from '@material-ui/core';
......@@ -21,7 +21,7 @@ type Props = {
/* eslint-disable react/jsx-props-no-spreading */
export const RestrictedRoute = ({ Component, path }: Props): JSX.Element => {
const [authUser, setAuthUser] = useState<boolean>(false);
const [isAuth, setIsAuth] = useState<boolean>(false);
const [isLoading, setLoading] = useState<boolean>(false);
useEffect(() => {
......@@ -29,7 +29,7 @@ export const RestrictedRoute = ({ Component, path }: Props): JSX.Element => {
isAuthenticated().then((state) => {
if (isMounted) {
setAuthUser(state);
setIsAuth(state);
setLoading(true);
}
});
......@@ -45,7 +45,7 @@ export const RestrictedRoute = ({ Component, path }: Props): JSX.Element => {
<Route
path={path}
render={(props: RouteProps) =>
!authUser ? (
!isAuth ? (
// Redirect to component.
<Component {...props} />
) : (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment