This commit is contained in:
Michaela Brydon 2024-03-04 18:08:34 -05:00
commit 87837f013c
6 changed files with 42 additions and 164 deletions

View file

@ -380,7 +380,11 @@ export default {
}, },
async navigateForward() { async navigateForward() {
if (this.unverified || this.verifiedDeductible) { if (this.unverified || this.verifiedDeductible) {
<<<<<<< HEAD
useMainStore().saveSupportingItems(this.supportingItems); useMainStore().saveSupportingItems(this.supportingItems);
=======
useMainStore().updateSupportingItems(this.supportingItems);
>>>>>>> 24103335eec282fad8ded09087cf8502b0150ad6
this.$router.navigate( this.$router.navigate(
navigationScenarios.CLICKED_FORWARD, navigationScenarios.CLICKED_FORWARD,
this.$route, this.$route,
@ -388,9 +392,15 @@ export default {
{ [routerParams.SAVE_SESSION_SYNCHRONOUS]: true } { [routerParams.SAVE_SESSION_SYNCHRONOUS]: true }
); );
} else if (this.verifiedITAC || this.verifiedNoComp) { } else if (this.verifiedITAC || this.verifiedNoComp) {
<<<<<<< HEAD
useMainStore().updateIsSafeliteProvider(this.selectedProvider === SAFELITE_PROVIDER); useMainStore().updateIsSafeliteProvider(this.selectedProvider === SAFELITE_PROVIDER);
if (this.selectedProvider === SAFELITE_PROVIDER) { if (this.selectedProvider === SAFELITE_PROVIDER) {
useMainStore().saveSupportingItems(this.supportingItems); useMainStore().saveSupportingItems(this.supportingItems);
=======
useMainStore().updateIsSafeliteProvider(this.selectedProvider === 'Safelite');
if (this.selectedProvider === 'Safelite') {
useMainStore().updateSupportingItems(this.supportingItems);
>>>>>>> 24103335eec282fad8ded09087cf8502b0150ad6
this.$router.navigate( this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
this.$route, this.$route,

View file

@ -75,8 +75,6 @@ function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) {
} }
}); });
// mountOptions.global.mocks["$store"] = store;
mountOptions.global.stubs = { mountOptions.global.stubs = {
siteFooter: footerStub, siteFooter: footerStub,
loadingModal: loadingModalStub loadingModal: loadingModalStub
@ -337,81 +335,4 @@ describe('schedule-page.vue', () => {
// Assert // Assert
expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); expect(wrapper.vm.$router.navigate).toHaveBeenCalled();
}); });
test('for mobile appts, updateSupportingItems should call store action to save supporting items', async () => {
// Arrange
const { wrapper } = getShallowMountedComponent();
wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE;
wrapper.vm.mobilePremiumAppointmentFee = 14.99;
wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = true;
wrapper.vm.mainStore.lineItems.supportingItems = [
{
partNumber: 'EARLY BIRD',
description: null,
partType: 'EARLY BIRD',
laborAmount: 0,
sellingPrice: 0,
kitPrice: 0
}
];
const store = useMainStore();
// Act
await wrapper.vm.updateSupportingItems();
// Assert
expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(1);
expect(wrapper.vm.mainStore.lineItems.supportingItems)
.toEqual(expect.arrayContaining([
expect.objectContaining({
partType: 'EARLY BIRD'
})
]));
});
test(
'for Inshop appts, updateSupportingItems should call store action to save supporting items WITHOUT the EARLY BIRD supporting item',
async () => {
// Arrange
const { wrapper } = getShallowMountedComponent();
wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.IN_SHOP;
wrapper.vm.mobilePremiumAppointmentFee = 14.99;
wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = true;
wrapper.vm.mainStore.lineItems.supportingItems = [
{
partNumber: 'EARLY BIRD',
description: null,
partType: 'EARLY BIRD',
laborAmount: 0,
sellingPrice: 0,
kitPrice: 0
}
];
const store = useMainStore();
// Act
await wrapper.vm.updateSupportingItems();
// Assert
expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(1);
expect(wrapper.vm.mainStore.lineItems.supportingItems)
.not.toEqual(expect.arrayContaining([
expect.objectContaining({
partType: 'EARLY BIRD'
})
]));
}
);
test('if no EARLY BIRD supporting item, then updateSupportingItems should NOT call store action', async () => {
// Arrange
const { wrapper } = getShallowMountedComponent();
wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE;
wrapper.vm.mobilePremiumAppointmentFee = 14.99;
wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = false;
wrapper.vm.mainStore.lineItems.supportingItems = [];
const store = useMainStore();
// Act
await wrapper.vm.updateSupportingItems();
// Assert
expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(0);
});
}); });

View file

@ -291,6 +291,9 @@ export default {
} }
return this.selectableDatesData.days?.find((selectableDate) => selectableDate.date === this.selectedDate); return this.selectableDatesData.days?.find((selectableDate) => selectableDate.date === this.selectedDate);
},
supportingItems() {
return useMainStore().lineItems.supportingItems;
} }
}, },
watch: { watch: {
@ -324,7 +327,7 @@ export default {
&& ((serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE && ((serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|| serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP) || serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP)
|| serviceLocation.provider.providerNumber); || serviceLocation.provider.providerNumber);
const supportingItems = useMainStore().lineItems.supportingItems !== null; const supportingItems = this.supportingItems !== null;
const damageInfo = const damageInfo =
useMainStore().order.damage.isRepair useMainStore().order.damage.isRepair
|| (useMainStore().order.lineItems?.glassParts != null || (useMainStore().order.lineItems?.glassParts != null
@ -360,9 +363,8 @@ export default {
return this.mainStore.order.schedule.date; return this.mainStore.order.schedule.date;
}, },
getSelectedTimeSlotInfo() { getSelectedTimeSlotInfo() {
const supportingItems = this.getSupportingItems();
const isPremiumAppointment = const isPremiumAppointment =
!!supportingItems.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) !!(this.supportingItems?.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) ?? [])
.length > 0; .length > 0;
const selectedTimeSlotInfo = { const selectedTimeSlotInfo = {
@ -372,9 +374,6 @@ export default {
return selectedTimeSlotInfo; return selectedTimeSlotInfo;
}, },
getSupportingItems() {
return this.mainStore.lineItems.supportingItems;
},
timeSlotModalClosed() { timeSlotModalClosed() {
// Clear the selectedDate if no timeSlot has been selected // Clear the selectedDate if no timeSlot has been selected
if (this.selectedTimeSlotInfo.timeSlot.routeCode == null) { if (this.selectedTimeSlotInfo.timeSlot.routeCode == null) {
@ -424,40 +423,7 @@ export default {
} }
return `${hours}:${minutes} ${meridianNotation}`; return `${hours}:${minutes} ${meridianNotation}`;
}, },
updateSupportingItems() {
const supportingItems = this.getSupportingItems();
// if we have a premium fee(early bird), then save/update supporting items
if (
this.appointmentType === AppointmentTypeStrings.MOBILE
&& this.selectedTimeSlotInfo?.isPremiumAppointment
) {
const premiumFeeIndex = supportingItems.findIndex((item) => item.partType === PREMIUM_FEE_PART_TYPE);
if (premiumFeeIndex >= 0) {
supportingItems[premiumFeeIndex].laborAmount =
this.mobilePremiumAppointmentFee.laborAmount;
supportingItems[premiumFeeIndex].sellingPrice =
this.mobilePremiumAppointmentFee.sellingPrice;
supportingItems[premiumFeeIndex].kitPrice =
this.mobilePremiumAppointmentFee.kitPrice;
} else {
supportingItems.push(this.mobilePremiumAppointmentFee);
}
this.mainStore.saveSupportingItemsSuppressingStateResetting(supportingItems);
} else {
// if it's not a mobile and/or premium early bird, then make sure we remove any that may have been added
const removePremiumFeeIndex = supportingItems.findIndex((item) => item.partType === PREMIUM_FEE_PART_TYPE);
if (removePremiumFeeIndex >= 0) {
supportingItems.splice(removePremiumFeeIndex, 1);
this.mainStore.saveSupportingItemsSuppressingStateResetting(supportingItems);
}
}
},
forwardButtonAction() { forwardButtonAction() {
this.updateSupportingItems();
this.mainStore.saveSchedule(this.selectedTimeSlotInfo.timeSlot); this.mainStore.saveSchedule(this.selectedTimeSlotInfo.timeSlot);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route);

View file

@ -124,7 +124,13 @@ export default {
let hasBailedOut = false; let hasBailedOut = false;
const pricingResults = await store.getPriceOrderItems(availableLineItems) const pricingResults = await store.getPriceOrderItems(availableLineItems)
.catch((err) => { .catch((err) => {
useMainStore().setBailout(to, bailoutMessage.pricingResponseError(availableLineItems.map((li) => li.partNumber), { code: err.code, message: err.message, data: err.data })); useMainStore().setBailout(
to,
bailoutMessage.pricingResponseError(
availableLineItems.map((li) => li.partNumber),
{ code: err.code, message: err.message, data: err.data }
)
);
hasBailedOut = true; hasBailedOut = true;
next(`/?issPage=${issPageValues.BAILOUT_PAGE}`); next(`/?issPage=${issPageValues.BAILOUT_PAGE}`);
}); });
@ -179,15 +185,19 @@ export default {
this.selectedVaps = vapsItemsSelected; this.selectedVaps = vapsItemsSelected;
}, },
forwardButtonAction() { forwardButtonAction() {
const parts = { glassParts: this.pricedGlassParts, supportingItems: this.supportingItems, vaps: this.selectedVaps }; const parts = {
glassParts: this.pricedGlassParts,
supportingItems: this.supportingItems,
vaps: this.selectedVaps
};
if (!allGlassPartsAndItemsHavePrices(parts)) { if (!allGlassPartsAndItemsHavePrices(parts)) {
window.console.error('One or more items have no price assigned!'); window.console.error('One or more items have no price assigned!');
} }
if (this.pricedGlassParts.length > 0) { if (this.pricedGlassParts.length > 0) {
store.saveGlassParts(this.pricedGlassParts); store.updateGlassParts(this.pricedGlassParts);
} }
store.saveSupportingItems(this.supportingItems); store.updateSupportingItems(this.supportingItems);
store.saveVaps(this.selectedVaps); store.updateVaps(this.selectedVaps);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route);
} }

View file

@ -361,7 +361,7 @@ export default {
if (this.isWindshieldRepair) { if (this.isWindshieldRepair) {
const supportingItems = await useMainStore().getSupportingItems(); const supportingItems = await useMainStore().getSupportingItems();
this.mainStore.saveSupportingItems(supportingItems.data); useMainStore().updateSupportingItems(supportingItems.data);
} }
if (this.mainStore.damage.isRepair) { if (this.mainStore.damage.isRepair) {

View file

@ -11,7 +11,7 @@ import applicationConfig from '@/constants/application-config';
import issPageValues from '@/router/router-constants/issPage-values'; import issPageValues from '@/router/router-constants/issPage-values';
import damageLocationsSelected from '@/constants/damage-locations-selected'; import damageLocationsSelected from '@/constants/damage-locations-selected';
import coverageStatuses from '@/constants/coverage-statuses'; import coverageStatuses from '@/constants/coverage-statuses';
import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants'; import { AppointmentTypeStrings } from '@/constants/schedule-constants';
import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper'; import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper';
import { paymentMethods } from '@/constants/payment-method-constants'; import { paymentMethods } from '@/constants/payment-method-constants';
import { import {
@ -947,7 +947,7 @@ export const useMainStore = defineStore({
}, },
async getSupportingItems() { async getSupportingItems() {
const glassPartsArray = this.lineItems.glassParts ?? []; const { glassParts } = this.lineItems;
const { carId } = this.vehicle; const { carId } = this.vehicle;
const { isRepair, numberOfChips } = this.damage; const { isRepair, numberOfChips } = this.damage;
const { parentAccountNumber } = this.issConfig; const { parentAccountNumber } = this.issConfig;
@ -960,7 +960,7 @@ export const useMainStore = defineStore({
carId, carId,
damageType: isRepair ? 'Repair' : 'Replace', damageType: isRepair ? 'Repair' : 'Replace',
parentAccountNumber, parentAccountNumber,
parts: glassPartsArray, parts: glassParts ?? [],
numberOfRepairChips: isRepair ? numberOfChips : 0 numberOfRepairChips: isRepair ? numberOfChips : 0
} }
}); });
@ -1472,8 +1472,8 @@ export const useMainStore = defineStore({
this.order.originalDeductible = vehicle.deductible; this.order.originalDeductible = vehicle.deductible;
this.order.currentDeductible = vehicle.deductible; this.order.currentDeductible = vehicle.deductible;
this.resetSupportingItemsState(); this.updateSupportingItems(null);
this.resetVapsState(); this.updateVaps(null);
}, },
updateVehicleVin(vin) { updateVehicleVin(vin) {
@ -1496,6 +1496,7 @@ export const useMainStore = defineStore({
resetGlassPartsState() { resetGlassPartsState() {
this.order.lineItems.glassParts = null; this.order.lineItems.glassParts = null;
this.order.lineItems.supportingItems = null;
this.order.damage.partQuestionAnswers = null; this.order.damage.partQuestionAnswers = null;
this.order.damage.moldingQuestionAnswers = null; this.order.damage.moldingQuestionAnswers = null;
this.order.damage.capabilityQuestionAnswers = null; this.order.damage.capabilityQuestionAnswers = null;
@ -1511,21 +1512,6 @@ export const useMainStore = defineStore({
this.order.schedule.routeCode = null; this.order.schedule.routeCode = null;
this.order.schedule.jobMaxMinutes = null; this.order.schedule.jobMaxMinutes = null;
this.order.schedule.jobMinMinutes = null; this.order.schedule.jobMinMinutes = null;
// premium appointment fee used on schedule page also needs reset when schedule is reset
const { supportingItems } = this.order.lineItems;
const premiumAppointmentFeeIndex = supportingItems?.findIndex((item) => item.partType === PREMIUM_FEE_PART_TYPE);
if (premiumAppointmentFeeIndex >= 0) {
supportingItems.splice(premiumAppointmentFeeIndex, 1);
state.order.lineItems.supportingItems = supportingItems;
}
},
resetSupportingItemsState() {
this.order.lineItems.supportingItems = null;
},
resetVapsState() {
this.order.lineItems.vaps = null;
}, },
resetDamageState() { resetDamageState() {
this.order.damage.isRepair = null; this.order.damage.isRepair = null;
@ -1685,8 +1671,8 @@ export const useMainStore = defineStore({
this.updateGlassParts(null); this.updateGlassParts(null);
this.updateMoldingQuestionAnswers(null); this.updateMoldingQuestionAnswers(null);
this.updateCapabilityQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null);
this.resetSupportingItemsState(); this.updateSupportingItems(null);
this.resetVapsState(); this.updateVaps(null);
this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: null }); this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: null });
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null }); this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null });
@ -1730,18 +1716,6 @@ export const useMainStore = defineStore({
// Save new values // Save new values
this.updateCapabilityQuestionAnswers(capabilityQuestionAnswersArray); this.updateCapabilityQuestionAnswers(capabilityQuestionAnswersArray);
}, },
saveGlassParts(glassParts) {
this.order.lineItems.glassParts = glassParts;
},
saveSupportingItems(supportingItems) {
this.order.lineItems.supportingItems = supportingItems;
},
saveSupportingItemsSuppressingStateResetting(supportingItems) {
this.order.lineItems.supportingItems = supportingItems;
},
saveVaps(vaps) {
this.order.lineItems.vaps = vaps;
},
// Price order actions // Price order actions
async priceOrderItemsAndSaveServerData(availableLineItems, serviceZipCode, serviceZipCodeCtu) { async priceOrderItemsAndSaveServerData(availableLineItems, serviceZipCode, serviceZipCodeCtu) {
@ -2110,21 +2084,18 @@ export const useMainStore = defineStore({
resetRegistrationAndDependencies() { resetRegistrationAndDependencies() {
this.resetRegistrationState(); this.resetRegistrationState();
this.resetGlassPartsState(); this.resetGlassPartsState();
this.resetSupportingItemsState(); this.updateVaps(null);
this.resetVapsState();
}, },
resetDamageAndDependencies() { resetDamageAndDependencies() {
this.resetDamageState(); this.resetDamageState();
this.resetGlassPartsState(); this.resetGlassPartsState();
this.resetSupportingItemsState(); this.updateVaps(null);
this.resetVapsState();
}, },
resetPartsAndDependencies() { resetPartsAndDependencies() {
this.resetGlassPartsState(); this.resetGlassPartsState();
this.resetSupportingItemsState(); this.updateVaps(null);
this.resetVapsState();
this.resetServiceLocationAndDependencies(); this.resetServiceLocationAndDependencies();
}, },