2021-09-02 19:05:13 -07:00
|
|
|
import { Layout } from 'antd';
|
2025-04-16 16:55:38 -07:00
|
|
|
import React, { useEffect } from 'react';
|
|
|
|
import { Route, Switch, useHistory, useLocation } from 'react-router-dom';
|
2025-01-29 20:42:01 -05:00
|
|
|
import styled from 'styled-components';
|
2025-04-16 16:55:38 -07:00
|
|
|
|
|
|
|
import DataHubTitle from '@app/DataHubTitle';
|
|
|
|
import EmbedRoutes from '@app/EmbedRoutes';
|
|
|
|
import { SearchRoutes } from '@app/SearchRoutes';
|
|
|
|
import { HomePage } from '@app/home/HomePage';
|
|
|
|
import { HomePage as HomePageV2 } from '@app/homeV2/HomePage';
|
|
|
|
import { IntroduceYourself } from '@app/homeV2/introduce/IntroduceYourself';
|
|
|
|
import { useSetUserPersona } from '@app/homeV2/persona/useUserPersona';
|
2025-06-30 21:28:55 +05:30
|
|
|
import { HomePage as HomePageNew } from '@app/homepageV2/HomePage';
|
2025-04-16 16:55:38 -07:00
|
|
|
import { useSetUserTitle } from '@app/identity/user/useUserTitle';
|
|
|
|
import { OnboardingContextProvider } from '@app/onboarding/OnboardingContextProvider';
|
2025-06-30 21:28:55 +05:30
|
|
|
import { useAppConfig } from '@app/useAppConfig';
|
2025-04-16 16:55:38 -07:00
|
|
|
import { useIsThemeV2, useSetThemeIsV2 } from '@app/useIsThemeV2';
|
2025-04-30 11:21:41 -04:00
|
|
|
import { useSetAppTheme } from '@app/useSetAppTheme';
|
2025-04-16 16:55:38 -07:00
|
|
|
import { useSetNavBarRedesignEnabled } from '@app/useShowNavBarRedesign';
|
|
|
|
import { NEW_ROUTE_MAP, PageRoutes } from '@conf/Global';
|
|
|
|
import { getRedirectUrl } from '@conf/utils';
|
2025-01-29 20:42:01 -05:00
|
|
|
|
|
|
|
const StyledLayout = styled(Layout)`
|
|
|
|
background-color: transparent;
|
|
|
|
`;
|
2021-09-02 19:05:13 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Container for all views behind an authentication wall.
|
|
|
|
*/
|
|
|
|
export const ProtectedRoutes = (): JSX.Element => {
|
2025-04-30 11:21:41 -04:00
|
|
|
useSetAppTheme();
|
2025-01-29 20:42:01 -05:00
|
|
|
useSetThemeIsV2();
|
|
|
|
useSetUserPersona();
|
|
|
|
useSetUserTitle();
|
|
|
|
useSetNavBarRedesignEnabled();
|
|
|
|
|
|
|
|
const isThemeV2 = useIsThemeV2();
|
2025-06-30 21:28:55 +05:30
|
|
|
const { config } = useAppConfig();
|
|
|
|
const showHomepageRedesign = config.featureFlags.showHomePageRedesign;
|
2025-01-29 20:42:01 -05:00
|
|
|
|
2025-06-30 21:28:55 +05:30
|
|
|
let FinalHomePage;
|
|
|
|
|
|
|
|
if (isThemeV2) {
|
|
|
|
FinalHomePage = showHomepageRedesign ? HomePageNew : HomePageV2;
|
|
|
|
} else {
|
|
|
|
FinalHomePage = HomePage;
|
|
|
|
}
|
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 (
|
2025-01-29 20:42:01 -05:00
|
|
|
<OnboardingContextProvider>
|
2025-02-19 10:50:13 -08:00
|
|
|
<DataHubTitle />
|
2025-01-29 20:42:01 -05:00
|
|
|
<StyledLayout className={isThemeV2 ? 'themeV2' : undefined}>
|
|
|
|
<Switch>
|
|
|
|
<Route exact path="/" render={() => <FinalHomePage />} />
|
|
|
|
<Route path={PageRoutes.EMBED} render={() => <EmbedRoutes />} />
|
|
|
|
<Route exact path={PageRoutes.INTRODUCE} render={() => <IntroduceYourself />} />
|
2025-02-19 10:50:13 -08:00
|
|
|
<Route path="/*" component={SearchRoutes} />
|
2025-01-29 20:42:01 -05:00
|
|
|
</Switch>
|
|
|
|
</StyledLayout>
|
|
|
|
</OnboardingContextProvider>
|
2021-09-02 19:05:13 -07:00
|
|
|
);
|
|
|
|
};
|