mirror of
https://github.com/sergeyyarkov/educt-client.git
synced 2026-10-11 10:19:22 +03:00
fix: redirect to auth
This commit is contained in:
parent
f48c1d2a2c
commit
511f919ffe
@ -21,9 +21,11 @@ import { UserRoleEnum } from 'enums';
|
|||||||
import { useRootStore } from 'hooks/useRootStore';
|
import { useRootStore } from 'hooks/useRootStore';
|
||||||
|
|
||||||
const App = () => {
|
const App = () => {
|
||||||
const { uiStore } = useRootStore();
|
const {
|
||||||
|
uiStore: { history },
|
||||||
|
} = useRootStore();
|
||||||
return (
|
return (
|
||||||
<Router history={uiStore.history}>
|
<Router history={history}>
|
||||||
<Switch>
|
<Switch>
|
||||||
<PrivateRoute exact path='/' component={MainPage} title='Home' />
|
<PrivateRoute exact path='/' component={MainPage} title='Home' />
|
||||||
<PrivateRoute path='/courses' component={CoursesPage} title='Courses' />
|
<PrivateRoute path='/courses' component={CoursesPage} title='Courses' />
|
||||||
|
|||||||
@ -32,7 +32,7 @@ const PrivateRoute: React.FC<IPrivateRouteProps> = ({ component: Component, titl
|
|||||||
</Layout>
|
</Layout>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
) : (
|
) : (
|
||||||
<Redirect to={{ pathname: '/auth', state: { from: props.location } }} />
|
<Redirect to='/auth' />
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -15,7 +15,7 @@ export default class UIStore {
|
|||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
|
|
||||||
this.history.listen(({ pathname }) => {
|
this.history.listen(({ pathname }) => {
|
||||||
console.log('path chaged');
|
console.log(`[history]: pathname changed to ${pathname}`);
|
||||||
|
|
||||||
this.location = pathname;
|
this.location = pathname;
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user