Cleaning up supportingItems setting

This commit is contained in:
Michaela Brydon 2024-03-04 15:08:51 -05:00
parent 7a8c685cec
commit 881a79c7eb
5 changed files with 49 additions and 82 deletions

View file

@ -369,7 +369,7 @@ export default {
},
async navigateForward() {
if (this.unverified || this.verifiedDeductible) {
this.mainStore.saveSupportingItems(this.supportingItems);
this.mainStore.updateSupportingItems(this.supportingItems);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD,
this.$route,
@ -379,7 +379,8 @@ export default {
} else if (this.verifiedITAC || this.verifiedNoComp) {
useMainStore().updateIsSafeliteProvider(this.selectedProvider === 'Safelite');
if (this.selectedProvider === 'Safelite') {
this.mainStore.saveSupportingItems(this.supportingItems);
// TODO maybe don't save supporting items on this page
this.mainStore.updateSupportingItems(this.supportingItems);
this.$router.navigate(
navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE,
this.$route,

View file

@ -268,7 +268,9 @@ export default {
return { mainStore };
},
data() {
const { supportingItems } = useMainStore().lineItems;
return {
supportingItems,
selectedDate: this.getSelectedDate(),
selectedTimeSlotInfo: this.getSelectedTimeSlotInfo(),
selectableDatesData: [],
@ -324,7 +326,7 @@ export default {
&& ((serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE
|| serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP)
|| serviceLocation.provider.providerNumber);
const supportingItems = useMainStore().lineItems.supportingItems !== null;
const supportingItems = this.supportingItems !== null;
const damageInfo =
useMainStore().order.damage.isRepair
|| (useMainStore().order.lineItems?.glassParts != null
@ -360,9 +362,8 @@ export default {
return this.mainStore.order.schedule.date;
},
getSelectedTimeSlotInfo() {
const supportingItems = this.getSupportingItems();
const isPremiumAppointment =
!!supportingItems.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE)
!!this.supportingItems.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE)
.length > 0;
const selectedTimeSlotInfo = {
@ -372,9 +373,6 @@ export default {
return selectedTimeSlotInfo;
},
getSupportingItems() {
return this.mainStore.lineItems.supportingItems;
},
timeSlotModalClosed() {
// Clear the selectedDate if no timeSlot has been selected
if (this.selectedTimeSlotInfo.timeSlot.routeCode == null) {
@ -424,40 +422,7 @@ export default {
}
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() {
this.updateSupportingItems();
this.mainStore.saveSchedule(this.selectedTimeSlotInfo.timeSlot);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route);

View file

@ -90,6 +90,7 @@ export default {
const wipersPromise = await store.getWipers();
const rainDefensePromise = await store.getRainDefense();
// TODO does this call need to happen here?
const supportingItemsPromise = await store.getSupportingItems();
const promiseResultMap = [
{
@ -124,7 +125,13 @@ export default {
let hasBailedOut = false;
const pricingResults = await store.getPriceOrderItems(availableLineItems)
.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;
next(`/?issPage=${issPageValues.BAILOUT_PAGE}`);
});
@ -179,15 +186,22 @@ export default {
this.selectedVaps = vapsItemsSelected;
},
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)) {
window.console.error('One or more items have no price assigned!');
}
if (this.pricedGlassParts.length > 0) {
store.saveGlassParts(this.pricedGlassParts);
// TODO saving glass parts here
store.updateGlassParts(this.pricedGlassParts);
}
store.saveSupportingItems(this.supportingItems);
store.saveVaps(this.selectedVaps);
// TODO saving supporting items on service packages page
// TODO does the glass parts array change?
store.updateSupportingItems(this.supportingItems);
store.updateVaps(this.selectedVaps);
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route);
}

View file

@ -360,8 +360,9 @@ export default {
);
if (this.isWindshieldRepair) {
// TODO only save supporting items on vehicle damage page if windshield repair
const supportingItems = await useMainStore().getSupportingItems();
this.mainStore.saveSupportingItems(supportingItems.data);
useMainStore().updateSupportingItems(supportingItems.data);
}
if (this.mainStore.damage.isRepair) {

View file

@ -947,11 +947,12 @@ export const useMainStore = defineStore({
});
},
// TODO this needs called when vehicle, damage, or glass parts changes
async getSupportingItems() {
const glassPartsArray = this.order.lineItems.glassParts ?? [];
const { carId } = this.order.vehicle;
const { isRepair } = this.order.damage;
const { numberOfChips } = this.order.damage;
const { glassParts } = this.lineItems;
const { carId } = this.vehicle;
const { isRepair, numberOfChips } = this.damage;
const { parentAccountNumber } = this.issConfig;
return globalMethods
.callHttpClient({
@ -960,8 +961,8 @@ export const useMainStore = defineStore({
payload: {
carId,
damageType: isRepair ? 'Repair' : 'Replace',
parentAccountNumber: applicationConfig.CASH_PARENT_ACCOUNT_NUMBER,
parts: glassPartsArray,
parentAccountNumber,
parts: glassParts ?? [],
numberOfRepairChips: isRepair ? numberOfChips : 0
}
});
@ -1434,8 +1435,9 @@ export const useMainStore = defineStore({
this.order.payment.insuranceCoverage.isVerified = false;
},
// Note that this is only used in the store
updateSupportingItems(partsData) {
this.order.lineItems.supportingItems = partsData;
this.lineItems.supportingItems = partsData;
},
updateVaps(partsData) {
@ -1473,8 +1475,8 @@ export const useMainStore = defineStore({
this.order.originalDeductible = vehicle.deductible;
this.order.currentDeductible = vehicle.deductible;
this.resetSupportingItemsState();
this.resetVapsState();
this.updateSupportingItems(null);
this.updateVaps(null);
},
updateVehicleVin(vin) {
@ -1497,6 +1499,7 @@ export const useMainStore = defineStore({
resetGlassPartsState() {
this.order.lineItems.glassParts = null;
this.order.lineItems.supportingItems = null;
this.order.damage.partQuestionAnswers = null;
this.order.damage.moldingQuestionAnswers = null;
this.order.damage.capabilityQuestionAnswers = null;
@ -1505,6 +1508,7 @@ export const useMainStore = defineStore({
this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null;
this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = null;
},
// TODO when schedule reset, supporting items modified
resetSchedule() {
this.order.schedule.date = null;
this.order.schedule.startTime = null;
@ -1522,12 +1526,6 @@ export const useMainStore = defineStore({
state.order.lineItems.supportingItems = supportingItems;
}
},
resetSupportingItemsState() {
this.order.lineItems.supportingItems = null;
},
resetVapsState() {
this.order.lineItems.vaps = null;
},
resetDamageState() {
this.order.damage.isRepair = null;
this.order.damage.numberOfChips = null;
@ -1686,8 +1684,8 @@ export const useMainStore = defineStore({
this.updateGlassParts(null);
this.updateMoldingQuestionAnswers(null);
this.updateCapabilityQuestionAnswers(null);
this.resetSupportingItemsState();
this.resetVapsState();
this.updateSupportingItems(null);
this.updateVaps(null);
this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: null });
this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null });
@ -1731,18 +1729,6 @@ export const useMainStore = defineStore({
// Save new values
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
async priceOrderItemsAndSaveServerData(availableLineItems, serviceZipCode, serviceZipCodeCtu) {
@ -2044,6 +2030,7 @@ export const useMainStore = defineStore({
if (!isSelectedGlassAvailableForVehicle) {
this.resetDamageState();
this.resetGlassPartsState();
// TODO probably reset supporting items
}
// Save new values
@ -2062,6 +2049,7 @@ export const useMainStore = defineStore({
if (!isSelectedGlassAvailableForVehicle) {
this.resetDamageState();
this.resetGlassPartsState();
// TODO probably reset supporting items
}
// Save new values
@ -2078,6 +2066,7 @@ export const useMainStore = defineStore({
// Dependencies already cleared in above statement
this.resetDamageState();
this.resetGlassPartsState();
// TODO reset supporting items state
}
// Save new values
@ -2111,21 +2100,18 @@ export const useMainStore = defineStore({
resetRegistrationAndDependencies() {
this.resetRegistrationState();
this.resetGlassPartsState();
this.resetSupportingItemsState();
this.resetVapsState();
this.updateVaps(null);
},
resetDamageAndDependencies() {
this.resetDamageState();
this.resetGlassPartsState();
this.resetSupportingItemsState();
this.resetVapsState();
this.updateVaps(null);
},
resetPartsAndDependencies() {
this.resetGlassPartsState();
this.resetSupportingItemsState();
this.resetVapsState();
this.updateVaps(null);
this.resetServiceLocationAndDependencies();
},