update for availabilityrating matching schedule
This commit is contained in:
parent
76b899fcf3
commit
e74a998665
3 changed files with 35 additions and 46 deletions
|
|
@ -17,6 +17,7 @@
|
||||||
<div class="service-location-content-container">
|
<div class="service-location-content-container">
|
||||||
<serviceLocation
|
<serviceLocation
|
||||||
ref="serviceLocation"
|
ref="serviceLocation"
|
||||||
|
:schedulingInshopAvailabilityRating="inShopAvailabilityRating"
|
||||||
@appointmentTypeChanged="appointmentTypeChangedFromServiceLocation"
|
@appointmentTypeChanged="appointmentTypeChangedFromServiceLocation"
|
||||||
@cityUpdated="cityUpdatedFromServiceLocation"
|
@cityUpdated="cityUpdatedFromServiceLocation"
|
||||||
@inShopZipUpdated="inShopZipUpdatedFromServiceLocation"
|
@inShopZipUpdated="inShopZipUpdatedFromServiceLocation"
|
||||||
|
|
@ -310,6 +311,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
inShopAvailabilityRating: 'high',
|
||||||
inShopDatesData: [],
|
inShopDatesData: [],
|
||||||
isMobileView: false,
|
isMobileView: false,
|
||||||
mobileDatesData: [],
|
mobileDatesData: [],
|
||||||
|
|
@ -364,6 +366,27 @@ export default {
|
||||||
return useMainStore().lineItems.supportingItems;
|
return useMainStore().lineItems.supportingItems;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
watch: {
|
||||||
|
inShopDatesData(newData) {
|
||||||
|
if (newData?.initialShopTimeSlotsResponse?.days?.length > 0) {
|
||||||
|
const numberOfDaysNeededToBeHighAvailability = 2;
|
||||||
|
const availabilityEndDate = new Date();
|
||||||
|
availabilityEndDate.setDate(availabilityEndDate.getDate() + 6);
|
||||||
|
|
||||||
|
const datesInAvailabilityRange = newData.initialShopTimeSlotsResponse.days.filter((day) => {
|
||||||
|
const dayDate = new Date(`${day.date}T00:00:00`);
|
||||||
|
return dayDate <= availabilityEndDate;
|
||||||
|
});
|
||||||
|
const isGoodAvailability =
|
||||||
|
datesInAvailabilityRange.filter((x) => x.timeSlots.length > 0).length
|
||||||
|
>= numberOfDaysNeededToBeHighAvailability;
|
||||||
|
|
||||||
|
this.inShopAvailabilityRating = isGoodAvailability ? 'high' : 'low';
|
||||||
|
} else {
|
||||||
|
this.inShopAvailabilityRating = 'low';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
showIssLoadingModal(true);
|
showIssLoadingModal(true);
|
||||||
this.mql = window.matchMedia('(min-width: 1200px)');
|
this.mql = window.matchMedia('(min-width: 1200px)');
|
||||||
|
|
@ -453,9 +476,6 @@ export default {
|
||||||
},
|
},
|
||||||
getAvailableDates,
|
getAvailableDates,
|
||||||
async getDatePickerInitialData(defaultProviderNumber = null) {
|
async getDatePickerInitialData(defaultProviderNumber = null) {
|
||||||
this.inShopDatesData = [];
|
|
||||||
this.mobileDatesData = [];
|
|
||||||
|
|
||||||
let todayDateString;
|
let todayDateString;
|
||||||
const todayDateObject = new Date();
|
const todayDateObject = new Date();
|
||||||
const calendarViewDirection = 'future';
|
const calendarViewDirection = 'future';
|
||||||
|
|
@ -532,6 +552,7 @@ export default {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.inShopDatesData = initialData;
|
this.inShopDatesData = initialData;
|
||||||
|
this.mobileDatesData = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return initialData;
|
return initialData;
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,6 @@ import errorMessages from '@/constants/error-messages';
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import showIssLoadingModal from '@/helpers/loading-modal-helper.js';
|
import showIssLoadingModal from '@/helpers/loading-modal-helper.js';
|
||||||
import {
|
import {
|
||||||
getAvailabilityRating,
|
|
||||||
getServiceabilityDetails,
|
getServiceabilityDetails,
|
||||||
getZipCodeData,
|
getZipCodeData,
|
||||||
getMobileZipCodeData
|
getMobileZipCodeData
|
||||||
|
|
@ -160,6 +159,12 @@ export default {
|
||||||
},
|
},
|
||||||
mixins: [baseFormMixin],
|
mixins: [baseFormMixin],
|
||||||
emits: ['appointment-type-changed', 'city-updated', 'in-shop-zip-updated', 'mobile-zip-updated', 'provider-changed'],
|
emits: ['appointment-type-changed', 'city-updated', 'in-shop-zip-updated', 'mobile-zip-updated', 'provider-changed'],
|
||||||
|
props: {
|
||||||
|
schedulingInshopAvailabilityRating: {
|
||||||
|
type: String,
|
||||||
|
default: 'high'
|
||||||
|
}
|
||||||
|
},
|
||||||
setup() {
|
setup() {
|
||||||
const mainStore = useMainStore();
|
const mainStore = useMainStore();
|
||||||
return { mainStore };
|
return { mainStore };
|
||||||
|
|
@ -307,9 +312,12 @@ export default {
|
||||||
this.$emit('mobile-zip-updated', updateMobileZipServiceLocationObj);
|
this.$emit('mobile-zip-updated', updateMobileZipServiceLocationObj);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
schedulingInshopAvailabilityRating(newRating) {
|
||||||
|
this.availabilityRating = newRating;
|
||||||
|
},
|
||||||
selectedAppointmentType(newValue, oldValue) {
|
selectedAppointmentType(newValue, oldValue) {
|
||||||
if (this.isInshop && this.selectedProvider && this.availabilityRating === null) {
|
if (this.isInshop && this.selectedProvider && this.availabilityRating === null) {
|
||||||
this.refreshAvailabilityRating();
|
// this.refreshAvailabilityRating();
|
||||||
|
|
||||||
const appointmenTypeServiceLocationObj = {
|
const appointmenTypeServiceLocationObj = {
|
||||||
appointmentType: newValue,
|
appointmentType: newValue,
|
||||||
|
|
@ -342,10 +350,6 @@ export default {
|
||||||
refreshDatePicker: appointmentIsInshop && oldProvider?.providerNumber !== null
|
refreshDatePicker: appointmentIsInshop && oldProvider?.providerNumber !== null
|
||||||
};
|
};
|
||||||
|
|
||||||
if (appointmentIsInshop && newProvider?.providerNumber != null) {
|
|
||||||
this.refreshAvailabilityRating();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newProvider?.providerNumber !== oldProvider?.providerNumber) {
|
if (newProvider?.providerNumber !== oldProvider?.providerNumber) {
|
||||||
this.$emit('provider-changed', returnedProvider);
|
this.$emit('provider-changed', returnedProvider);
|
||||||
}
|
}
|
||||||
|
|
@ -444,24 +448,6 @@ export default {
|
||||||
this.$emit('in-shop-zip-updated', inShopZipServiceLocationObj);
|
this.$emit('in-shop-zip-updated', inShopZipServiceLocationObj);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
refreshAvailabilityRating() {
|
|
||||||
const startDate = new Date();
|
|
||||||
const endDate = new Date();
|
|
||||||
endDate.setDate(startDate.getDate() + 6);
|
|
||||||
const formattedStartDate = startDate.toISOString().split('T')[0];
|
|
||||||
const formattedEndDate = endDate.toISOString().split('T')[0];
|
|
||||||
|
|
||||||
getAvailabilityRating(
|
|
||||||
formattedStartDate,
|
|
||||||
formattedEndDate,
|
|
||||||
AppointmentTypeStrings.IN_SHOP,
|
|
||||||
this.selectedProvider ? this.selectedProvider.providerNumber : null
|
|
||||||
).then((rating) => {
|
|
||||||
this.availabilityRating = rating;
|
|
||||||
}).catch(() => {
|
|
||||||
this.availabilityRating = null;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
setCtuForMobile(val) {
|
setCtuForMobile(val) {
|
||||||
this.zipCodeCtu = val;
|
this.zipCodeCtu = val;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,7 @@
|
||||||
groupName="chooseShop"
|
groupName="chooseShop"
|
||||||
textPosition="text-start"
|
textPosition="text-start"
|
||||||
isRequired
|
isRequired
|
||||||
validationRules="option-required"
|
validationRules="option-required" />
|
||||||
:additionalButtonData="additionalButtonData" />
|
|
||||||
<span class="service-zip-prompt">
|
<span class="service-zip-prompt">
|
||||||
{{ serviceZipPrompt }}
|
{{ serviceZipPrompt }}
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -108,7 +107,6 @@ import baseMixin from '@/mixins/base-mixin.js';
|
||||||
import showIssLoadingModal from '@/helpers/loading-modal-helper.js';
|
import showIssLoadingModal from '@/helpers/loading-modal-helper.js';
|
||||||
import { toTitleCase } from '@/helpers/text-helper.js';
|
import { toTitleCase } from '@/helpers/text-helper.js';
|
||||||
import { markRaw } from 'vue';
|
import { markRaw } from 'vue';
|
||||||
import { getAvailabilityRating } from '@/helpers/service-location-helper';
|
|
||||||
import { useMainStore } from '@/store';
|
import { useMainStore } from '@/store';
|
||||||
import widgetFields from '@/constants/cms-widget-fields';
|
import widgetFields from '@/constants/cms-widget-fields';
|
||||||
import { dropdownVariants, modalPositions } from '@/constants/component-variants';
|
import { dropdownVariants, modalPositions } from '@/constants/component-variants';
|
||||||
|
|
@ -185,22 +183,6 @@ export default {
|
||||||
modalName() {
|
modalName() {
|
||||||
return this.modalWidgetName;
|
return this.modalWidgetName;
|
||||||
},
|
},
|
||||||
additionalButtonData() {
|
|
||||||
const startDate = new Date();
|
|
||||||
const endDate = new Date();
|
|
||||||
endDate.setDate(startDate.getDate() + 6);
|
|
||||||
|
|
||||||
const formattedStartDate = startDate.toISOString().split('T')[0];
|
|
||||||
const formattedEndDate = endDate.toISOString().split('T')[0];
|
|
||||||
|
|
||||||
return {
|
|
||||||
displayAvailabilityIndicators: false,
|
|
||||||
availabilityRatingCallback: getAvailabilityRating,
|
|
||||||
startDate: formattedStartDate,
|
|
||||||
endDate: formattedEndDate,
|
|
||||||
shopAppointmentType: 'InshopOrDropoff'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
serviceZipPrompt() {
|
serviceZipPrompt() {
|
||||||
return this.getCmsContent(this.modalWidgetName, widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2);
|
return this.getCmsContent(this.modalWidgetName, widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2);
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue