Skip to content

Commit

Permalink
Appoint a rep routing fix (#32939)
Browse files Browse the repository at this point in the history
* Updated routing logic to check for query params

* Removed unnecessary useEffect handling postlogin

* Using typographic apostrophe in copy

* Reintroduce authorizeMedicalSelect

* Refactored authorizeMedicalSelect

* Removed unused method
  • Loading branch information
cosu419 authored Nov 8, 2024
1 parent 9beea14 commit 20a2e97
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 96 deletions.
26 changes: 13 additions & 13 deletions src/applications/representative-appoint/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

import {
authorizeMedical,
// authorizeMedicalSelect,
authorizeMedicalSelect,
authorizeAddress,
authorizeInsideVA,
authorizeOutsideVA,
Expand Down Expand Up @@ -334,18 +334,18 @@ const formConfig = {
uiSchema: authorizeMedical.uiSchema,
schema: authorizeMedical.schema,
},
// authorizeMedicalSelect: {
// path: 'authorize-medical/select',
// depends: formData => {
// return (
// formData?.authorizationRadio ===
// 'Yes, but they can only access some of these types of records'
// );
// },
// title: 'Authorization for Certain Medical Records - Select',
// uiSchema: authorizeMedicalSelect.uiSchema,
// schema: authorizeMedicalSelect.schema,
// },
authorizeMedicalSelect: {
path: 'authorize-medical/select',
depends: formData => {
return (
formData?.authorizationRadio ===
'Yes, but they can only access some of these types of records'
);
},
title: 'Authorization for Certain Medical Records - Select',
uiSchema: authorizeMedicalSelect.uiSchema,
schema: authorizeMedicalSelect.schema,
},
authorizeAddress: {
path: 'authorize-address',
title: 'Authorization to change your address',
Expand Down
13 changes: 0 additions & 13 deletions src/applications/representative-appoint/containers/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,6 @@ function App({ loggedIn, location, children, formData, setFormData }) {
const { pathname } = location || {};
const [updatedFormConfig, setUpdatedFormConfig] = useState({ ...formConfig });

const isPostLogin = document.location.search?.includes('postLogin=true');

useEffect(
() => {
if (isPostLogin) {
window.location.replace(
'/get-help-from-accredited-representative/appoint-rep',
);
}
},
[isPostLogin],
);

useEffect(
() => {
configService.setFormConfig({ subTitle });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export const schema = {
properties: {},
},
authorizeAddressRadio: radioSchema([
`Yes, they can change my address if it's incorrect or outdated`,
`Yes, they can change my address if its incorrect or outdated`,
`No, they can't change my address`,
]),
'view:authorizationNote3': {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,56 +1,61 @@
// import React from 'react';
// import { checkboxGroupUI } from 'platform/forms-system/src/js/web-component-patterns';
// import {
// checkboxGroupSchemaWithReviewLabels,
// representativeTypeMap,
// } from '../../utilities/helpers';
import React from 'react';
import {
checkboxGroupSchema,
checkboxGroupUI,
} from '~/platform/forms-system/src/js/web-component-patterns';
import { authorizationNote } from '../../content/authorizeMedical';
import { representativeTypeMap } from '../../utilities/helpers';

// export const uiSchema = {
// 'ui:description': ({ formData }) => {
// return (
// <>
// <h3>Authorization to access certain medical records</h3>
// <p className="vads-u-margin-bottom--3 appoint-text">
// You’ve authorized this accredited{' '}
// {representativeTypeMap[formData.repTypeRadio] || `representative`} to
// access some of your medical records.
// </p>
// </>
// );
// },
// 'view:authorizeRecordsCheckbox': {
// ...checkboxGroupUI({
// title: 'Select the types of records they can access',
// required: true,
// labelHeaderLevel: '',
// tile: false,
// uswds: true,
// labels: {
// alcoholRecords: 'Alcoholism and alcohol abuse records',
// drugAbuseRecords: 'Drug abuse records',
// HIVRecords: 'HIV (human immunodeficiency virus) records',
// sickleCellRecords: 'Sickle cell anemia records',
// },
// errorMessages: {
// required: 'Please select at least one option',
// },
// }),
// 'ui:options': {
// classNames: 'vads-u-margin-top--0',
// },
// },
// };
export const uiSchema = {
'ui:description': ({ formData }) => {
return (
<>
<h3>Authorization to access certain medical records</h3>
<p className="vads-u-margin-bottom--3 appoint-text">
You’ve authorized this accredited{' '}
{representativeTypeMap[formData.repTypeRadio] || `representative`} to
access some of your medical records.
</p>
</>
);
},

// export const schema = {
// type: 'object',
// properties: {
// 'view:authorizeRecordsCheckbox': {
// ...checkboxGroupSchemaWithReviewLabels([
// 'alcoholRecords',
// 'drugAbuseRecords',
// 'HIVRecords',
// 'sickleCellRecords',
// ]),
// },
// },
// };
authorizeMedicalSelectCheckbox: checkboxGroupUI({
title: 'Select the types of records they can access',
required: true,
labelHeaderLevel: '',
tile: false,
uswds: true,
labels: {
alcoholRecords: 'Alcoholism and alcohol abuse records',
drugAbuseRecords: 'Drug abuse records',
HIVRecords: 'HIV (human immunodeficiency virus) records',
sickleCellRecords: 'Sickle cell anemia records',
},
errorMessages: {
required: 'Please select at least one option',
},
}),
'view:authorizationNote4': {
'ui:description': authorizationNote,
},
};

export const schema = {
type: 'object',
required: ['authorizeMedicalSelectCheckbox'],
properties: {
'view:authorizeRecordsSelect': {
type: 'object',
properties: {},
},
authorizeMedicalSelectCheckbox: checkboxGroupSchema(
Object.keys({
alcoholRecords: 'Alcoholism and alcohol abuse records',
drugAbuseRecords: 'Drug abuse records',
HIVRecords: 'HIV (human immunodeficiency virus) records',
sickleCellRecords: 'Sickle cell anemia records',
}),
),
},
};
18 changes: 16 additions & 2 deletions src/applications/representative-appoint/routes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,23 @@ import App from './containers/App';
const route = {
path: '/',
component: App,
indexRoute: { onEnter: (_nextState, replace) => replace('/introduction') },
indexRoute: {
onEnter: (nextState, replace) => {
const { location } = nextState;

childRoutes: [...createRoutesWithSaveInProgress(formConfig)],
if (
location.pathname === '/introduction' &&
location.query.next === 'loginModal' &&
location.query.postLogin === 'true'
) {
replace('/');
} else {
replace('/introduction');
}
},
},

childRoutes: createRoutesWithSaveInProgress(formConfig),
};

export default route;
13 changes: 0 additions & 13 deletions src/applications/representative-appoint/utilities/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { checkboxGroupSchema } from 'platform/forms-system/src/js/web-component-patterns';
import environment from '@department-of-veterans-affairs/platform-utilities/environment';
import { createInitialState } from '@department-of-veterans-affairs/platform-forms-system/state/helpers';
import moment from 'moment';
Expand All @@ -13,18 +12,6 @@ export const representativeTypeMap = {
'Veterans Service Organization (VSO)': 'Veterans Service Organization (VSO)',
};

export const checkboxGroupSchemaWithReviewLabels = keys => {
const schema = checkboxGroupSchema(keys);
keys.forEach(key => {
schema.properties[key] = {
...schema.properties[key],
enum: [true, false],
enumNames: ['Selected', 'Not selected'],
};
});
return schema;
};

export const deviewifyFields = formData => {
const newFormData = {};
Object.keys(formData).forEach(key => {
Expand Down

0 comments on commit 20a2e97

Please sign in to comment.