fix: redirect to auth

This commit is contained in:
Sergey Yarkov 2021-08-25 17:47:43 +03:00
parent f48c1d2a2c
commit 511f919ffe
3 changed files with 6 additions and 4 deletions

View File

@ -21,9 +21,11 @@ import { UserRoleEnum } from 'enums';
import { useRootStore } from 'hooks/useRootStore';
const App = () => {
const { uiStore } = useRootStore();
const {
uiStore: { history },
} = useRootStore();
return (
<Router history={uiStore.history}>
<Router history={history}>
<Switch>
<PrivateRoute exact path='/' component={MainPage} title='Home' />
<PrivateRoute path='/courses' component={CoursesPage} title='Courses' />

View File

@ -32,7 +32,7 @@ const PrivateRoute: React.FC<IPrivateRouteProps> = ({ component: Component, titl
</Layout>
</ErrorBoundary>
) : (
<Redirect to={{ pathname: '/auth', state: { from: props.location } }} />
<Redirect to='/auth' />
)
}
/>

View File

@ -15,7 +15,7 @@ export default class UIStore {
makeAutoObservable(this);
this.history.listen(({ pathname }) => {
console.log('path chaged');
console.log(`[history]: pathname changed to ${pathname}`);
this.location = pathname;
});