diff --git a/src/constants/parent-account-numbers.js b/src/constants/parent-account-numbers.js deleted file mode 100644 index 70419bf8..00000000 --- a/src/constants/parent-account-numbers.js +++ /dev/null @@ -1,5 +0,0 @@ -const parentAccountNumber = Object.freeze({ - USAA: 900040 -}); - -export default parentAccountNumber; \ No newline at end of file diff --git a/src/helpers/client-mappers/Client900040Coverage.js b/src/helpers/client-mappers/Client900040Coverage.js new file mode 100644 index 00000000..b85ba1c0 --- /dev/null +++ b/src/helpers/client-mappers/Client900040Coverage.js @@ -0,0 +1,10 @@ +import { useMainStore } from "@/store"; + +export function updateClaimRegistrationPayload(payload) { + console.log(`updating payload for USAA`) + const mainStore = useMainStore(); + payload.additionalInfo = { + offeredItac: mainStore.isITAC ? 'true' : 'false', + qualifiedForItac: mainStore.isITAC ? 'true' : 'false' + } +} \ No newline at end of file diff --git a/src/helpers/coverage-helper.js b/src/helpers/coverage-helper.js index cece9348..61177121 100644 --- a/src/helpers/coverage-helper.js +++ b/src/helpers/coverage-helper.js @@ -1,16 +1,14 @@ -import parentAccountNumber from "@/constants/parent-account-numbers"; import { useMainStore } from "@/store"; -export function updateClientSpecificFieldsForClaimRegistration(payload) { +export async function updateClientSpecificFieldsForClaimRegistration(payload) { const mainStore = useMainStore(); - switch (mainStore.order.parentAccountNumber) { - case parentAccountNumber.USAA: - payload.additionalInfo = { - offeredItac: mainStore.isITAC.toString(), - qualifiedForItac: mainStore.isITAC.toString() - } - break; - default: - break; + try { + console.log(`Updating client-specific fields for claim registration for parent account number: ${mainStore.order.parentAccountNumber}`); + const clientMapper = await import(`@/helpers/client-mappers/Client${mainStore.order.parentAccountNumber}Coverage.js`); + console.log(`Loaded client mapper: ${clientMapper}`); + clientMapper.updateClaimRegistrationPayload(payload); + } + catch (error) { + console.error('Error updating client-specific fields for claim registration:', error); } } \ No newline at end of file diff --git a/src/helpers/coverage-helper.spec.js b/src/helpers/coverage-helper.spec.js index 6b10cf84..fd1fb2bc 100644 --- a/src/helpers/coverage-helper.spec.js +++ b/src/helpers/coverage-helper.spec.js @@ -1,68 +1,67 @@ import { updateClientSpecificFieldsForClaimRegistration } from '@/helpers/coverage-helper'; -import parentAccountNumber from '@/constants/parent-account-numbers'; let mockStore; jest.mock('@/store', () => ({ - useMainStore: jest.fn(() => mockStore) + useMainStore: jest.fn(() => mockStore) })); describe('coverage-helper.js', () => { - describe('updateClientSpecificFieldsForClaimRegistration', () => { - beforeEach(() => { - mockStore = { - order: { - parentAccountNumber: null - }, - isITAC: false - }; + describe('updateClientSpecificFieldsForClaimRegistration', () => { + beforeEach(() => { + mockStore = { + order: { + parentAccountNumber: null + }, + isITAC: false + }; - jest.clearAllMocks(); - }); + jest.clearAllMocks(); + }); - test('Sets additionalInfo fields when parent account is USAA and isITAC is true', () => { - // Arrange - const payload = {}; - mockStore.order.parentAccountNumber = parentAccountNumber.USAA; - mockStore.isITAC = true; + test('Sets additionalInfo fields when parent account is 900040 and isITAC is true', async () => { + // Arrange + const payload = {}; + mockStore.order.parentAccountNumber = 900040; + mockStore.isITAC = true; - // Act - updateClientSpecificFieldsForClaimRegistration(payload); + // Act + await updateClientSpecificFieldsForClaimRegistration(payload); - // Assert - expect(payload.additionalInfo).toEqual({ - offeredItac: 'true', - qualifiedForItac: 'true' - }); - }); + // Assert + expect(payload.additionalInfo).toEqual({ + offeredItac: 'true', + qualifiedForItac: 'true' + }); + }); - test('Sets additionalInfo fields when parent account is USAA and isITAC is false', () => { - // Arrange - const payload = {}; - mockStore.order.parentAccountNumber = parentAccountNumber.USAA; - mockStore.isITAC = false; + test('Sets additionalInfo fields when parent account is 900040 and isITAC is false', async () => { + // Arrange + const payload = {}; + mockStore.order.parentAccountNumber = 900040; + mockStore.isITAC = false; - // Act - updateClientSpecificFieldsForClaimRegistration(payload); + // Act + await updateClientSpecificFieldsForClaimRegistration(payload); - // Assert - expect(payload.additionalInfo).toEqual({ - offeredItac: 'false', - qualifiedForItac: 'false' - }); - }); + // Assert + expect(payload.additionalInfo).toEqual({ + offeredItac: 'false', + qualifiedForItac: 'false' + }); + }); - test('Does not set additionalInfo when parent account is not USAA', () => { - // Arrange - const payload = {}; - mockStore.order.parentAccountNumber = 123456; - mockStore.isITAC = true; + test('Does not set additionalInfo when parent account is not 900040', async () => { + // Arrange + const payload = {}; + mockStore.order.parentAccountNumber = 123456; + mockStore.isITAC = true; - // Act - updateClientSpecificFieldsForClaimRegistration(payload); + // Act + await updateClientSpecificFieldsForClaimRegistration(payload); - // Assert - expect(payload.additionalInfo).toBeUndefined(); - }); - }); + // Assert + expect(payload.additionalInfo).toBeUndefined(); + }); + }); }); diff --git a/src/store/index.js b/src/store/index.js index 0938eb33..9de98893 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -714,7 +714,7 @@ export const useMainStore = defineStore({ if (this.issConfig.useMemberNumber) { payload.memberNumber = this.order.policy.policyNumber; } - updateClientSpecificFieldsForClaimRegistration(payload); + await updateClientSpecificFieldsForClaimRegistration(payload); const response = await globalMethods.callHttpClient({ method: endpoints.RegisterClaim.method, endpoint: endpoints.RegisterClaim.url,