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

Create export file for HCA helper utils #33290

Merged
merged 2 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React, { useEffect, useRef, useState } from 'react';
import { Link } from 'react-router';
import PropTypes from 'prop-types';

import { VaModal } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import { focusElement } from 'platform/utilities/ui';
import { SESSION_ITEM_NAME, SHARED_PATHS } from '../../utils/constants';
import { normalizeFullName } from '../../utils/helpers/general';
import { normalizeFullName } from '../../utils/helpers';
import useAfterRenderEffect from '../../hooks/useAfterRenderEffect';

// declare shared routes from the form & default states
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import {
dependentUISchema as uiSchema,
} from '../../definitions/dependent';
import { selectAuthStatus } from '../../utils/selectors';
import {
replaceStrValues,
normalizeFullName,
} from '../../utils/helpers/general';
import { replaceStrValues, normalizeFullName } from '../../utils/helpers';
import DependentSIPWarning from '../FormAlerts/DependentSIPWarning';

const DependentListLoopForm = props => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,61 @@
import React, { useEffect, useMemo, useState } from 'react';
import PropTypes from 'prop-types';

import { VaModal } from '@department-of-veterans-affairs/component-library/dist/react-bindings';
import { focusElement } from 'platform/utilities/ui';
import { getActivePages } from 'platform/forms-system/src/js/helpers';
import FormNavButtons from 'platform/forms-system/src/js/components/FormNavButtons';

import DependentListLoopForm from '../FormFields/DependentListLoopForm';
import useAfterRenderEffect from '../../hooks/useAfterRenderEffect';
import {
getDataToSet,
getSearchAction,
getSearchIndex,
getDefaultState,
} from '../../utils/helpers/listloop-pattern';
replaceStrValues,
canHaveEducationExpenses,
} from '../../utils/helpers';
import {
DEPENDENT_VIEW_FIELDS,
DEPENDENT_SUBPAGES,
SESSION_ITEM_NAME,
SHARED_PATHS,
LAST_YEAR,
} from '../../utils/constants';
import content from '../../locales/en/content.json';

// declare shared data & route attrs from the form
const { dependents: DEPENDENT_PATHS } = SHARED_PATHS;

// declare subpage configs for dependent information page
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needed moved out of the Constants file, as it created a dependency cycle after changing the imports. This is only used in this file, so it makes sense for it to just live here.

const DEPENDENT_SUBPAGES = [
{
id: 'basic',
title: content['household-dependent-info-basic-title'],
},
{
id: 'additional',
title: content['household-dependent-info-addtl-title'],
},
{
id: 'support',
title: content['household-dependent-info-support-title'],
depends: { cohabitedLastYear: false },
},
{
id: 'income',
title: replaceStrValues(
content['household-dependent-info-income-title'],
LAST_YEAR,
'%d',
),
depends: { 'view:dependentIncome': true },
},
{
id: 'education',
title: content['household-dependent-info-education-title'],
depends: canHaveEducationExpenses,
},
];

// declare default component
const DependentInformation = props => {
const { data, goToPath, setFormData } = props;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { formatDate } from '../../utils/helpers/general';
import { formatDate } from '../../utils/helpers';

const CustomDateReviewField = ({
children: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import { normalizeFullName } from '../../utils/helpers/general';
import { normalizeFullName } from '../../utils/helpers';

const DependentsReviewPage = ({ data, editPage }) => {
const { dependents } = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useSelector } from 'react-redux';
import { HCA_ENROLLMENT_STATUSES } from '../../../../utils/constants';
import { selectEnrollmentStatus } from '../../../../utils/selectors';
import { createLiteralMap } from '../../../../utils/helpers/general';
import { createLiteralMap } from '../../../../utils/helpers';
import GeneralFAQs from '../ContentBlocks/GeneralFAQs';
import ReapplyFAQs from '../ContentBlocks/ReapplyFAQs';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useSelector } from 'react-redux';
import { HCA_ENROLLMENT_STATUSES } from '../../../../utils/constants';
import { selectEnrollmentStatus } from '../../../../utils/selectors';
import { createLiteralMap } from '../../../../utils/helpers/general';
import { createLiteralMap } from '../../../../utils/helpers';
import WarningExplainations from '../ContentBlocks/WarningExplainations';

const WarningExplanation = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useSelector } from 'react-redux';
import { HCA_ENROLLMENT_STATUSES } from '../../../../utils/constants';
import { selectEnrollmentStatus } from '../../../../utils/selectors';
import { createLiteralMap } from '../../../../utils/helpers/general';
import { createLiteralMap } from '../../../../utils/helpers';
import content from '../../../../locales/en/content.json';

const WarningHeadline = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { useSelector } from 'react-redux';
import { getMedicalCenterNameByID } from 'platform/utilities/medical-centers/medical-centers';
import { isValidDateString } from 'platform/utilities/date';
import { formatDate } from '../../../../utils/helpers/general';
import { formatDate } from '../../../../utils/helpers';
import { HCA_ENROLLMENT_STATUSES } from '../../../../utils/constants';
import { selectEnrollmentStatus } from '../../../../utils/selectors';
import content from '../../../../locales/en/content.json';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import PropTypes from 'prop-types';

import { CONTACTS } from '@department-of-veterans-affairs/component-library/contacts';
import AuthenticatedShortFormAlert from '../FormAlerts/AuthenticatedShortFormAlert';
import { formatDate, normalizeFullName } from '../../utils/helpers/general';
import { formatDate, normalizeFullName } from '../../utils/helpers';
import { APP_URLS, HIGH_DISABILITY_MINIMUM } from '../../utils/constants';

const AuthProfileInformation = ({ user }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import React from 'react';
import PropTypes from 'prop-types';
import {
formatDate,
maskSSN,
normalizeFullName,
} from '../../utils/helpers/general';
import { formatDate, maskSSN, normalizeFullName } from '../../utils/helpers';

const GuestVerifiedInformation = ({ user }) => {
const {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
TricarePolicyDescription,
} from '../../../components/FormDescriptions';
import { validatePolicyNumber } from '../../../utils/validation';
import { getInsuranceAriaLabel } from '../../../utils/helpers/insurance';
import { getInsuranceAriaLabel } from '../../../utils/helpers';
import { emptyObjectSchema } from '../../../definitions';

const { providers, isCoveredByHealthInsurance } = fullSchemaHca.properties;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { arrayBuilderPages } from 'platform/forms-system/src/js/patterns/array-builder';
import { insuranceTextOverrides } from '../../../utils/helpers/form-config';
import { insuranceTextOverrides } from '../../../utils/helpers';
import { validateInsurancePolicy } from '../../../utils/validation';
import {
policyPage,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import environment from 'platform/utilities/environment';
import fileUploadUI from 'platform/forms-system/src/js/definitions/file';
import DischargePapersDescription from '../../../components/FormDescriptions/DischargePapersDescription';
import {
createPayload,
parseResponse,
} from '../../../utils/helpers/file-attachments';
import { createPayload, parseResponse } from '../../../utils/helpers';
import { attachmentsSchema } from '../../../definitions/attachments';

export default {
Expand Down
2 changes: 1 addition & 1 deletion src/applications/hca/config/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
spouseAddressDoesNotMatchVeterans,
includeDependentInformation,
collectMedicareInformation,
} from '../utils/helpers/form-config';
} from '../utils/helpers';
import { SHARED_PATHS } from '../utils/constants';
import migrations from './migrations';
import manifest from '../manifest.json';
Expand Down
2 changes: 1 addition & 1 deletion src/applications/hca/config/submit-transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from 'platform/forms-system/src/js/helpers';
import set from 'platform/utilities/data/set';
import recordEvent from 'platform/monitoring/record-event';
import { hasLowDisabilityRating } from '../utils/helpers/form-config';
import { hasLowDisabilityRating } from '../utils/helpers';

/**
* Map file attachment data to determine if any of the files are the
Expand Down
3 changes: 1 addition & 2 deletions src/applications/hca/containers/ConfirmationPage.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import React from 'react';
import { useSelector } from 'react-redux';

import { isLoggedIn, selectProfile } from 'platform/user/selectors';
import ConfirmationScreenView from '../components/ConfirmationPage/ConfirmationScreenView';
import ConfirmationPrintView from '../components/ConfirmationPage/ConfirmationPrintView';
import ConfirmationFAQ from '../components/ConfirmationPage/ConfirmationFAQ';
import { normalizeFullName } from '../utils/helpers/general';
import { normalizeFullName } from '../utils/helpers';

const ConfirmationPage = () => {
const { submission, data } = useSelector(state => state.form);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React from 'react';
import { render } from '@testing-library/react';
import { expect } from 'chai';

import ConfirmationPrintView from '../../../../components/ConfirmationPage/ConfirmationPrintView';
import { normalizeFullName } from '../../../../utils/helpers/general';
import { normalizeFullName } from '../../../../utils/helpers';

describe('hca <ConfirmationPrintView>', () => {
const getData = ({ timestamp = undefined }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import React from 'react';
import { fireEvent, render } from '@testing-library/react';
import { expect } from 'chai';
import sinon from 'sinon';

import ConfirmationScreenView from '../../../../components/ConfirmationPage/ConfirmationScreenView';
import { normalizeFullName } from '../../../../utils/helpers/general';
import { normalizeFullName } from '../../../../utils/helpers';

describe('hca <ConfirmationScreenView>', () => {
const getData = ({ timestamp = undefined }) => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import React from 'react';
import { render } from '@testing-library/react';
import { expect } from 'chai';
import sinon from 'sinon';

import DependentList from '../../../../components/FormFields/DependentList';
import { normalizeFullName } from '../../../../utils/helpers/general';
import { normalizeFullName } from '../../../../utils/helpers';

describe('hca <DependentList>', () => {
const getData = () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
isClientError,
isServerError,
parseResponseErrors,
} from '../../../../utils/helpers/disability-rating';
} from '../../../../utils/helpers';

describe('hca disability rating helpers', () => {
context('when `isClientError` executes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { expect } from 'chai';
import sinon from 'sinon';
import { mockApiRequest } from '~/platform/testing/unit/helpers';
import { mockApiRequest } from 'platform/testing/unit/helpers';
import {
callAPI,
callFake404,
callFakeSuccess,
} from '../../../../utils/helpers/enrollment-status';
} from '../../../../utils/helpers';

describe('hca enrollment status helpers', () => {
let dispatch;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { expect } from 'chai';
import {
createPayload,
parseResponse,
} from '../../../../utils/helpers/file-attachments';
import { createPayload, parseResponse } from '../../../../utils/helpers';

describe('hca `createPayload` method', () => {
let mockFile;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
includeDependentInformation,
collectMedicareInformation,
insuranceTextOverrides,
} from '../../../../utils/helpers/form-config';
} from '../../../../utils/helpers';
import {
DEPENDENT_VIEW_FIELDS,
HIGH_DISABILITY_MINIMUM,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
maskSSN,
normalizeFullName,
replaceStrValues,
} from '../../../../utils/helpers/general';
} from '../../../../utils/helpers';

describe('hca `createLiteralMap` method', () => {
it('should create an object with correct properties based on array data', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { canHaveEducationExpenses } from '../../../../utils/helpers/household';
import { canHaveEducationExpenses } from '../../../../utils/helpers';

describe('hca household section helpers', () => {
context('hca `canHaveEducationExpenses` executes', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { expect } from 'chai';
import { getInsuranceAriaLabel } from '../../../../utils/helpers/insurance';
import { getInsuranceAriaLabel } from '../../../../utils/helpers';

describe('hca `getInsuranceAriaLabel` method', () => {
it('should return a generic label when the provider name is not provided', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getDefaultState,
getSearchAction,
getSearchIndex,
} from '../../../../utils/helpers/listloop-pattern';
} from '../../../../utils/helpers';

describe('hca `getDataToSet` method', () => {
const listRef = [{ name: 'John' }, { name: 'Jane' }, { name: 'Mary' }];
Expand Down
36 changes: 1 addition & 35 deletions src/applications/hca/utils/constants.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { getAppUrl } from '~/platform/utilities/registry-helpers';
import { canHaveEducationExpenses } from './helpers/household';
import { replaceStrValues } from './helpers/general';
import content from '../locales/en/content.json';
import { getAppUrl } from 'platform/utilities/registry-helpers';

// declare previous year for form questions and content
export const LAST_YEAR = new Date().getFullYear() - 1;
Expand All @@ -21,37 +18,6 @@ export const APP_URLS = {
verify: getAppUrl('verify'),
};

// declare subpage configs for dependent information page
export const DEPENDENT_SUBPAGES = [
{
id: 'basic',
title: content['household-dependent-info-basic-title'],
},
{
id: 'additional',
title: content['household-dependent-info-addtl-title'],
},
{
id: 'support',
title: content['household-dependent-info-support-title'],
depends: { cohabitedLastYear: false },
},
{
id: 'income',
title: replaceStrValues(
content['household-dependent-info-income-title'],
LAST_YEAR,
'%d',
),
depends: { 'view:dependentIncome': true },
},
{
id: 'education',
title: content['household-dependent-info-education-title'],
depends: canHaveEducationExpenses,
},
];

// declare view fields for use in household section
export const DEPENDENT_VIEW_FIELDS = {
report: 'view:reportDependents',
Expand Down
10 changes: 9 additions & 1 deletion src/applications/hca/utils/helpers/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
// keeping for future use as an exports file
// export helpers
export * from './disability-rating';
export * from './enrollment-status';
export * from './file-attachments';
export * from './form-config';
export * from './general';
export * from './household';
export * from './insurance';
export * from './listloop-pattern';
Loading