src/applications/accredited-representative-portal/containers/App.jsx
import React from 'react';
import { Outlet, useNavigation } from 'react-router-dom';
import { VaLoadingIndicator } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import environment from '@department-of-veterans-affairs/platform-utilities/environment';
import { useFeatureToggle } from '~/platform/utilities/feature-toggles/useFeatureToggle';
import Header from '../components/Header';
import Footer from '../components/Footer';
function App() {
const {
TOGGLE_NAMES: { accreditedRepresentativePortalFrontend: appToggleKey },
useToggleLoadingValue,
useToggleValue,
} = useFeatureToggle();
const isAppEnabled = useToggleValue(appToggleKey);
const isProduction = window.Cypress || environment.isProduction();
const shouldExitApp = isProduction && !isAppEnabled;
const isAppToggleLoading = useToggleLoadingValue(appToggleKey);
const navigation = useNavigation();
if (isAppToggleLoading) {
return (
<div className="vads-u-margin-y--5">
<VaLoadingIndicator message="Loading the Accredited Representative Portal..." />
</div>
);
}
if (shouldExitApp) {
window.location.replace('/');
return null;
}
return (
<div className="container">
<Header />
{navigation.state === 'loading' ? (
<VaLoadingIndicator message="Loading..." />
) : (
<Outlet />
)}
<Footer />
</div>
);
}
export default App;