From 32a6b4d1bb67c925b2ecdea144dcceb6b8aa4fa5 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 25 May 2023 16:27:42 -0400 Subject: [PATCH 1/3] CSR-1137 | Implement get-mobile-time-slots, get-mobile-early-bird-fee --- src/constants/endpoints.js | 1 - src/constants/store-actions.js | 1 + src/layouts/schedule/schedule.vue | 34 ++++++++++++------ src/store/index.js | 58 +++++++++++++++++++++++++++---- 4 files changed, 77 insertions(+), 17 deletions(-) diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index f1aeded2e..53f981d8a 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -116,7 +116,6 @@ const endpoints = { }, GetMobileEarlyBirdFee: { url: "/parts/api/v1/parts/mobile-early-bird-fee", - mockUrl: "https://mockey.qa.sagaws.net/service/mobile-early-bird-fee", // TODO: REMOVE MOCKURL method: "GET", }, SaveSession: { diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 341fcd487..5ff98fd9d 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -33,6 +33,7 @@ const storeActions = { GET_MOBILE_FEE_PART: "getMobileFeePart", GET_SERVICEABILITY_DETAILS: "getServiceabilityDetails", GET_SHOP_TIME_SLOTS: "getShopTimeSlots", + GET_MOBILE_TIME_SLOTS: "getMobileTimeSlots", GET_PROVIDERS: "getProviders", GET_MOBILE_EARLY_BIRD_FEE: "getMobileEarlyBirdFee", SAVE_SESSION: "saveSession", diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 24deff3e5..5969dfa06 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -83,17 +83,31 @@ defineRule("time-slot-selection-required", required(errorMessages.DATE_REQUIRED) const getAvailableDates = async (startDate, endDate, appointmentType, providerNumber) => { // USING DATES PASSED, MAKE AN API CALL - const newShopTimeSlotsResponse = await baseMixin.methods.dispatchStoreAction( + + let newTimeSlotsResponse; + if (appointmentType === AppointmentTypeStrings.MOBILE) { + newTimeSlotsResponse = await baseMixin.methods.dispatchStoreAction( + storeActions.GET_MOBILE_TIME_SLOTS, + { + startDate: startDate, + endDate: endDate, + }, + false + ); + } else { + newTimeSlotsResponse = await baseMixin.methods.dispatchStoreAction( storeActions.GET_SHOP_TIME_SLOTS, - { - startDate: startDate, - endDate: endDate, - shopAppointmentType: appointmentType, - providerNumber: providerNumber, - }, - false - ); - const newShopTimeSlots = newShopTimeSlotsResponse.data; + { + startDate: startDate, + endDate: endDate, + shopAppointmentType: appointmentType, + providerNumber: providerNumber, + }, + false + ); + } + + const newShopTimeSlots = newTimeSlotsResponse.data; return convertApiResponse(newShopTimeSlots); }; const convertApiResponse = (responseData) => { diff --git a/src/store/index.js b/src/store/index.js index 8d020e255..7889217cc 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1166,17 +1166,63 @@ export const actions = { logApiCall: false, }); }, + getMobileTimeSlots(context, { startDate, endDate }) { + const order = context.state.order; + const vehicle = context.state.order.vehicle; + let partNumbers = [ + ...(order.lineItems.supportingItems ?? []), + ...(order.lineItems.vaps ?? []), + ...getFlattenedArrayOfLineItemsWithChildParts(order.lineItems.glassParts), + ]; + partNumbers = partNumbers.map((lineItem) => { + return lineItem.partNumber; + }); + const glassPieces = order.damage.glassToReplace ?? []; + var payload = { + startDate: startDate, + endDate: endDate, + applicationName: "Safelite.com funnel", + parentAccountNumber: context.getters.payment.parentAccountNumber, + carId: vehicle.carId, + partNumbers: partNumbers, + glassPieces: glassPieces, + eon: order.eon, + coverage: { + status: "", + deductible: 0, + additionalAuthFlag: "", + }, + partSelection: { + // TODO: Provisional booking will utilize these fields + hasAnsweredPartQuestions: false, + hasAnsweredMoldingQuestions: false, + hasAnsweredCapabilityQuestions: false, + hasManuallySelectedParts: false, + }, + vehicle: { + year: vehicle.year, + make: vehicle.make, + model: vehicle.model, + style: vehicle.style, + vin: vehicle.vin, + }, + zipCode: order.serviceLocation.zipCode, + }; + return globalMethods.callHttpClient({ + method: endpoints.GetMobileTimeSlots.method, + endpoint: endpoints.GetMobileTimeSlots.url, + payload: payload, + logApiCall: false, + }); + }, getMobileEarlyBirdFee(context) { const damageType = context.getters.damage.isRepair ? "Repair" : "Replace"; const paymentType = context.getters.order.payment.isInsurance ? "Insurance" : "Cash"; - return globalMethods.callMockHttpClient({ + + return globalMethods.callHttpClient({ method: endpoints.GetMobileEarlyBirdFee.method, - endpoint: `${endpoints.GetMobileEarlyBirdFee.mockUrl}/Cash/Replace`, + endpoint: `${endpoints.GetMobileEarlyBirdFee.url}/${paymentType}/${damageType}`, }); - // return globalMethods.callHttpClient({ - // method: endpoints.GetMobileEarlyBirdFee.method, - // endpoint: `${endpoints.GetMobileEarlyBirdFee.url}/${paymentType}/${damageType}`, - // }); }, // Session API Actions saveSession(context) { From db48ca9fd0eec51b72e81a4dd7311a85f0366e09 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 25 May 2023 16:28:57 -0400 Subject: [PATCH 2/3] CSR-1137 | Formatting --- src/layouts/schedule/schedule.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index 5969dfa06..37bdc8622 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -96,7 +96,7 @@ const getAvailableDates = async (startDate, endDate, appointmentType, providerNu ); } else { newTimeSlotsResponse = await baseMixin.methods.dispatchStoreAction( - storeActions.GET_SHOP_TIME_SLOTS, + storeActions.GET_SHOP_TIME_SLOTS, { startDate: startDate, endDate: endDate, @@ -106,7 +106,7 @@ const getAvailableDates = async (startDate, endDate, appointmentType, providerNu false ); } - + const newShopTimeSlots = newTimeSlotsResponse.data; return convertApiResponse(newShopTimeSlots); }; From 83d0fe5b6d471538b7686d4850f19cf97580a733 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 25 May 2023 16:38:57 -0400 Subject: [PATCH 3/3] CSR-1137 | Dropping test coverage % --- jest.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index a757d5ada..28c5557cb 100644 --- a/jest.config.js +++ b/jest.config.js @@ -26,7 +26,7 @@ module.exports = { testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], coverageThreshold: { global: { - statements: 80, + statements: 78, // Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90 }, },