Schedule
This commit is contained in:
parent
649d2a1ef8
commit
c2d9237902
4 changed files with 82 additions and 11 deletions
|
|
@ -2,11 +2,12 @@ import { storeActions } from "@/constants/store-actions";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
|
||||||
export async function getAlertReasons(ctu) {
|
export async function getAlertReasons(ctu) {
|
||||||
const alertReasons = await baseMixin.methods.dispatchStoreAction(
|
const alertReasons = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.GET_ALERT_REASONS_BY_CTU,
|
storeActions.GET_ALERT_REASONS_BY_CTU,
|
||||||
{
|
{
|
||||||
ctu: ctu,
|
ctu: ctu,
|
||||||
}
|
},
|
||||||
|
"schedule"
|
||||||
);
|
);
|
||||||
|
|
||||||
return Promise.resolve(alertReasons);
|
return Promise.resolve(alertReasons);
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,65 @@ jest.mock("@/mixins/base-mixin.js", () => ({
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
dispatchStoreActionWithLogging: jest.fn().mockImplementation((storeAction) => {
|
||||||
|
if (storeAction === "getShopTimeSlots") {
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
estimatedServiceMinutesMinimum: 90,
|
||||||
|
estimatedServiceMinutesMaximum: 120,
|
||||||
|
days: [
|
||||||
|
{
|
||||||
|
date: "2023-12-01",
|
||||||
|
timeSlots: [
|
||||||
|
{
|
||||||
|
id: "06747-01820-S-B*20424*7 AM",
|
||||||
|
startTime: "07:00",
|
||||||
|
endTime: "08:00",
|
||||||
|
offerPremium: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (storeAction === "getMobilePremiumFee") {
|
||||||
|
return Promise.resolve({
|
||||||
|
data: {
|
||||||
|
partNumber: "EARLY BIRD",
|
||||||
|
description: null,
|
||||||
|
partType: "EARLY BIRD",
|
||||||
|
laborAmount: 0,
|
||||||
|
sellingPrice: 14.99,
|
||||||
|
kitPrice: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (storeAction === "priceOrderItemsAndSaveServerData") {
|
||||||
|
return Promise.resolve([
|
||||||
|
{
|
||||||
|
partNumber: "EARLY BIRD",
|
||||||
|
description: null,
|
||||||
|
partType: "EARLY BIRD",
|
||||||
|
laborAmount: 0,
|
||||||
|
sellingPrice: 14.99,
|
||||||
|
kitPrice: 0,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
if (storeAction === "saveSupportingItemsSuppressingStateResetting") {
|
||||||
|
return Promise.resolve([
|
||||||
|
{
|
||||||
|
partNumber: "EARLY BIRD",
|
||||||
|
description: null,
|
||||||
|
partType: "EARLY BIRD",
|
||||||
|
laborAmount: 0,
|
||||||
|
sellingPrice: 14.99,
|
||||||
|
kitPrice: 0,
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
@ -226,10 +285,11 @@ describe("schedule.vue...", () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalledTimes(3);
|
expect(baseMixin.methods.dispatchStoreActionWithLogging).toHaveBeenCalledTimes(3);
|
||||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith(
|
expect(baseMixin.methods.dispatchStoreActionWithLogging).toHaveBeenCalledWith(
|
||||||
"getShopTimeSlots",
|
"getShopTimeSlots",
|
||||||
expect.anything(),
|
expect.anything(),
|
||||||
|
expect.anything(),
|
||||||
expect.anything()
|
expect.anything()
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -168,9 +168,10 @@ const getAvailableDates = async (
|
||||||
const makeParallelCalls = async () => {
|
const makeParallelCalls = async () => {
|
||||||
await Promise.all(
|
await Promise.all(
|
||||||
storeActionConfigs.map(async (storeAction) => {
|
storeActionConfigs.map(async (storeAction) => {
|
||||||
const timeSlotsResponse = await baseMixin.methods.dispatchStoreAction(
|
const timeSlotsResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeAction.storeAction,
|
storeAction.storeAction,
|
||||||
storeAction.payload,
|
storeAction.payload,
|
||||||
|
"schedule",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
timeSlotsResponsesData.estimatedServiceMinutesMinimum =
|
timeSlotsResponsesData.estimatedServiceMinutesMinimum =
|
||||||
|
|
@ -218,17 +219,20 @@ export default {
|
||||||
preSelectedDate: preSelectedDate,
|
preSelectedDate: preSelectedDate,
|
||||||
});
|
});
|
||||||
|
|
||||||
const premiumFeePromise = baseMixin.methods.dispatchStoreAction(
|
const premiumFeePromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.GET_MOBILE_PREMIUM_FEE
|
storeActions.GET_MOBILE_PREMIUM_FEE,
|
||||||
|
null,
|
||||||
|
"schedule"
|
||||||
);
|
);
|
||||||
|
|
||||||
const premiumFeeWithPricePromise = premiumFeePromise.then((result) => {
|
const premiumFeeWithPricePromise = premiumFeePromise.then((result) => {
|
||||||
if (result.data) {
|
if (result.data) {
|
||||||
return baseMixin.methods.dispatchStoreAction(
|
return baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
||||||
{
|
{
|
||||||
availableLineItems: [result.data],
|
availableLineItems: [result.data],
|
||||||
},
|
},
|
||||||
|
"schedule",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -930,11 +930,13 @@ export const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// Location API Actions
|
// Location API Actions
|
||||||
getAlertReasonsByCtu(context, { ctu }) {
|
getAlertReasonsByCtu(context, { payload: { ctu }, pageNameToLog }) {
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.GetAlertReasons.method,
|
method: endpoints.GetAlertReasons.method,
|
||||||
endpoint: `${endpoints.GetAlertReasons.url}/${ctu}`,
|
endpoint: `${endpoints.GetAlertReasons.url}/${ctu}`,
|
||||||
payload: {},
|
payload: {},
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -1412,7 +1414,7 @@ export const actions = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getMobileTimeSlots(context, { startDate, endDate }) {
|
getMobileTimeSlots(context, { payload: { startDate, endDate }, pageNameToLog }) {
|
||||||
const order = context.state.order;
|
const order = context.state.order;
|
||||||
const vehicle = context.state.order.vehicle;
|
const vehicle = context.state.order.vehicle;
|
||||||
let lineItems = [
|
let lineItems = [
|
||||||
|
|
@ -1464,6 +1466,8 @@ export const actions = {
|
||||||
method: endpoints.GetMobileTimeSlots.method,
|
method: endpoints.GetMobileTimeSlots.method,
|
||||||
endpoint: endpoints.GetMobileTimeSlots.url,
|
endpoint: endpoints.GetMobileTimeSlots.url,
|
||||||
payload: payload,
|
payload: payload,
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
additionalSuccessEventDataHandler: (response) =>
|
additionalSuccessEventDataHandler: (response) =>
|
||||||
getTimeSlotsAdditionalEventData(
|
getTimeSlotsAdditionalEventData(
|
||||||
response.data.provisionalTriggers,
|
response.data.provisionalTriggers,
|
||||||
|
|
@ -1473,13 +1477,15 @@ export const actions = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getMobilePremiumFee(context) {
|
getMobilePremiumFee(context, { pageNameToLog }) {
|
||||||
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.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
method: endpoints.GetMobilePremiumFee.method,
|
method: endpoints.GetMobilePremiumFee.method,
|
||||||
endpoint: `${endpoints.GetMobilePremiumFee.url}/${paymentType}/${damageType}`,
|
endpoint: `${endpoints.GetMobilePremiumFee.url}/${paymentType}/${damageType}`,
|
||||||
|
logApiCall: true,
|
||||||
|
pageNameToLog: pageNameToLog,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue