Mobile provider number setting on service-location page
This commit is contained in:
parent
19e419cd80
commit
7d5565fccf
3 changed files with 50 additions and 55 deletions
|
|
@ -1,5 +1,4 @@
|
|||
import { storeActions } from "@/constants/store-actions";
|
||||
import store from "@/store";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
|
||||
export async function getPricedMobileFeePart(serviceZipCode) {
|
||||
|
|
@ -72,17 +71,25 @@ export async function getAvailabilityRating(
|
|||
return Promise.resolve(shopStatus);
|
||||
}
|
||||
|
||||
// export function getMobileProvider(mobileProviderNumber) {
|
||||
// const provider = {
|
||||
// providerNumber: mobileProviderNumber,
|
||||
// address: {
|
||||
// streetAddress1: null,
|
||||
// streetAddress2: null,
|
||||
// city: null,
|
||||
// state: null,
|
||||
// zipCode: null,
|
||||
// zipCodeCtu: null,
|
||||
// },
|
||||
// };
|
||||
// return provider;
|
||||
// }
|
||||
export class Provider {
|
||||
constructor(providerNumber = null, address = null) {
|
||||
this.providerNumber = providerNumber;
|
||||
this.address = address ?? new ProviderAddress();
|
||||
}
|
||||
}
|
||||
|
||||
export class ProviderAddress {
|
||||
constructor(
|
||||
streetAddress = null,
|
||||
city = null,
|
||||
state = null,
|
||||
zipCode = null,
|
||||
zipCodeCtu = null
|
||||
) {
|
||||
this.streetAddress = streetAddress;
|
||||
this.city = city;
|
||||
this.state = state;
|
||||
this.zipCode = zipCode;
|
||||
this.zipCodeCtu = zipCodeCtu;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ import { settleAllPromises } from "@/helpers/layout-helper";
|
|||
import {
|
||||
getPricedMobileFeePart,
|
||||
getServiceabilityDetails,
|
||||
Provider,
|
||||
} from "@/layouts/service-location/helpers/service-location-helper/service-location-helper";
|
||||
import store from "@/store";
|
||||
|
||||
|
|
@ -150,7 +151,7 @@ export default {
|
|||
mobileFeePart: null,
|
||||
zipContainsMilitaryBase: false,
|
||||
zipCodeCtu: null,
|
||||
providerData: [],
|
||||
providerData: null,
|
||||
};
|
||||
},
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
|
|
@ -200,7 +201,12 @@ export default {
|
|||
resultMap.serviceabilityDetails,
|
||||
resultMap.mobileFeePart
|
||||
);
|
||||
|
||||
// Initialize the Shop Question component
|
||||
vm.$refs.shopQuestion.initializeComponent(resultMap.shopQuestionInitialData);
|
||||
|
||||
// Initialize the page level shop data
|
||||
vm.providerData = resultMap.shopQuestionInitialData;
|
||||
});
|
||||
},
|
||||
computed: {
|
||||
|
|
@ -422,18 +428,19 @@ export default {
|
|||
selectedAppointmentType: {
|
||||
handler(newValue) {
|
||||
if (newValue === "Mobile") {
|
||||
this.selectedProvider = this.defaultProvider;
|
||||
this.selectedProvider.providerNumber = this.providerData.mobileProviderNumber;
|
||||
this.selectedProvider = new Provider(this.providerData.mobileProviderNumber);
|
||||
} else {
|
||||
this.selectedProvider = new Provider();
|
||||
}
|
||||
},
|
||||
providerData: {
|
||||
handler(newValue) {
|
||||
if (newValue === "Mobile") {
|
||||
this.selectedProvider = this.defaultProvider;
|
||||
this.selectedProvider.providerNumber =
|
||||
this.providerData.mobileProviderNumber;
|
||||
}
|
||||
},
|
||||
},
|
||||
providerData: {
|
||||
handler(newValue) {
|
||||
if (newValue === "Mobile") {
|
||||
this.selectedProvider = new Provider(this.providerData.mobileProviderNumber);
|
||||
} else {
|
||||
this.selectedProvider = new Provider();
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ import { errorMessages } from "@/constants/error-messages";
|
|||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import { nextTick } from "vue";
|
||||
|
||||
import { getAvailabilityRating } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper";
|
||||
import { getAvailabilityRating, Provider } from "@/layouts/service-location/helpers/service-location-helper/service-location-helper";
|
||||
|
||||
defineRule("option-required", required(errorMessages.OPTION_REQUIRED));
|
||||
|
||||
|
|
@ -95,10 +95,9 @@ export default {
|
|||
return this.selectedValue?.providerNumber;
|
||||
},
|
||||
set: function (newValue) {
|
||||
console.log(`set: ${newValue}`);
|
||||
// Button Question only supports Number, or String data types so we must get the full object to emit
|
||||
this.selectedValue =
|
||||
this.getSelectedProviderObject(newValue) ?? this.defaultProvider;
|
||||
this.getSelectedProviderObject(newValue);
|
||||
},
|
||||
},
|
||||
displayDropoffInformation() {
|
||||
|
|
@ -198,28 +197,15 @@ export default {
|
|||
async reloadShopData(serviceZipCode) {
|
||||
const result = await this.loadData(serviceZipCode);
|
||||
this.initializeComponent(result.data);
|
||||
console.log("reloadShopData");
|
||||
|
||||
this.resetAnswers();
|
||||
|
||||
await nextTick();
|
||||
await this.getNextShopsFromList();
|
||||
},
|
||||
getSelectedProviderObject(providerNumber) {
|
||||
const defaultProvider = {
|
||||
providerNumber: null,
|
||||
address: {
|
||||
streetAddress1: null,
|
||||
streetAddress2: null,
|
||||
city: null,
|
||||
state: null,
|
||||
zipCode: null,
|
||||
zipCodeCtu: null,
|
||||
},
|
||||
};
|
||||
|
||||
const provider =
|
||||
this.shopProviders?.find((provider) => provider.providerNumber == providerNumber) ??
|
||||
defaultProvider;
|
||||
this.shopProviders?.find((provider) => provider.providerNumber == providerNumber) ?? new Provider();
|
||||
|
||||
return provider;
|
||||
},
|
||||
|
|
@ -233,20 +219,15 @@ export default {
|
|||
},
|
||||
watch: {
|
||||
selectedAppointmentType: {
|
||||
async handler(newValue) {
|
||||
// Question: Does it matter if this fires when clicking Mobile? Ideally it should not, but it doesn't seem to effect anything
|
||||
// What we DON'T want to do here is create a dependency by checking if the selectedAppointmentType is Mobile as that has
|
||||
// nothing to do with this component. We could mitigate this by showing / hiding this component with v-if but that messes
|
||||
// up the component initialization on page load.
|
||||
async handler() {
|
||||
this.resetAnswers();
|
||||
|
||||
await nextTick();
|
||||
|
||||
if (newValue !== "Mobile") {
|
||||
this.selectedProviderNumber = -1;
|
||||
}
|
||||
|
||||
await nextTick();
|
||||
|
||||
if (newValue !== "Mobile") {
|
||||
this.getNextShopsFromList();
|
||||
}
|
||||
this.getNextShopsFromList();
|
||||
},
|
||||
},
|
||||
shopProviders: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue