src/applications/discharge-wizard/components/questions/CourtMartial.jsx
import React from 'react';
import PropTypes from 'prop-types';
import Scroll from 'react-scroll';
import { VaRadio } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
// Relative Imports
import { shouldShowQuestion } from '../../helpers';
const { Element } = Scroll;
const CourtMartial = ({
formValues,
handleKeyDown,
scrollToLast,
updateField,
}) => {
const key = '7_courtMartial';
if (!formValues) {
return null;
}
if (!shouldShowQuestion(key, formValues.questions)) {
return null;
}
// explicit override for dd214 condition
if (formValues['4_reason'] === '8') {
return null;
}
const options = [
{
label: 'Yes, my discharge was the outcome of a general court-martial.',
value: '1',
},
{
label:
'No, my discharge was administrative or the outcome of a special or summary court-martial.',
value: '2',
},
{ label: "I'm not sure.", value: '3' },
];
const radioButtonProps = {
name: key,
label: 'Was your discharge the outcome of a general court-martial?',
'label-header-level': '2',
key,
value: formValues[key],
onVaValueChange: e => {
if (e.returnValue) {
updateField(key, e.detail.value);
}
},
onMouseDown: scrollToLast,
onKeyDown: handleKeyDown,
};
return (
<div className="vads-u-margin-top--6">
<Element name={key} />
<VaRadio {...radioButtonProps} uswds>
{options.map((option, index) => (
<va-radio-option
key={index}
label={option.label}
name={key}
value={option.value}
checked={formValues[key] === option.value}
/>
))}
</VaRadio>
</div>
);
};
CourtMartial.propTypes = {
formValues: PropTypes.object.isRequired,
handleKeyDown: PropTypes.func,
scrollToLast: PropTypes.func,
updateField: PropTypes.func,
};
export default CourtMartial;