2024-07-27 02:54:23 +05:30
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { Switch, Route, useLocation, useHistory } from 'react-router-dom';
|
2021-09-02 19:05:13 -07:00
|
|
|
import { Layout } from 'antd';
|
|
|
|
import { HomePage } from './home/HomePage';
|
2022-07-01 18:08:08 -04:00
|
|
|
import { SearchRoutes } from './SearchRoutes';
|
2024-01-17 18:15:36 -05:00
|
|
|
import EmbedRoutes from './EmbedRoutes';
|
2024-07-27 02:54:23 +05:30
|
|
|
import { NEW_ROUTE_MAP, PageRoutes } from '../conf/Global';
|
|
|
|
import { getRedirectUrl } from '../conf/utils';
|
2021-09-02 19:05:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Container for all views behind an authentication wall.
|
|
|
|
*/
|
|
|
|
export const ProtectedRoutes = (): JSX.Element => {
|
2024-07-27 02:54:23 +05:30
|
|
|
const location = useLocation();
|
|
|
|
const history = useHistory();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (location.pathname.indexOf('/Validation') !== -1) {
|
|
|
|
history.replace(getRedirectUrl(NEW_ROUTE_MAP));
|
|
|
|
}
|
|
|
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
|
|
}, [location]);
|
|
|
|
|
2021-09-02 19:05:13 -07:00
|
|
|
return (
|
2024-03-08 12:16:53 -08:00
|
|
|
<Layout>
|
|
|
|
<Switch>
|
|
|
|
<Route exact path="/" render={() => <HomePage />} />
|
|
|
|
<Route path={PageRoutes.EMBED} render={() => <EmbedRoutes />} />
|
|
|
|
<Route path="/*" render={() => <SearchRoutes />} />
|
|
|
|
</Switch>
|
|
|
|
</Layout>
|
2021-09-02 19:05:13 -07:00
|
|
|
);
|
|
|
|
};
|