Added call to get mobile fee part in each component

This commit is contained in:
Leah Schumann 2023-03-14 13:28:16 -04:00
parent 1613e192e3
commit 8c82e8f9f9
3 changed files with 15 additions and 31 deletions

View file

@ -1,14 +1,8 @@
import { storeActions } from "@/constants/store-actions"; import { storeActions } from "@/constants/store-actions";
import store from "@/store";
import baseMixin from "@/mixins/base-mixin.js"; import baseMixin from "@/mixins/base-mixin.js";
export async function getPricedMobileFeePart( export async function getPricedMobileFeePart(serviceZipCode) {
serviceZipCode, if (!serviceZipCode) {
serviceType,
parentAccountNumber,
billToAccountNumber
) {
if (!serviceZipCode || !serviceType || !parentAccountNumber || !billToAccountNumber) {
return Promise.resolve(null); return Promise.resolve(null);
} }
@ -17,11 +11,7 @@ export async function getPricedMobileFeePart(
// Get the Mobile Fee Part // Get the Mobile Fee Part
const mobileFeePart = await baseMixin.methods.dispatchStoreAction( const mobileFeePart = await baseMixin.methods.dispatchStoreAction(
storeActions.GET_MOBILE_FEE_PART, storeActions.GET_MOBILE_FEE_PART,
{ null,
serviceType: serviceType,
parentAccountNumber: parentAccountNumber,
billToAccountNumber: billToAccountNumber,
},
false false
); );
@ -38,4 +28,3 @@ export async function getPricedMobileFeePart(
return Promise.resolve(pricingResults[0]); return Promise.resolve(pricingResults[0]);
} }

View file

@ -161,6 +161,7 @@ export default {
values: { values: {
state: updatedServiceZipCodeInfo.state, state: updatedServiceZipCodeInfo.state,
zipCode: updatedServiceZipCodeInfo.zipCode, zipCode: updatedServiceZipCodeInfo.zipCode,
isVehicleProtected: updatedServiceZipCodeInfo.isVehicleProtected
}, },
}); });
}, },
@ -177,14 +178,11 @@ export default {
this.displayInvalidZipAlert = true; this.displayInvalidZipAlert = true;
this.resetModalButtonStyle(); this.resetModalButtonStyle();
} else { } else {
// retrieve mobile fee part // retrieve mobile fee part
const serviceType = store.getters.damage.isRepair ? "Repair" : "Replace"; const serviceZipCode = this.internalModel.addressQuestions.zipCode;
const parentAccountNumber = store.getters.payment.parentAccountNumber;
const billToAccountNumber = 1; const mobileFeePart = await getPricedMobileFeePart(serviceZipCode);
const mobileFeePart = await getPricedMobileFeePart(this.internalModel.addressQuestions.zipCode, serviceType, parentAccountNumber, billToAccountNumber);
// emit it to parent // emit it to parent
this.$emit("set-mobile-fee-part", mobileFeePart); this.$emit("set-mobile-fee-part", mobileFeePart);
@ -200,8 +198,9 @@ export default {
this.internalModel = deepClone(newValue); this.internalModel = deepClone(newValue);
this.resetComponent({ this.resetComponent({
state: newValue.state, state: newValue.addressQuestions.state,
zipCode: newValue.zipCode, zipCode: newValue.addressQuestions.zipCode,
isVehicleProtected: newValue.isVehicleProtected
}); });
}, },
deep: true, deep: true,

View file

@ -61,7 +61,7 @@ export default {
mobileFeePart: { mobileFeePart: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
}, },
linkWidgetName: String, linkWidgetName: String,
modalWidgetName: String, modalWidgetName: String,
}, },
@ -142,27 +142,23 @@ export default {
this.resetAlerts(); this.resetAlerts();
const zipCodeData = await this.getZipCodeData(this.internalModel.zipCode); const zipCodeData = await this.getZipCodeData(this.internalModel.zipCode);
this.resetModalButtonStyle();
if (!zipCodeData.isValid) { if (!zipCodeData.isValid) {
this.displayInvalidZipAlert = true; this.displayInvalidZipAlert = true;
this.focusOnZipInput(); this.focusOnZipInput();
this.resetModalButtonStyle();
} else { } else {
this.internalModel.state = zipCodeData.state; this.internalModel.state = zipCodeData.state;
// retrieve mobile fee part // retrieve mobile fee part
const serviceType = store.getters.damage.isRepair ? "Repair" : "Replace"; const serviceZipCode = this.internalModel.zipCode;
const parentAccountNumber = store.getters.payment.parentAccountNumber; const mobileFeePart = await getPricedMobileFeePart(serviceZipCode);
const billToAccountNumber = 1;
const mobileFeePart = await getPricedMobileFeePart(this.internalModel.zipCode, serviceType, parentAccountNumber, billToAccountNumber);
// emit it to parent // emit it to parent
this.$emit("set-mobile-fee-part", mobileFeePart); this.$emit("set-mobile-fee-part", mobileFeePart);
// Update the page level model // Update the page level model
this.$emit("update:modelValue", this.internalModel); this.$emit("update:modelValue", this.internalModel);
this.closeModal(); this.closeModal();
} }
}, },