Skip to content

Commit

Permalink
VACMS-16917: DUW Result Page (#30684)
Browse files Browse the repository at this point in the history

---------

Co-authored-by: Chris Kim
  • Loading branch information
chriskim2311 authored Jul 10, 2024
1 parent 872ddde commit 6a8f9de
Show file tree
Hide file tree
Showing 9 changed files with 332 additions and 24 deletions.
52 changes: 52 additions & 0 deletions src/applications/discharge-wizard/components/v2/ResultsPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React, { useEffect } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import { pageSetup } from '../../utilities/page-setup';
import { ROUTES } from '../../constants';

import ResultsSummary from './resultsComponents/ResultsSummary';

const ResultsPage = ({ formResponses, router, viewedIntroPage }) => {
const H1 = 'Your Steps for Upgrading Your Discharge';

useEffect(
() => {
pageSetup(H1);
},
[H1],
);

useEffect(
() => {
if (!viewedIntroPage) {
router.push(ROUTES.HOME);
}
},
[router, viewedIntroPage],
);

return (
<article className="dw-guidance" data-testId="duw-results">
<h1>{H1}</h1>
<div className="medium-8">
<ResultsSummary formResponses={formResponses} />
</div>
</article>
);
};

ResultsPage.propTypes = {
formResponses: PropTypes.object.isRequired,
router: PropTypes.shape({
push: PropTypes.func,
}).isRequired,
viewedIntroPage: PropTypes.bool.isRequired,
};

const mapStateToProps = state => ({
formResponses: state?.dischargeUpgradeWizard?.duwForm?.form,
viewedIntroPage: state?.dischargeUpgradeWizard?.duwForm?.viewedIntroPage,
});

export default connect(mapStateToProps)(ResultsPage);
17 changes: 9 additions & 8 deletions src/applications/discharge-wizard/components/v2/ReviewPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ const ReviewPage = ({ formResponses, router, viewedIntroPage }) => {
[router, viewedIntroPage],
);

const onEditAnswerClick = route => {
router.push(route);
};

const renderReviewAnswers = () => {
return Object.keys(SHORT_NAME_MAP).map(shortName => {
if (formResponses[shortName] === null) {
Expand All @@ -43,15 +47,12 @@ const ReviewPage = ({ formResponses, router, viewedIntroPage }) => {
className="vads-u-margin-bottom--0 vads-u-padding-y--3 vads-u-padding-x--1p5 answer-review"
>
{reviewLabel}
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<a
aria-label={reviewLabel}
className="vads-u-padding-left--2"
href="#"
<va-link
class="hydrated vads-u-padding-left--2"
onClick={() => onEditAnswerClick(ROUTES[shortName])}
name={shortName}
>
Edit
</a>
text="Edit"
/>
</li>
)
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
determineBoardObj,
determineAirForceAFRBAPortal,
determineFormData,
} from '../../../helpers';

import {
SHORT_NAME_MAP,
RESPONSES,
} from '../../../constants/question-data-map';

const ResultsSummary = ({ formResponses }) => {
const forReconsideration =
[
RESPONSES.PREV_APPLICATION_TYPE_3A,
RESPONSES.PREV_APPLICATION_TYPE_3B,
].includes(formResponses[SHORT_NAME_MAP.PREV_APPLICATION_TYPE]) &&
![
RESPONSES.FAILURE_TO_EXHAUST_1A,
RESPONSES.FAILURE_TO_EXHAUST_1B,
].includes(formResponses[SHORT_NAME_MAP.FAILURE_TO_EXHAUST]);

const airForceAFRBAPortal = determineAirForceAFRBAPortal(formResponses);
const formNumber = determineFormData(formResponses).num;
const dischargeBoard = determineBoardObj(formResponses).name;
const serviceBranch = formResponses[SHORT_NAME_MAP.SERVICE_BRANCH];
const isReconsideration = forReconsideration ? ' for reconsideration' : '';

let summary = `Based on your answers, you need to complete Department of Defense (DoD) Form ${formNumber} and send it to the ${dischargeBoard} for the ${serviceBranch} ${isReconsideration}.`;

if (airForceAFRBAPortal) {
summary =
'Based on your answers, you need to complete an Application for Correction of Military Record (DD 149). You can download this form from the Air Force Review Boards Agency Website and Portal.';
}

return (
<section className="va-introtext">
<p>{summary}</p>
</section>
);
};

ResultsSummary.propTypes = {
formResponses: PropTypes.object.isRequired,
};

export default ResultsSummary;
105 changes: 102 additions & 3 deletions src/applications/discharge-wizard/helpers/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import moment from 'moment';
import { differenceInYears } from 'date-fns';
import * as options from 'platform/static-data/options-for-select';
import { questionLabels, prevApplicationYearCutoff } from '../constants';
import { SHORT_NAME_MAP, RESPONSES } from '../constants/question-data-map';
Expand Down Expand Up @@ -62,7 +63,7 @@ export const board = (formValues, noDRB) => {

if (formValues['1_branchOfService'] === 'airForce') {
return {
name: 'Air Force Review Boards Agency (AFDRB) for the Air Force',
name: 'Air Force Review Boards Agency (AFDRB)',
abbr: 'AFDRB',
};
}
Expand Down Expand Up @@ -260,13 +261,15 @@ export const deriveIsAirForceAFRBAPortal = formValues =>
board(formValues).abbr === 'BCMR' &&
formData(formValues).num === 149;

// v2 Helpers

export const answerReviewLabel = (key, formValues) => {
const answer = formValues[key];
const monthObj = options.months.find(
m => String(m.value) === formValues[SHORT_NAME_MAP.DISCHARGE_MONTH],
);

const dischargeMonth = monthObj && monthObj.label;
const dischargeMonth = (monthObj && monthObj.label) || '';

switch (key) {
case SHORT_NAME_MAP.SERVICE_BRANCH:
Expand All @@ -279,7 +282,7 @@ export const answerReviewLabel = (key, formValues) => {
return 'I was discharged before 1992.';
}

return `I was discharged in ${dischargeMonth || ''} ${formValues[key]}.`;
return `I was discharged in ${dischargeMonth} ${formValues[key]}.`;
case SHORT_NAME_MAP.PREV_APPLICATION:
if (answer === RESPONSES.PREV_APPLICATION_1) {
return 'I have previously applied for a discharge upgrade for this period of service.';
Expand Down Expand Up @@ -308,3 +311,99 @@ export const answerReviewLabel = (key, formValues) => {
}
}
};

export const determineBoardObj = (formResponses, noDRB) => {
if (!formResponses) {
return null;
}

const prevAppType = [
RESPONSES.PREV_APPLICATION_TYPE_1,
RESPONSES.PREV_APPLICATION_TYPE_4,
].includes(formResponses[SHORT_NAME_MAP.PREV_APPLICATION_TYPE]);

const noPrevApp =
formResponses[SHORT_NAME_MAP.PREV_APPLICATION] ===
RESPONSES.PREV_APPLICATION_2;

const preAppDateBefore = [
RESPONSES.PREV_APPLICATION_YEAR_1A,
RESPONSES.PREV_APPLICATION_YEAR_1B,
RESPONSES.PREV_APPLICATION_YEAR_1C,
].includes(formResponses[SHORT_NAME_MAP.PREV_APPLICATION_YEAR]);

const courtMartial =
formResponses[SHORT_NAME_MAP.COURT_MARTIAL] === RESPONSES.COURT_MARTIAL_1;

const transgender =
formResponses[SHORT_NAME_MAP.REASON] === RESPONSES.REASON_5;
const intention =
formResponses[SHORT_NAME_MAP.INTENTION] === RESPONSES.INTENTION_1;
const dischargeYear = formResponses[SHORT_NAME_MAP.DISCHARGE_YEAR];
const dischargeMonth = formResponses[SHORT_NAME_MAP.DISCHARGE_MONTH] || 0;

const oldDischarge =
differenceInYears(new Date(), new Date(dischargeMonth, dischargeYear)) >=
15;

const failureToExhaust = [
RESPONSES.FAILURE_TO_EXHAUST_1A,
RESPONSES.FAILURE_TO_EXHAUST_1B,
].includes(formResponses[SHORT_NAME_MAP.FAILURE_TO_EXHAUST]);

let boardObj = {
name: 'Board for Correction of Naval Records (BCNR)',
abbr: 'BCNR',
};
if (
[RESPONSES.ARMY, RESPONSES.AIR_FORCE, RESPONSES.COAST_GUARD].includes(
formResponses[SHORT_NAME_MAP.SERVICE_BRANCH],
)
) {
boardObj = {
name: 'Board for Correction of Military Records (BCMR)',
abbr: 'BCMR',
};
}

if (noDRB) {
return boardObj;
}

if (noPrevApp || preAppDateBefore || prevAppType || failureToExhaust) {
if (courtMartial || transgender || intention || oldDischarge) {
return boardObj;
}

if (formResponses[SHORT_NAME_MAP.SERVICE_BRANCH] === RESPONSES.AIR_FORCE) {
return {
name: 'Air Force Review Boards Agency (AFDRB)',
abbr: 'AFDRB',
};
}

return { name: 'Discharge Review Board (DRB)', abbr: 'DRB' };
}

return boardObj;
};

export const determineFormData = formResponses => {
const boardData = determineBoardObj(formResponses);
if (boardData?.abbr === 'DRB') {
return {
num: 293,
link:
'http://www.esd.whs.mil/Portals/54/Documents/DD/forms/dd/dd0293.pdf',
};
}
return {
num: 149,
link: 'https://www.esd.whs.mil/Portals/54/Documents/DD/forms/dd/dd0149.pdf',
};
};

export const determineAirForceAFRBAPortal = formResponses =>
formResponses[SHORT_NAME_MAP.SERVICE_BRANCH] === RESPONSES.AIR_FORCE &&
determineBoardObj(formResponses).abbr === 'BCMR' &&
determineFormData(formResponses).num === 149;
2 changes: 2 additions & 0 deletions src/applications/discharge-wizard/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import PrevApplicationYear from './components/v2/questions/PrevApplicationYear';
import PriorService from './components/v2/questions/PriorService';
import FailureToExhaust from './components/v2/questions/FailureToExhaust';
import ReviewPage from './components/v2/ReviewPage';
import ResultsPage from './components/v2/ResultsPage';

const envChildRoutes = environment.isProduction()
? [
Expand Down Expand Up @@ -47,6 +48,7 @@ const envChildRoutes = environment.isProduction()
{ path: 'prior-service', component: PriorService },
{ path: 'failure-to-exhaust', component: FailureToExhaust },
{ path: 'review', component: ReviewPage },
{ path: 'results', component: ResultsPage },
];
const routes = {
path: '/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,12 @@ xdescribe('Discharge Upgrade Wizard', () => {
h.selectRadio(h.FAILURE_TO_EXHAUST_INPUT, 1);
h.clickBack();

// // REVIEW
// h.verifyUrl(ROUTES.REVIEW);
// REVIEW
h.verifyUrl(ROUTES.REVIEW);

// FAILURE_TO_EXHAUST
h.verifyUrl(ROUTES.FAILURE_TO_EXHAUST);
h.clickBack();

// PREVIOUS_APPLICATION_TYPE
h.verifyUrl(ROUTES.PREV_APPLICATION_TYPE);
Expand Down
Loading

0 comments on commit 6a8f9de

Please sign in to comment.