Skip to content

Commit

Permalink
pdf transform logic now matches backend shape (#33100)
Browse files Browse the repository at this point in the history
* pdf transform logic now matches backend shape

* Updated action link titles

* Open link in new tab

* Opens link in new tab

* Updated redirect
  • Loading branch information
cosu419 authored Nov 25, 2024
1 parent 9924cc0 commit 0bd6f28
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const ClaimantTypeForm = props => {
return (
<div className="vads-u-margin-top--2p5">
<FormTitle
title="Request help from a VA accredited representative or VSO"
title="Fill out your form to request help"
subTitle="VA Forms 21-22 and 21-22a"
/>
<h3>Tell us who you are</h3>{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ function ProfileNotUpdatedNote(props) {
<>
<va-link
href="https://va.gov"
text="Find out how to change you address in your VA.gov profile (opens in
text="Find out how to change your address in your VA.gov profile (opens in
new tab)"
external
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ const SelectAccreditedRepresentative = props => {
<va-link
href="/get-help-from-accredited-representative/find-rep"
text="Find a VA accredited representative or VSO (opens in new tab)"
external
/>
<FormNavButtons goBack={handleGoBack} goForward={handleGoForward} />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const IntroductionPage = props => {
<article className="schemaform-intro">
<div className="title-section">
<FormTitle
title="Request help from a VA accredited representative or VSO"
title="Fill out your form to request help"
subTitle="VA Form 21-22 and VA Form 21-22a"
/>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function NextStepsPage() {
return (
<div>
<FormTitle
title="Request help from a VA accredited representative or VSO"
title="Fill out your form to request help"
subTitle={getFormSubtitle(formData)}
/>
<h2>Your next steps</h2>
Expand All @@ -43,7 +43,11 @@ export default function NextStepsPage() {
After your form is signed, you or the accredited {repType} can submit it
online, by mail, or in person.
</p>
<va-link href="" text="Learn how to submit your form" />
<va-link
href="/get-help-from-accredited-representative"
text="Learn how to submit your form"
external
/>
<h2 className="vads-u-margin-top--3">
After you submit your printed form
</h2>
Expand Down
26 changes: 20 additions & 6 deletions src/applications/representative-appoint/utilities/pdfTransform.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getRepType } from './helpers';

function consentLimitsTransform(formData) {
const authorizeRecords = formData['view:authorizeRecordsCheckbox'] || {};
const authorizeRecords = formData.authorizeMedicalSelectCheckbox || {};

const conditionsMap = {
alcoholRecords: 'ALCOHOLISM',
Expand All @@ -15,6 +15,13 @@ function consentLimitsTransform(formData) {
.map(([, value]) => value);
}

function yesNoToBoolean(field) {
if (typeof field !== 'string') {
return null;
}
return !!field.trim().startsWith('Yes');
}

export function pdfTransform(formData) {
const {
veteranFullName,
Expand All @@ -29,14 +36,17 @@ export function pdfTransform(formData) {
applicantName,
applicantDOB,
claimantRelationship,
'Branch of Service': serviceBranch,
homeAddress: claimantAddress,
authorizationRadio,
authorizeAddressRadio,
authorizeInsideVARadio,
authorizeOutsideVARadio,
authorizeNamesTextArea,
applicantPhone,
applicantEmail,
} = formData;

// extracts address information
const createAddress = (address = {}) => ({
addressLine1: address.street || '',
addressLine2: address.street2 || '',
Expand All @@ -47,7 +57,6 @@ export function pdfTransform(formData) {
zipCodeSuffix: address.zipCodeSuffix || '',
});

// construct veteran object
const veteran = {
name: {
first: veteranFullName?.first || '',
Expand All @@ -58,7 +67,7 @@ export function pdfTransform(formData) {
vaFileNumber,
dateOfBirth,
serviceNumber,
insuranceNumbers: [],
serviceBranch,
address: createAddress(homeAddress),
phone,
email,
Expand Down Expand Up @@ -102,9 +111,14 @@ export function pdfTransform(formData) {

return {
veteran,
recordConsent: authorizationRadio || '',
consentAddressChange: authorizeAddressRadio || '',
recordConsent: yesNoToBoolean(authorizationRadio),
consentAddressChange: yesNoToBoolean(authorizeAddressRadio),
consentLimits: consentLimitsTransform(formData),
consentInsideAccess: yesNoToBoolean(authorizeInsideVARadio),
consentOutsideAccess: yesNoToBoolean(authorizeOutsideVARadio),
consentTeamMembers: authorizeNamesTextArea
.split(',')
.map(item => item.trim()),
representative,
...(formData['view:applicantIsVeteran'] === 'No' && { claimant }),
};
Expand Down

0 comments on commit 0bd6f28

Please sign in to comment.