From 32a6b4d1bb67c925b2ecdea144dcceb6b8aa4fa5 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 25 May 2023 16:27:42 -0400 Subject: [PATCH] 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) {