refactoring: authentication with react-query.

This commit is contained in:
a.bouhuolia
2021-02-20 15:33:20 +02:00
parent 8f680e2068
commit a079f711d4
57 changed files with 1629 additions and 1290 deletions

View File

@@ -1,14 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
import BodyClassName from 'react-body-classname';
import { Redirect } from 'react-router-dom';
import withAuthentication from 'containers/Authentication/withAuthentication';
import { compose } from 'utils';
import { useIsAuthenticated } from 'hooks/state';
export default function PrivateRoute({ component: Component, ...rest }) {
const isAuthenticated = useIsAuthenticated();
function PrivateRoute({ component: Component, isAuthorized = false, ...rest }) {
return (
<BodyClassName className={''}>
{isAuthorized ? (
{isAuthenticated ? (
<Component />
) : (
<Redirect
@@ -20,7 +20,3 @@ function PrivateRoute({ component: Component, isAuthorized = false, ...rest }) {
</BodyClassName>
);
}
export default compose(
withAuthentication(({ isAuthorized }) => ({ isAuthorized })),
)(PrivateRoute);