Skip to content

Commit

Permalink
Fix bug with using formData in the schema files when calling ProfileN… (
Browse files Browse the repository at this point in the history
#33881)

* fix bug with using formData in the schema files when calling ProfileNotUpdatedNote

* fix failing tests
  • Loading branch information
holdenhinkle authored Jan 3, 2025
1 parent 22e1d6b commit e22526e
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import PropTypes from 'prop-types';

import { CONTACTS } from '@department-of-veterans-affairs/component-library/contacts';
import { isLoggedIn } from 'platform/user/selectors';
import { preparerIsVeteran } from '../utilities/helpers';

function ProfileNotUpdatedNote(props) {
const {
formData,
includeLink,
includePhone,
includePrefix,
loggedIn,
preparerIsVeteran,
} = props;
const isLoggedInVeteran = loggedIn && preparerIsVeteran;
const isLoggedInVeteran = loggedIn && preparerIsVeteran({ formData });

return (
<>
Expand Down Expand Up @@ -52,16 +53,17 @@ function ProfileNotUpdatedNote(props) {
}

ProfileNotUpdatedNote.propTypes = {
formData: PropTypes.object,
includeLink: PropTypes.bool,
includePhone: PropTypes.bool,
includePrefix: PropTypes.bool,
loggedIn: PropTypes.bool,
preparerIsVeteran: PropTypes.bool,
};

function mapStateToProps(state) {
return {
loggedIn: isLoggedIn(state),
formData: state.form.data,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,14 @@ import {
titleSchema,
} from 'platform/forms-system/src/js/web-component-patterns';
import ProfileNotUpdatedNote from '../../components/ProfileNotUpdatedNote';
import { preparerIsVeteran } from '../../utilities/helpers';

export const uiSchema = {
...titleUI(
'Your mailing address',
'We’ll send any important information about your form to this address.',
),
profileNotUpdatedNote: {
'ui:description': formData => (
<ProfileNotUpdatedNote
includeLink
includePrefix
preparerIsVeteran={preparerIsVeteran({ formData })}
/>
),
'ui:description': () => <ProfileNotUpdatedNote includeLink includePrefix />,
},
veteranHomeAddress: addressUI({
labels: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@ import {
} from 'platform/forms-system/src/js/web-component-patterns';

import ProfileNotUpdatedNote from '../../components/ProfileNotUpdatedNote';
import { preparerIsVeteran } from '../../utilities/helpers';
// import { preparerIsVeteran } from '../../utilities/helpers';

export const uiSchema = {
...titleUI(() => 'Your phone number and email address'),
profileNotUpdatedNote: {
'ui:description': formData => (
<ProfileNotUpdatedNote
includePhone
preparerIsVeteran={preparerIsVeteran({ formData })}
/>
),
'ui:description': () => <ProfileNotUpdatedNote includePhone />,
},
'Primary phone': phoneUI({
required: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ export const uiSchema = {
} Social Security and VA file numbers are the same. `,
),
profileNotUpdatedNote: {
'ui:description': formData => (
<ProfileNotUpdatedNote
includePhone
includePrefix
preparerIsVeteran={preparerIsVeteran({ formData })}
/>
'ui:description': () => (
<ProfileNotUpdatedNote includePhone includePrefix />
),
},
veteranSocialSecurityNumber: ssnUI('Social Security number'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ export const uiSchema = {
} name and date of birth`,
),
profileNotUpdatedNote: {
'ui:description': formData => (
<ProfileNotUpdatedNote
includePhone
preparerIsVeteran={preparerIsVeteran({ formData })}
/>
),
'ui:description': () => <ProfileNotUpdatedNote includePhone />,
},
veteranFullName: fullNameMiddleInitialUI,
veteranDateOfBirth: dateOfBirthUI(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,7 @@ export const uiSchema = {
} service information`,
),
profileNotUpdatedNote: {
'ui:description': formData => (
<ProfileNotUpdatedNote
includePhone
preparerIsVeteran={preparerIsVeteran({ formData })}
/>
),
'ui:description': () => <ProfileNotUpdatedNote includePhone />,
},
'Branch of Service': radioUI('Branch of service'),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Claimant Contact Phone Email page', () => {
const mockStore = configureStore();
const store = mockStore({
user: { login: { currentlyLoggedIn: true } },
form: { data: {} },
});

it('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('Claimant Personal Information page', () => {
const mockStore = configureStore();
const store = mockStore({
user: { login: { currentlyLoggedIn: true } },
form: { data: {} },
});

// Custom page is rendered, so this only renders a submit button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Veteran Contact Phone Email page', () => {
const mockStore = configureStore();
const store = mockStore({
user: { login: { currentlyLoggedIn: true } },
form: { data: {} },
});

it('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Veteran Contact Phone Email Claimant page', () => {
const mockStore = configureStore();
const store = mockStore({
user: { login: { currentlyLoggedIn: true } },
form: { data: {} },
});

it('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Veteran Identification page', () => {
const mockStore = configureStore();
const store = mockStore({
user: { login: { currentlyLoggedIn: true } },
form: { data: {} },
});

it('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Veteran Personal Information page', () => {
const mockStore = configureStore();
const store = mockStore({
user: { login: { currentlyLoggedIn: true } },
form: { data: {} },
});

it('should render', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe('Veteran Service Information page', () => {
const mockStore = configureStore();
const store = mockStore({
user: { login: { currentlyLoggedIn: true } },
form: { data: {} },
});

it('should render', () => {
Expand Down

0 comments on commit e22526e

Please sign in to comment.