From d62e3426a26f8aaae70419ef6214192d0f9dd9b1 Mon Sep 17 00:00:00 2001 From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it> Date: Tue, 4 May 2021 09:45:03 +0200 Subject: [PATCH] Nest authuser components route --- src/App.tsx | 3 ++- src/components/AuthUser/AuthUser.tsx | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 9c5a50c..f56d532 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,12 +9,13 @@ import { NotFound } from 'components/NotFound/NotFound'; import { ProfilePage } from 'components/ProfilePage/ProfilePage'; import { Roles } from 'components/api/userRoles'; import { Unauthorized } from 'components/Unauthorized/Unauthorized'; +import { SignUpForm } from 'components/AuthUser/SignUpForm/SignUpForm'; export const App: FC = () => ( <Router> <div data-testid="App"> <Switch> - <Route path={NonAuthRoutes.signIn} component={AuthUser} /> + <Route path={NonAuthRoutes.auth} component={AuthUser} /> <Route exact path={NonAuthRoutes.home} component={LandingPage} /> <PrivateRoute path={AuthRoutes.dashboard} diff --git a/src/components/AuthUser/AuthUser.tsx b/src/components/AuthUser/AuthUser.tsx index 317a5f7..a30678c 100644 --- a/src/components/AuthUser/AuthUser.tsx +++ b/src/components/AuthUser/AuthUser.tsx @@ -1,7 +1,10 @@ import React, { FC, useEffect } from 'react'; import axios from 'axios'; import Container from '@material-ui/core/Container'; -import { SignInForm } from './SignInForm/SignInForm'; +import { Route, useRouteMatch } from 'react-router-dom'; +import { NonAuthRoutes } from 'components/api/routes'; +import { SignInForm } from 'components/AuthUser/SignInForm/SignInForm'; +import { SignUpForm } from 'components/AuthUser/SignUpForm/SignUpForm'; const configDjangoCookieName = (): void => { axios.defaults.xsrfHeaderName = 'X-CSRFTOKEN'; @@ -10,6 +13,7 @@ const configDjangoCookieName = (): void => { }; export const AuthUser: FC = () => { + const { path } = useRouteMatch(); configDjangoCookieName(); useEffect(() => { axios @@ -23,7 +27,8 @@ export const AuthUser: FC = () => { }, []); return ( <Container maxWidth="sm"> - <SignInForm /> + <Route path={`${path}${NonAuthRoutes.signIn}`} component={SignInForm} /> + <Route path={`${path}${NonAuthRoutes.signUp}`} component={SignUpForm} /> </Container> ); }; -- GitLab