Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependents | 94154: Fix redirect looping #33787

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 33 additions & 14 deletions src/applications/686c-674/containers/App.jsx
Original file line number Diff line number Diff line change
@@ -1,47 +1,66 @@
import React from 'react';
import { connect } from 'react-redux';
import RoutedSavableApp from 'platform/forms/save-in-progress/RoutedSavableApp';
import { VA_FORM_IDS } from '@department-of-veterans-affairs/platform-forms/constants';
// import manifest from '../manifest.json';
import { useBrowserMonitoring } from '~/platform/utilities/real-user-monitoring';
import { useFeatureToggle } from '~/platform/utilities/feature-toggles';
import manifest from '../manifest.json';
import formConfig from '../config/form';
import { DOC_TITLE } from '../config/constants';

function App({ location, children, isLoading, featureToggles, savedForms }) {
function App({
location,

Check warning on line 11 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:11:3:'location' is missing in props validation
children,

Check warning on line 12 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:12:3:'children' is missing in props validation
isLoggedIn,

Check warning on line 13 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:13:3:'isLoggedIn' is missing in props validation
isLoading,

Check warning on line 14 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:14:3:'isLoading' is missing in props validation
vaFileNumber,

Check warning on line 15 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:15:3:'vaFileNumber' is missing in props validation
featureToggles,

Check warning on line 16 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:16:3:'featureToggles' is missing in props validation
}) {
const { TOGGLE_NAMES } = useFeatureToggle();
useBrowserMonitoring({
location,
toggleName: TOGGLE_NAMES.disablityBenefitsBrowserMonitoringEnabled,
});

// Must match the H1
document.title = DOC_TITLE;

// Handle loading
if (isLoading || !featureToggles || featureToggles.loading) {

Check warning on line 28 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:28:54:'featureToggles.loading' is missing in props validation
return <va-loading-indicator message="Loading your information..." />;
}

const flipperV2 = featureToggles.vaDependentsV2;
const hasV1Form = savedForms.some(
form => form.form === VA_FORM_IDS.FORM_21_686C,
);
const hasV2Form = savedForms.some(
form => form.form === VA_FORM_IDS.FORM_21_686CV2,
);

const shouldUseV2 = hasV2Form || (flipperV2 && !hasV1Form);
if (!shouldUseV2) {
if (!featureToggles.vaDependentsV2) {

Check warning on line 32 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:32:23:'featureToggles.vaDependentsV2' is missing in props validation
window.location.href = '/view-change-dependents/add-remove-form-21-686c/';
return <></>;
}

return (
const content = (
<article id="form-686c" data-location={`${location?.pathname?.slice(1)}`}>

Check warning on line 38 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:38:57:'location.pathname' is missing in props validation

Check warning on line 38 in src/applications/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/686c-674/containers/App.jsx:38:67:'location.pathname.slice' is missing in props validation
<RoutedSavableApp formConfig={formConfig} currentLocation={location}>
{children}
</RoutedSavableApp>
</article>
);

// If on intro page, just return
if (location.pathname === '/introduction') {
return content;
}

// If a user is not logged in OR
// a user is logged in, but hasn't gone through va file number validation
// redirect them to the introduction page.
if (
!isLoggedIn ||
(isLoggedIn && !vaFileNumber?.hasVaFileNumber?.VALIDVAFILENUMBER)
) {
document.location.replace(`${manifest.rootUrl}`);
return (
<va-loading-indicator message="Redirecting to introduction page..." />
);
}

return content;
}

const mapStateToProps = state => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

Check warning on line 1 in src/applications/disability-benefits/686c-674/containers/App.jsx

View workflow job for this annotation

GitHub Actions / App Isolation Annotations

Staged Continuous Deployment App Isolation Conflict

*WARNING* This PR contains changes related to an application that is currently not isolated. As of Feb 3, 2025 deployment may no longer be possible for apps that are not isolated. Please isolate this app from other directories in 'src/applications' to prevent future deployment issues. More information on your app's status can be seen here: https://department-of-veterans-affairs.github.io/veteran-facing-services-tools/frontend-support-dashboard/cross-app-import-report Please reach out to Frontend Platform Support with any questions.
import { connect } from 'react-redux';
import RoutedSavableApp from 'platform/forms/save-in-progress/RoutedSavableApp';
import { VA_FORM_IDS } from '@department-of-veterans-affairs/platform-forms/constants';
import { useBrowserMonitoring } from '~/platform/utilities/real-user-monitoring';
import { useFeatureToggle } from '~/platform/utilities/feature-toggles';
import manifest from '../manifest.json';
Expand All @@ -15,7 +14,6 @@
isLoading,
vaFileNumber,
featureToggles,
savedForms,
}) {
const { TOGGLE_NAMES } = useFeatureToggle();
useBrowserMonitoring({
Expand All @@ -31,16 +29,7 @@
return <va-loading-indicator message="Loading your information..." />;
}

const flipperV2 = featureToggles.vaDependentsV2;
const hasV1Form = savedForms.some(
form => form.form === VA_FORM_IDS.FORM_21_686C,
);
const hasV2Form = savedForms.some(
form => form.form === VA_FORM_IDS.FORM_21_686CV2,
);

const shouldUseV2 = hasV2Form || (flipperV2 && !hasV1Form);
if (shouldUseV2) {
if (featureToggles.vaDependentsV2) {
window.location.href =
'/view-change-dependents/add-remove-form-21-686c-v2/';
return <></>;
Expand All @@ -52,6 +41,7 @@
</RoutedSavableApp>
</article>
);

// If on intro page, just return
if (location.pathname === '/introduction') {
return content;
Expand Down
Loading