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

@@ -4,9 +4,8 @@ import BodyClassName from 'react-body-classname';
import { TransitionGroup, CSSTransition } from 'react-transition-group';
import authenticationRoutes from 'routes/authentication';
import { FormattedMessage as T } from 'react-intl';
import withAuthentication from 'containers/Authentication/withAuthentication';
import { compose } from 'utils';
import Icon from 'components/Icon';
import { useIsAuthenticated } from 'hooks/state';
import 'style/pages/Authentication/Auth.scss'
@@ -14,14 +13,15 @@ function PageFade(props) {
return <CSSTransition {...props} classNames="authTransition" timeout={500} />;
}
function AuthenticationWrapper({ isAuthorized = false, ...rest }) {
export default function AuthenticationWrapper({ ...rest }) {
const to = { pathname: '/homepage' };
const location = useLocation();
const isAuthenticated = useIsAuthenticated();
const locationKey = location.pathname;
return (
<>
{isAuthorized ? (
{isAuthenticated ? (
<Redirect to={to} />
) : (
<BodyClassName className={'authentication'}>
@@ -61,7 +61,3 @@ function AuthenticationWrapper({ isAuthorized = false, ...rest }) {
</>
);
}
export default compose(
withAuthentication(({ isAuthorized }) => ({ isAuthorized })),
)(AuthenticationWrapper);