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

VACMS-16913: DUW questions 3 #29030

Merged
merged 36 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
662aa0c
wip
Mar 25, 2024
2c0c12d
branching logic
Mar 27, 2024
d5bed59
initial tests
Mar 27, 2024
d0cdbdf
update error message
Mar 27, 2024
7a12603
remove
Mar 27, 2024
18b9748
test fixes
Mar 28, 2024
731c62b
comment out flaky unit tests
Mar 29, 2024
8166a7c
content updates
Mar 29, 2024
7f23736
Merge branch 'main' into 16910-branch-year-month-logic
chriskim2311 Mar 30, 2024
cb7f082
Merge branch 'main' into 16910-branch-year-month-logic
chriskim2311 Apr 1, 2024
ef17910
Merge branch 'main' into 16910-branch-year-month-logic
chriskim2311 Apr 1, 2024
e8eb69c
init commit for questions
Apr 4, 2024
edc3771
a11y and pr comment changes
Apr 4, 2024
40a9457
eslint fix
Apr 4, 2024
3f65579
merge
Apr 4, 2024
4d6ca56
more fixes
Apr 5, 2024
c6d8d8e
Merge branch '16910-branch-year-month-logic' of https://github.com/de…
Apr 5, 2024
5a60f2c
cypress tests
Apr 5, 2024
7df3aa4
change focus errors
Apr 5, 2024
f67f0c3
Merge branch '16910-branch-year-month-logic' of https://github.com/de…
Apr 5, 2024
62fd84f
merge conflict
Apr 5, 2024
c9c9f78
update cypress tests
Apr 8, 2024
fb0ebf1
Merge branch 'main' into 16913-questions-3
chriskim2311 Apr 8, 2024
29b4558
update tests again
Apr 8, 2024
3a88d57
Merge branch '16913-questions-3' of https://github.com/department-of-…
Apr 8, 2024
67e252d
update
Apr 9, 2024
99e4a05
testing cypress test routes
Apr 9, 2024
782a6aa
remove cypress flaky test
Apr 9, 2024
e499b51
revert routes test
Apr 10, 2024
e484cb2
change imports
Apr 10, 2024
7790a4e
PR comments changes
Apr 10, 2024
16a0b88
html cleanup
Apr 10, 2024
a95b29c
display question cleanup
Apr 11, 2024
47159b6
PR comment changes
Apr 11, 2024
99a4b78
Updates to navigation forward for Discharge Upgrade Wizard (#29130)
chriskim2311 Apr 11, 2024
88924bc
Merge branch '16913-questions-3' of https://github.com/department-of-…
Apr 11, 2024
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
38 changes: 35 additions & 3 deletions src/applications/discharge-wizard/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import {
DW_UPDATE_FIELD,
// v2 actions
DUW_UPDATE_FORM_STORE,
DUW_VIEWED_INTRO_PAGE,
DUW_UPDATE_SERVICE_BRANCH,
DUW_UPDATE_DISCHARGE_YEAR,
DUW_UPDATE_DISCHARGE_MONTH,
DUW_UPDATE_FORM_STORE,
DUW_UPDATE_REASON,
DUW_UPDATE_DISCHARGE_TYPE,
DUW_UPDATE_COURT_MARTIAL,
DUW_UPDATE_INTENTION,
} from '../constants';

export const updateField = (key, value) => {
Expand All @@ -16,6 +20,13 @@ export const updateField = (key, value) => {
};
};

export const updateFormStore = value => {
return {
type: DUW_UPDATE_FORM_STORE,
payload: value,
};
};

export const updateIntroPageViewed = value => {
return {
type: DUW_VIEWED_INTRO_PAGE,
Expand Down Expand Up @@ -44,9 +55,30 @@ export const updateDischargeMonth = value => {
};
};

export const updateFormStore = value => {
export const updateReason = value => {
return {
type: DUW_UPDATE_FORM_STORE,
type: DUW_UPDATE_REASON,
payload: value,
};
};

export const updateCourtMartial = value => {
return {
type: DUW_UPDATE_COURT_MARTIAL,
payload: value,
};
};

export const updateIntention = value => {
return {
type: DUW_UPDATE_INTENTION,
payload: value,
};
};

export const updateDischargeType = value => {
return {
type: DUW_UPDATE_DISCHARGE_TYPE,
payload: value,
};
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';
import environment from 'platform/utilities/environment';

Check warning on line 3 in src/applications/discharge-wizard/components/DischargeWizardApp.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/discharge-wizard/components/DischargeWizardApp.jsx:3:1:Importing from platform via platform/utilities is deprecated. Import from @department-of-veterans-affairs/platform-utilities instead or check babel.config.json for an alias to the import.
import Breadcrumbs from './Breadcrumbs';
import BreadcrumbsV2 from './v2/BreadcrumbsV2';

export default function DischargeWizardApp({ children }) {
const isProd = environment.isProduction();
Expand All @@ -16,7 +17,7 @@
}
return (
<div className="row discharge-wizard-v2 vads-u-padding-x--1 large-screen:vads-u-padding-x--0 vads-u-padding-bottom--8">
<Breadcrumbs />
<BreadcrumbsV2 />
<div className="usa-width-two-thirds medium-8 columns">{children}</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import { VaBreadcrumbs } from '@department-of-veterans-affairs/web-components/react-bindings';

const BreadcrumbsV2 = () => (
<VaBreadcrumbs
class="vads-u-margin-left--1p5"
label="Breadcrumbs"
uswds
breadcrumbList={[
{
href: '/',
label: 'Home',
},
{
href: '/discharge-upgrade-instructions/introduction',
label: 'Discharge upgrade',
},
]}
/>
);

export default BreadcrumbsV2;
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const HomePage = ({ router, setIntroPageViewed }) => {
{/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}
<Link
className="vads-c-action-link--green"
data-testid="duw-start-form"
href="#"
onClick={startForm}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
QUESTION_MAP,
RESPONSES,
SHORT_NAME_MAP,
} from '../../../constants/question-data-map';
import RadioGroup from './shared/RadioGroup';
import { updateCourtMartial } from '../../../actions';
import { pageSetup } from '../../../utilities/page-setup';
import { ROUTES } from '../../../constants';

const CourtMartial = ({
formResponses,
setCourtMartial,
router,
viewedIntroPage,
}) => {
const [formError, setFormError] = useState(false);
const shortName = SHORT_NAME_MAP.COURT_MARTIAL;
const H1 = QUESTION_MAP[shortName];
const courtMartial = formResponses[shortName];
const { COURT_MARTIAL_1, COURT_MARTIAL_2, COURT_MARTIAL_3 } = RESPONSES;

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

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

return (
<RadioGroup
formError={formError}
formResponses={formResponses}
formValue={courtMartial}
H1={H1}
responses={[COURT_MARTIAL_1, COURT_MARTIAL_2, COURT_MARTIAL_3]}
router={router}
setFormError={setFormError}
shortName={shortName}
testId="duw-court_martial"
valueSetter={setCourtMartial}
/>
);
};

CourtMartial.propTypes = {
formResponses: PropTypes.object,
router: PropTypes.shape({
chriskim2311 marked this conversation as resolved.
Show resolved Hide resolved
push: PropTypes.func,
}),
setCourtMartial: PropTypes.func,
viewedIntroPage: PropTypes.bool,
};

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

const mapDispatchToProps = {
setCourtMartial: updateCourtMartial,
};

export default connect(
mapStateToProps,
mapDispatchToProps,
)(CourtMartial);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import PropTypes from 'prop-types';
import { connect } from 'react-redux';

import { months } from 'platform/static-data/options-for-select';

Check warning on line 5 in src/applications/discharge-wizard/components/v2/questions/DischargeMonth.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/discharge-wizard/components/v2/questions/DischargeMonth.jsx:5:1:Importing from platform via platform/static-data is deprecated. Import from @department-of-veterans-affairs/platform-static-data instead or check babel.config.json for an alias to the import.
import {
QUESTION_MAP,
SHORT_NAME_MAP,
Expand Down Expand Up @@ -42,7 +42,11 @@
const dischargeMonth = formResponses[shortName];
const monthOptions = months.map(month => {
return (
<option key={month.value} value={month.value}>
<option
data-testid="va-select-option"
key={month.value}
value={month.value}
>
{month.label}
</option>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
QUESTION_MAP,
RESPONSES,
SHORT_NAME_MAP,
} from '../../../constants/question-data-map';
import RadioGroup from './shared/RadioGroup';
import { updateDischargeType } from '../../../actions';
import { pageSetup } from '../../../utilities/page-setup';
import { ROUTES } from '../../../constants';

const DischargeType = ({
formResponses,
setDischargeType,
router,
viewedIntroPage,
}) => {
const [formError, setFormError] = useState(false);
const shortName = SHORT_NAME_MAP.DISCHARGE_TYPE;
const H1 = QUESTION_MAP[shortName];
const dischargeType = formResponses[shortName];
const { DISCHARGE_TYPE_1, DISCHARGE_TYPE_2 } = RESPONSES;

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

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

return (
<RadioGroup
formError={formError}
formResponses={formResponses}
formValue={dischargeType}
H1={H1}
responses={[DISCHARGE_TYPE_1, DISCHARGE_TYPE_2]}
router={router}
setFormError={setFormError}
shortName={shortName}
testId="duw-discharge_type"
valueSetter={setDischargeType}
/>
);
};

DischargeType.propTypes = {
formResponses: PropTypes.object,
setDischargeType: PropTypes.func,
router: PropTypes.shape({

Check warning on line 61 in src/applications/discharge-wizard/components/v2/questions/DischargeType.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/discharge-wizard/components/v2/questions/DischargeType.jsx:61:3:Prop types declarations should be sorted alphabetically
chriskim2311 marked this conversation as resolved.
Show resolved Hide resolved
push: PropTypes.func,
}),
viewedIntroPage: PropTypes.bool,
};

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

const mapDispatchToProps = {
setDischargeType: updateDischargeType,
};

export default connect(
mapStateToProps,
mapDispatchToProps,
)(DischargeType);
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ const DischargeYear = ({
const yearOptions = range(currentYear - 1992).map(i => {
const year = currentYear - i;
return (
<option key={i} value={year.toString()}>
<option data-testid="va-select-option" key={i} value={year.toString()}>
{year.toString()}
</option>
);
});
const before1992Key = yearOptions.length + 1;

yearOptions.push(
<option key={before1992Key} value="1991">
<option data-testid="va-select-option" key={before1992Key} value="1991">
Before 1992
</option>,
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React, { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import {
QUESTION_MAP,
RESPONSES,
SHORT_NAME_MAP,
} from '../../../constants/question-data-map';
import RadioGroup from './shared/RadioGroup';
import { updateIntention } from '../../../actions';
import { pageSetup } from '../../../utilities/page-setup';
import { ROUTES } from '../../../constants';

const Intention = ({
formResponses,
setIntention,
router,
viewedIntroPage,
}) => {
const [formError, setFormError] = useState(false);
const shortName = SHORT_NAME_MAP.INTENTION;
const H1 = QUESTION_MAP[shortName];
const intention = formResponses[shortName];
const { INTENTION_1, INTENTION_2 } = RESPONSES;

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

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

return (
<RadioGroup
formError={formError}
formResponses={formResponses}
formValue={intention}
H1={H1}
responses={[INTENTION_1, INTENTION_2]}
router={router}
setFormError={setFormError}
shortName={shortName}
testId="duw-intention"
valueSetter={setIntention}
/>
);
};

Intention.propTypes = {
formResponses: PropTypes.object,
setIntention: PropTypes.func,
router: PropTypes.shape({

Check warning on line 61 in src/applications/discharge-wizard/components/v2/questions/Intention.jsx

View workflow job for this annotation

GitHub Actions / Linting (Files Changed)

src/applications/discharge-wizard/components/v2/questions/Intention.jsx:61:3:Prop types declarations should be sorted alphabetically
chriskim2311 marked this conversation as resolved.
Show resolved Hide resolved
push: PropTypes.func,
}),
viewedIntroPage: PropTypes.bool,
};

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

const mapDispatchToProps = {
setIntention: updateIntention,
};

export default connect(
mapStateToProps,
mapDispatchToProps,
)(Intention);
Loading
Loading