diff --git a/src/constants/endorsement-codes.js b/src/constants/endorsement-codes.js new file mode 100644 index 00000000..222c90f8 --- /dev/null +++ b/src/constants/endorsement-codes.js @@ -0,0 +1,6 @@ +const endorsementCodes_LibertyMutual = Object.freeze({ + EDUCATOR: '001', + PARKING_GUARD: '003' +}); + +export default endorsementCodes_LibertyMutual; \ No newline at end of file diff --git a/src/helpers/policy-vehicle-helper.js b/src/helpers/policy-vehicle-helper.js index 69a80e74..783f210d 100644 --- a/src/helpers/policy-vehicle-helper.js +++ b/src/helpers/policy-vehicle-helper.js @@ -1,4 +1,5 @@ import endorsementOptions from '@/constants/endorsement-options'; +import endorsementCodes_LibertyMutual from '@/constants/endorsement-codes'; export function noCoverageForSelectedVehicle(vehicle) { return (vehicle?.coverages?.length ?? 0) === 0; @@ -18,6 +19,20 @@ export function endorsementsForSelectedVehicle(vehicle) { } return []; } +export function endorsementCodesForSelectedVehicle(vehicle) { + if (!Array.isArray(vehicle?.endorsements) || vehicle.endorsements.length === 0) { + return ''; + } + + let codes = []; + if (vehicle.endorsements.includes(endorsementOptions.EDUCATOR)) { + codes.push(endorsementCodes_LibertyMutual.EDUCATOR); + } + if (vehicle.endorsements.includes(endorsementOptions.PARKING_GUARD)) { + codes.push(endorsementCodes_LibertyMutual.PARKING_GUARD); + } + return codes.join(','); +} export function repairWaivedForSelectedVehicle(vehicle) { return vehicle?.endorsements?.includes(endorsementOptions.REPAIR_WAIVED) ?? false; } diff --git a/src/layouts/policy-vehicles/policy-vehicles.spec.js b/src/layouts/policy-vehicles/policy-vehicles.spec.js index 176d4eb7..f144af63 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.spec.js +++ b/src/layouts/policy-vehicles/policy-vehicles.spec.js @@ -125,7 +125,8 @@ describe('policy-vehicles.vue', () => { noCoverage: true, deductible: 0, repairWaived: false, - endorsements: [] + endorsements: [], + cvrgEndorsementCode: "" }; // Act @@ -180,7 +181,8 @@ describe('policy-vehicles.vue', () => { noCoverage: true, deductible: 0, repairWaived: false, - endorsements + endorsements, + cvrgEndorsementCode: "001" }; // Act @@ -233,7 +235,8 @@ describe('policy-vehicles.vue', () => { noCoverage: true, deductible: 0, repairWaived: false, - endorsements + endorsements, + cvrgEndorsementCode: "003" }; // Act diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 49f8815a..a8fe665a 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -55,6 +55,7 @@ import { useMainStore } from '@/store/index.js'; import { deductibleForSelectedVehicle, endorsementsForSelectedVehicle, + endorsementCodesForSelectedVehicle, noCoverageForSelectedVehicle, repairWaivedForSelectedVehicle } from '@/helpers/policy-vehicle-helper'; @@ -132,6 +133,9 @@ export default { endorsementsForSelectedVehicle() { return endorsementsForSelectedVehicle(this.selectedPolicyVehicle); }, + endorsementCodesForSelectedVehicle() { + return endorsementCodesForSelectedVehicle(this.selectedPolicyVehicle); + }, repairWaivedForSelectedVehicle() { return repairWaivedForSelectedVehicle(this.selectedPolicyVehicle); } @@ -202,7 +206,8 @@ export default { noCoverage: this.noCoverageForSelectedVehicle, deductible: this.deductibleForSelectedVehicle, repairWaived: this.repairWaivedForSelectedVehicle, - endorsements: this.endorsementsForSelectedVehicle + endorsements: this.endorsementsForSelectedVehicle, + cvrgEndorsementCode: this.endorsementCodesForSelectedVehicle }); this.pushEventToGA("policy_vehicle", "submitted", useMainStore().order.vehicle.make + "_" + useMainStore().order.vehicle.model + " " + useMainStore().order.vehicle.carId, true); diff --git a/src/store/index.js b/src/store/index.js index ecfda6f4..1954086a 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -4,6 +4,7 @@ import bailoutCode from '@/constants/bailoutCode'; import coverageStatuses from '@/constants/coverage-statuses'; import coverageType from '@/constants/coverage-type'; import damageLocationsSelected from '@/constants/damage-locations-selected'; +import endorsementOptions from '@/constants/endorsement-options'; import endpoints from '@/constants/endpoints'; import { experimentSettings, experimentTriggers, experimentUniverses } from '@/constants/experiments'; import partNumberStrings from '@/constants/part-number-strings'; @@ -17,7 +18,7 @@ import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourT import { getExperimentSettingValue, getFeatureTogglesPayloadObject } from '@/helpers/experiment-helper'; import { findLineItemIndex, getLineItemsFlattened } from '@/helpers/line-items-helper'; import { - deductibleForSelectedVehicle, endorsementsForSelectedVehicle, + deductibleForSelectedVehicle, endorsementsForSelectedVehicle, endorsementCodesForSelectedVehicle, noCoverageForSelectedVehicle, repairWaivedForSelectedVehicle } from '@/helpers/policy-vehicle-helper'; @@ -109,6 +110,7 @@ export const getDefaultState = () => ({ vehicles: [], endorsements: [], endorsementQuestionAnswers: [], + cvrgEndorsementCode: null, status: null, policyData: null, policyLookupErrorCode: 0 @@ -1479,7 +1481,9 @@ export const useMainStore = defineStore({ currentDeductible: this.currentDeductible, OemEndorsement: this.hasOemEndorsement, noCoverage: this.isNoComp, - isItac: this.isITAC + isItac: this.isITAC, + cvrgEndorsementCode: policy.cvrgEndorsementCode ?? endorsementCodesForSelectedVehicle(vehicle), + endorsementQuestionAnswers: policy.endorsementQuestionAnswers }, customer: { address: { @@ -2081,6 +2085,7 @@ export const useMainStore = defineStore({ this.order.policy.deductible.replace = coverage.deductible; this.order.policy.deductible.repair = coverage?.repairWaived ?? false ? 0 : coverage.deductible; this.order.policy.endorsements = coverage?.endorsements; + this.order.policy.cvrgEndorsementCode = coverage?.cvrgEndorsementCode; this.order.originalDeductible.replace = this.order.policy.deductible.replace; this.order.currentDeductible.replace = this.order.policy.deductible.replace; @@ -2122,6 +2127,7 @@ export const useMainStore = defineStore({ this.order.policy.vehicles = []; this.order.policy.endorsements = []; this.order.policy.endorsementQuestionAnswers = []; + this.order.policy.cvrgEndorsementCode = null; this.order.policy.policyData = null; this.order.policy.policyLookupErrorCode = 0; this.order.policy.deductible.repair = null;