Checkpoint - needs additional testing / debugging

This commit is contained in:
Leah Schumann 2023-04-25 13:04:02 -04:00
parent 01fbea8f62
commit 77ebdf1a7e
3 changed files with 104 additions and 113 deletions

View file

@ -46,7 +46,7 @@
alertClass="alert-warning" /> alertClass="alert-warning" />
<appointmentTypeQuestion <appointmentTypeQuestion
v-model="selectedAppointmentType" v-model="selectedAppointmentType"
v-if="!displayNoShopsAlert" v-show="!displayNoShopsAlert"
:isServiceableMobile="isServiceableMobile" :isServiceableMobile="isServiceableMobile"
:isServiceableInshop="isServiceableInshop" :isServiceableInshop="isServiceableInshop"
ref="appointmentTypeQuestion" ref="appointmentTypeQuestion"
@ -67,12 +67,14 @@
modalWidgetName="MobileLocationModalWidget" /> modalWidgetName="MobileLocationModalWidget" />
<shopQuestion <shopQuestion
ref="shopQuestion" ref="shopQuestion"
v-show="selectedAppointmentType === 'Inshop' || selectedAppointmentType === 'Dropoff'" v-show="
v-model="selectedShop" selectedAppointmentType === 'Inshop' || selectedAppointmentType === 'Dropoff'
"
v-model="providerNumber"
:isDropoff="isDropoff" :isDropoff="isDropoff"
:serviceZipCode="zipCode" :serviceZipCode="zipCode"
:selectedAppointmentType="selectedAppointmentType" :selectedAppointmentType="selectedAppointmentType"
:shopQuestionData="shopQuestionData" :shopQuestionData="shopQuestionInitialData"
cmsWidgetName="ShopQuestionWidget" /> cmsWidgetName="ShopQuestionWidget" />
<contentGroupModal ref="RecalModal" cmsWidgetName="RecalModal" /> <contentGroupModal ref="RecalModal" cmsWidgetName="RecalModal" />
<funnel-footer <funnel-footer
@ -147,9 +149,8 @@ export default {
mobileFeePart: null, mobileFeePart: null,
zipContainsMilitaryBase: false, zipContainsMilitaryBase: false,
selectedAppointmentType: "Dropoff", selectedAppointmentType: "Dropoff",
providerNumber: null, providerNumber: "127",
shopQuestionData: null, shopQuestionInitialData: null,
selectedShop: "",
}; };
}, },
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
@ -163,7 +164,7 @@ export default {
const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode); const mobileFeePartPromise = getPricedMobileFeePart(serviceZipCode);
const shopQuestionDataPromise = shopQuestion.methods.loadData(); const shopQuestionInitialDataPromise = shopQuestion.methods.loadInitialData();
// Settle promises and get results // Settle promises and get results
const promiseResultMap = [ const promiseResultMap = [
@ -184,8 +185,8 @@ export default {
promise: getZipCodeData, promise: getZipCodeData,
}, },
{ {
resultKey: "shopQuestionData", resultKey: "shopQuestionInitialData",
promise: shopQuestionDataPromise, promise: shopQuestionInitialDataPromise,
}, },
]; ];
@ -197,9 +198,9 @@ export default {
vm.setData( vm.setData(
resultMap.zipCodeData, resultMap.zipCodeData,
resultMap.serviceabilityDetails, resultMap.serviceabilityDetails,
resultMap.mobileFeePart, resultMap.mobileFeePart
resultMap.shopQuestionData
); );
vm.$refs.shopQuestion.initializeComponent(resultMap.shopQuestionInitialData);
}); });
}, },
computed: { computed: {
@ -321,10 +322,6 @@ export default {
if (mobileFeePart) { if (mobileFeePart) {
this.mobileFeePart = mobileFeePart; this.mobileFeePart = mobileFeePart;
} }
if (shopQuestionData) {
this.shopQuestionData = shopQuestionData;
}
}, },
setContainsMilitaryBase(val) { setContainsMilitaryBase(val) {
if (this.zipContainsMilitaryBase !== val) { if (this.zipContainsMilitaryBase !== val) {
@ -374,6 +371,15 @@ export default {
this.$refs[modalName].openModal(); this.$refs[modalName].openModal();
}, },
}, },
// watch: {
// zipCode: {
// async handler() {
// console.log(this.$refs)
// const initialData = await this.$refs.shopQuestion.loadInitialData();
// this.$refs.shopQuestion.initializeComponent(initialData);
// }
// }
// },
components: { components: {
alert, alert,
serviceZipModalQuestion, serviceZipModalQuestion,

View file

@ -71,17 +71,12 @@ export default {
serviceZipCode: String, serviceZipCode: String,
selectedAppointmentType: String, selectedAppointmentType: String,
cmsWidgetName: String, cmsWidgetName: String,
shopQuestionData: { shopQuestionInitialData: {
type: Object, type: Object,
required: true, required: true,
}, },
validationRules: String, validationRules: String,
}, },
components: {
alert,
buttonQuestion,
textLink,
},
computed: { computed: {
questionText() { questionText() {
return this.getCmsContent(this.cmsWidgetName, "QuestionText"); return this.getCmsContent(this.cmsWidgetName, "QuestionText");
@ -102,31 +97,26 @@ export default {
}, },
}, },
methods: { methods: {
loadData() { loadInitialData() {
return baseMixin.methods.dispatchStoreAction(storeActions.GET_PROVIDER_LOCATIONS, { return baseMixin.methods.dispatchStoreAction(storeActions.GET_PROVIDER_LOCATIONS, {
serviceZipCode: this.serviceZipCode, serviceZipCode: this.serviceZipCode,
}); });
}, },
async updateShopList() { initializeComponent(shopQuestionInitialData) {
const result = await this.dispatchStoreAction(storeActions.GET_PROVIDER_LOCATIONS, { this.shops = shopQuestionInitialData;
serviceZipCode: this.serviceZipCode,
});
this.resetShopList();
return result.data;
}, },
shopIterator(array, n) { getNextShopsFromList(numberToGet = 3) {
let l = array.length; const shopIterator = (array, n) => {
return () => { let l = array.length;
var end = this.shopIndex + n; return () => {
var part = array.slice(this.shopIndex, end); var end = this.shopIndex + n;
this.shopIndex = end < l ? end : this.shops.length; var part = array.slice(this.shopIndex, end);
return part; this.shopIndex = end < l ? end : this.shops.length;
return part;
};
}; };
},
async getNextShopsFromList() { const nextShop = shopIterator(this.shops, numberToGet);
const nextShop = this.shopIterator(this.shops, 3);
// Map API result data // Map API result data
const mappedData = nextShop().map((shop) => { const mappedData = nextShop().map((shop) => {
@ -147,70 +137,68 @@ export default {
}); });
} }
await this.$nextTick(); this.$nextTick().then(() => {
if (this.shopIndex == this.shops.length) {
if (this.shopIndex == this.shops.length) { this.displaySeeMoreLocationsLink = false;
this.displaySeeMoreLocationsLink = false; } else {
} else { this.displaySeeMoreLocationsLink = true;
this.displaySeeMoreLocationsLink = true; }
}
await this.$nextTick();
const container = document.getElementsByClassName("page-container-grouped-styles")[0];
container.scrollTo({ top: container.scrollHeight, left: 0, behavior: "smooth" });
this.$nextTick().then(() => {
this.scrollToBottom();
});
});
}, },
resetShopList() { resetShopList() {
this.answers = []; this.answers = [];
this.shopIndex = 0; this.shopIndex = 0;
this.getNextShopsFromList();
this.displaySeeMoreLocationsLink = true; this.displaySeeMoreLocationsLink = true;
this.selectedValue = ""; this.selectedValue = "";
this.$refs.buttonQuestion.resetField(); this.$refs.buttonQuestion.resetField();
}, },
scrollToBottom() {
const container = document.getElementsByClassName("page-container-grouped-styles")[0];
container.scrollTo({ top: container.scrollHeight, left: 0, behavior: "smooth" });
},
}, },
// mounted() {
// console.log(this.shopQuestionData);
// this.shops = this.shopQuestionData;
// this.getNextShopsFromList();
// console.log(this.shops);
// },
watch: { watch: {
serviceZipCode: { serviceZipCode: {
async handler() { handler(newValue) {
this.shops = await this.updateShopList(); this.loadInitialData(newValue).then((result) => {
this.initializeComponent(result.data);
this.resetShopList();
});
}, },
}, },
selectedAppointmentType: { selectedAppointmentType: {
async handler(newValue, oldValue) { handler(newValue) {
if (oldValue == undefined) { // If the validation has been previously triggered, clear it before displaying the component
this.shops = this.shopQuestionData; this.$refs.buttonQuestion.resetField();
this.getNextShopsFromList();
this.displaySeeMoreLocationsLink = true; if (newValue != null) {
return; this.$nextTick().then(() => {
this.scrollToBottom();
});
} }
await this.$nextTick();
const container = document.getElementsByClassName(
"page-container-grouped-styles"
)[0];
container.scrollTo({ top: container.scrollHeight, left: 0, behavior: "smooth" });
this.resetShopList();
}, },
}, },
shopQuestionData: { shops: {
handler(newValue) { handler(newValue) {
console.log(newValue) this.$refs.buttonQuestion.resetField();
this.shops = newValue; const selectedShopIndex = newValue.findIndex((provider) => provider.providerNumber == this.modelValue);
this.getNextShopsFromList(); if (selectedShopIndex >= 3) {
this.getNextShopsFromList(selectedShopIndex + 1);
} else {
this.getNextShopsFromList();
}
}, },
} },
},
components: {
alert,
buttonQuestion,
textLink,
}, },
}; };
</script> </script>

View file

@ -24,38 +24,35 @@ import { applicationConfig } from "../constants/application-config";
export default { export default {
methods: { methods: {
logPageView(pageEvent) { logPageView(pageEvent) {
const currentPageName = getPageNameByQueryString(); // const currentPageName = getPageNameByQueryString();
var payload = { // var payload = {
userId: getDeviceIdValue(), // userId: getDeviceIdValue(),
sessionKey: getSessionKeyValue(), // sessionKey: getSessionKeyValue(),
pageName: currentPageName, // pageName: currentPageName,
sessionId: getSessionIdValue(), // sessionId: getSessionIdValue(),
action: "", // action: "",
event: pageEvent, // event: pageEvent,
shouldUseSessionId: false, // shouldUseSessionId: false,
experimentsForUser: store.getters.applicationUser.experiments, // experimentsForUser: store.getters.applicationUser.experiments,
}; // };
// baseMixin.methods.dispatchStoreAction(storeActions.LOG_PAGE_VIEW, payload, false);
baseMixin.methods.dispatchStoreAction(storeActions.LOG_PAGE_VIEW, payload, false);
}, },
logCustomEvent(category, action, label, value) { logCustomEvent(category, action, label, value) {
const currentPageName = getPageNameByQueryString(); // const currentPageName = getPageNameByQueryString();
// var payload = {
var payload = { // userId: getDeviceIdValue(),
userId: getDeviceIdValue(), // sessionKey: getSessionKeyValue(),
sessionKey: getSessionKeyValue(), // pageName: currentPageName,
pageName: currentPageName, // sessionId: getSessionIdValue(),
sessionId: getSessionIdValue(), // category: category,
category: category, // action: action,
action: action, // label: label,
label: label, // value: value,
value: value, // shouldUseSessionId: false,
shouldUseSessionId: false, // experimentsForUser: store.getters.applicationUser.experiments,
experimentsForUser: store.getters.applicationUser.experiments, // };
}; // baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false);
baseMixin.methods.dispatchStoreAction(storeActions.LOG_CUSTOM_EVENT, payload, false);
}, },
pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) { pushEventToGA(category, action, label, pushToLogApp = false, valueToLogType = null) {