CSR-1137 | Implement get-mobile-time-slots, get-mobile-early-bird-fee
This commit is contained in:
parent
881004fc9b
commit
32a6b4d1bb
4 changed files with 77 additions and 17 deletions
|
|
@ -116,7 +116,6 @@ const endpoints = {
|
||||||
},
|
},
|
||||||
GetMobileEarlyBirdFee: {
|
GetMobileEarlyBirdFee: {
|
||||||
url: "/parts/api/v1/parts/mobile-early-bird-fee",
|
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",
|
method: "GET",
|
||||||
},
|
},
|
||||||
SaveSession: {
|
SaveSession: {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ const storeActions = {
|
||||||
GET_MOBILE_FEE_PART: "getMobileFeePart",
|
GET_MOBILE_FEE_PART: "getMobileFeePart",
|
||||||
GET_SERVICEABILITY_DETAILS: "getServiceabilityDetails",
|
GET_SERVICEABILITY_DETAILS: "getServiceabilityDetails",
|
||||||
GET_SHOP_TIME_SLOTS: "getShopTimeSlots",
|
GET_SHOP_TIME_SLOTS: "getShopTimeSlots",
|
||||||
|
GET_MOBILE_TIME_SLOTS: "getMobileTimeSlots",
|
||||||
GET_PROVIDERS: "getProviders",
|
GET_PROVIDERS: "getProviders",
|
||||||
GET_MOBILE_EARLY_BIRD_FEE: "getMobileEarlyBirdFee",
|
GET_MOBILE_EARLY_BIRD_FEE: "getMobileEarlyBirdFee",
|
||||||
SAVE_SESSION: "saveSession",
|
SAVE_SESSION: "saveSession",
|
||||||
|
|
|
||||||
|
|
@ -83,17 +83,31 @@ defineRule("time-slot-selection-required", required(errorMessages.DATE_REQUIRED)
|
||||||
|
|
||||||
const getAvailableDates = async (startDate, endDate, appointmentType, providerNumber) => {
|
const getAvailableDates = async (startDate, endDate, appointmentType, providerNumber) => {
|
||||||
// USING DATES PASSED, MAKE AN API CALL
|
// 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,
|
storeActions.GET_SHOP_TIME_SLOTS,
|
||||||
{
|
{
|
||||||
startDate: startDate,
|
startDate: startDate,
|
||||||
endDate: endDate,
|
endDate: endDate,
|
||||||
shopAppointmentType: appointmentType,
|
shopAppointmentType: appointmentType,
|
||||||
providerNumber: providerNumber,
|
providerNumber: providerNumber,
|
||||||
},
|
},
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
const newShopTimeSlots = newShopTimeSlotsResponse.data;
|
}
|
||||||
|
|
||||||
|
const newShopTimeSlots = newTimeSlotsResponse.data;
|
||||||
return convertApiResponse(newShopTimeSlots);
|
return convertApiResponse(newShopTimeSlots);
|
||||||
};
|
};
|
||||||
const convertApiResponse = (responseData) => {
|
const convertApiResponse = (responseData) => {
|
||||||
|
|
|
||||||
|
|
@ -1166,17 +1166,63 @@ export const actions = {
|
||||||
logApiCall: false,
|
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) {
|
getMobileEarlyBirdFee(context) {
|
||||||
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
||||||
const paymentType = context.getters.order.payment.isInsurance ? "Insurance" : "Cash";
|
const paymentType = context.getters.order.payment.isInsurance ? "Insurance" : "Cash";
|
||||||
return globalMethods.callMockHttpClient({
|
|
||||||
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.GetMobileEarlyBirdFee.method,
|
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
|
// Session API Actions
|
||||||
saveSession(context) {
|
saveSession(context) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue