diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index fb14a057..10f9bd1c 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -6,7 +6,7 @@ const COVERAGE_BASE_URL = '/coverage/api/v1/coverage'; const EXPERIMENTS_BASE_URL = '/experiments/api/v1/experiments'; const LOCATION_BASE_URL = '/location/api/v1/location'; const ORDER_BASE_URL = '/order/api/v1/order'; -const PARTS_BASE_URL = '/parts/api/v1/parts'; +const PARTS_BASE_URL = '/parts/api/v2/parts'; const PRICE_BASE_URL = '/price/api/v1/price'; const SCHEDULE_BASE_URL = '/schedule/api/v1/schedule'; const VEHICLE_BASE_URL = '/vehicle/api/v1/vehicle'; diff --git a/src/constants/part-number-strings.js b/src/constants/part-number-strings.js index dbfa87ad..89f4a97f 100644 --- a/src/constants/part-number-strings.js +++ b/src/constants/part-number-strings.js @@ -1,6 +1,8 @@ const partNumberStrings = Object.freeze({ RECYCLE_FEE: 'RECYCLE FEE', LABOR2: 'LABOR2', + RECAL_MOBILE: 'RECAL MOBILE', + RECAL_MOBILEDUAL: 'RECAL MOBILEDUAL' }); export default partNumberStrings; diff --git a/src/helpers/querystring-helper.js b/src/helpers/querystring-helper.js index 11dcdb48..b6f8ec3b 100644 --- a/src/helpers/querystring-helper.js +++ b/src/helpers/querystring-helper.js @@ -52,14 +52,14 @@ export function buildURLSearchParams(data) { } if (Array.isArray(value)) { value.forEach((arrayValue, index) => { - if (typeof value === 'object') { + if (typeof arrayValue === 'object') { Object.entries(arrayValue).forEach(([objectKey, objectValue]) => { if (objectValue != null) { params.append(`${key}[${index}].${objectKey}`, `${objectValue}`); } }); } else { - params.append(`${key}[${index}]`, `${value}`); + params.append(`${key}[${index}]`, `${arrayValue}`); } }); } else { diff --git a/src/helpers/service-location-helper.js b/src/helpers/service-location-helper.js index 5da94148..4755aa69 100644 --- a/src/helpers/service-location-helper.js +++ b/src/helpers/service-location-helper.js @@ -44,7 +44,7 @@ export async function getPricedMobileFeePart(serviceZipCode) { } // Get the Mobile Fee Part - const mobileFeePart = await useMainStore().getMobileFeePart(); + const mobileFeePart = await useMainStore().getMobileFeePart(serviceZipCode); if (mobileFeePart?.data == null || mobileFeePart.data === '') { return Promise.resolve(null); diff --git a/src/layouts/schedule-page/service-location/service-location.spec.js b/src/layouts/schedule-page/service-location/service-location.spec.js index cda30da8..eb77d52c 100644 --- a/src/layouts/schedule-page/service-location/service-location.spec.js +++ b/src/layouts/schedule-page/service-location/service-location.spec.js @@ -4,6 +4,7 @@ import { createTestingPinia } from '@pinia/testing'; import { AppointmentTypeStrings } from '@/constants/schedule-constants'; import navigationScenarios from '@/router/router-constants/navigation-scenarios'; import routerParams from '@/router/router-constants/router-params'; +import { getPricedMobileFeePart } from '@/helpers/service-location-helper'; import { useMainStore } from '@/store'; import serviceLocation from '@/layouts/schedule-page/service-location/service-location.vue'; @@ -87,7 +88,8 @@ jest.mock( '@/helpers/service-location-helper', () => ({ getZipCodeData: jest.fn((mockServiceZipCode) => mockZipcodeData(mockServiceZipCode)), - getMobileZipCodeData: jest.fn((mockServiceZipCode) => mockZipcodeData(mockServiceZipCode)) + getMobileZipCodeData: jest.fn((mockServiceZipCode) => mockZipcodeData(mockServiceZipCode)), + getPricedMobileFeePart: jest.fn(() => Promise.resolve(null)) }) ); diff --git a/src/layouts/schedule-page/service-location/service-location.vue b/src/layouts/schedule-page/service-location/service-location.vue index 7476acd1..f9787d16 100644 --- a/src/layouts/schedule-page/service-location/service-location.vue +++ b/src/layouts/schedule-page/service-location/service-location.vue @@ -143,6 +143,7 @@ import shopAddress from '@/layouts/schedule-page/service-location/shop-address/s import serviceZipQuestion from '@/layouts/schedule-page/service-location/service-zip-question/service-zip-question.vue'; import widgetFields from '@/constants/cms-widget-fields'; import recalModal from '@/iss-components/recal-modal/recal-modal.vue'; +import { getPricedMobileFeePart } from '@/helpers/service-location-helper'; const RECAL_MODAL_REF_NAME = 'RecalModal'; @@ -355,9 +356,7 @@ export default { let provider = this.selectedProvider; this.mainStore.updateMobileFee(null); if (this.isMobile) { - if (this.mainStore.isNoComp || this.mainStore.isITAC) { - this.mainStore.updateMobileFee(this.mobileFeePart); - } + this.mainStore.updateMobileFee(this.mobileFeePart); provider = { providerNumber: this.mobileProviderNumber, @@ -568,6 +567,11 @@ export default { } } }); + const mobileFeePromise = getPricedMobileFeePart(this.mobileZipCode); + await mobileFeePromise.then((result) => { + this.mobileFeePart = result ?? null; + }); + } } } diff --git a/src/store/index.js b/src/store/index.js index 1d9dfafd..12dc746f 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -22,7 +22,7 @@ import { repairWaivedForSelectedVehicle } from '@/helpers/policy-vehicle-helper'; import { buildURLSearchParams, getPartNumbersListForQueryString } from '@/helpers/querystring-helper'; -import { getTopLevelGlassPartsWithRecal } from '@/helpers/recal-helper'; +import { getRecalPartNumbers, getTopLevelGlassPartsWithRecal } from '@/helpers/recal-helper'; import { getDateForSavedSessionTimeout } from '@/helpers/session-helper'; import { isMobileDevice } from '@/helpers/useragent-helper'; import issPageValues from '@/router/router-constants/issPage-values'; @@ -1320,13 +1320,14 @@ export const useMainStore = defineStore({ return availableLineItems; }, - getMobileFeePart() { + getMobileFeePart(serviceZipCode) { const { vehicle, insuranceCoverage } = this.order; + const recalParts = getRecalPartNumbers(this.order.lineItems.glassParts); if (!this.billToAccountNumber || !this.providerNumber) { return null; } - const params = new URLSearchParams({ + const params = buildURLSearchParams({ serviceType: this.damage.isRepair ? 'Repair' : 'Install', facilityType: 'Mobile', parentAccountNumber: this.order.parentAccountNumber, @@ -1334,6 +1335,8 @@ export const useMainStore = defineStore({ isItacOptimized: insuranceCoverage.isItacOptimized, providerNumber: this.providerNumber, carId: vehicle.carId, + zipCode: serviceZipCode, + partNumbers: recalParts, coverageStatus: coverageStatuses.mapToApi(insuranceCoverage.coverageStatus), coverageType: coverageType.mapToApi(insuranceCoverage.coverageType) }); @@ -1995,8 +1998,10 @@ export const useMainStore = defineStore({ updateMobileFee(fee) { const isMobileFeeHidden = getExperimentSettingValue(this.experimentSettings, experimentSettings.ISS_FEATURE_TOGGLE_IS_MOBILE_FEE_HIDDEN) === 'true'; + const isMSRFee = fee?.partNumber === partNumberStrings.RECAL_MOBILE || fee?.partNumber === partNumberStrings.RECAL_MOBILEDUAL; // Mobile Fee is only added for NO COMP or ITAC and is NOT hidden - if (fee && this.isVerified && (this.isNoComp || this.isITAC) && !isMobileFeeHidden) { + // MSR Fee is added for all orders + if ((fee && this.isVerified && (this.isNoComp || this.isITAC) && !isMobileFeeHidden) || isMSRFee) { this.addPartTypeFeeItem(fee, partTypeStrings.MOBILE_FEE); } else { this.addPartTypeFeeItem(null, partTypeStrings.MOBILE_FEE);