Merge pull request #683 from Safelite/feature/richardson/misc-style-fixes

format only
This commit is contained in:
brich1212safe 2024-05-06 12:12:55 -04:00 committed by GitHub
commit 3dcd58e4e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -90,16 +90,16 @@ import {
AppointmentTypeStrings, AppointmentTypeStrings,
GET_MOBILE_TIME_SLOTS, GET_MOBILE_TIME_SLOTS,
GET_SHOP_TIME_SLOTS, GET_SHOP_TIME_SLOTS,
PREMIUM_FEE_PART_TYPE, PREMIUM_FEE_PART_TYPE
} from '@/constants/schedule-constants.js'; } from '@/constants/schedule-constants.js';
import { import {
fetchCmsContentForPage, fetchCmsContentForPage,
splitCopyOnCMSPlaceHolder, splitCopyOnCMSPlaceHolder
} from '@/helpers/cms-content-helper'; } from '@/helpers/cms-content-helper';
import { import {
calcDaysBetweenDates, calcDaysBetweenDates,
convertDateStringToDate, convertDateStringToDate,
sumDateString, sumDateString
} from '@/helpers/date-helper'; } from '@/helpers/date-helper';
import settleAllPromises from '@/helpers/layout-helper'; import settleAllPromises from '@/helpers/layout-helper';
import { Form, defineRule } from 'vee-validate'; import { Form, defineRule } from 'vee-validate';
@ -156,16 +156,16 @@ const getAvailableDates = async (
} }
if ( if (
appointmentType === AppointmentTypeStrings.MOBILE || appointmentType === AppointmentTypeStrings.MOBILE
appointmentType === || appointmentType
AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
) { ) {
storeActionConfig = { storeActionConfig = {
storeAction: GET_MOBILE_TIME_SLOTS, storeAction: GET_MOBILE_TIME_SLOTS,
payload: { payload: {
startDate: apiStartDate, startDate: apiStartDate,
endDate: apiEndDate, endDate: apiEndDate
}, }
}; };
} else { } else {
storeActionConfig = { storeActionConfig = {
@ -174,16 +174,15 @@ const getAvailableDates = async (
startDate: apiStartDate, startDate: apiStartDate,
endDate: apiEndDate, endDate: apiEndDate,
shopAppointmentType: appointmentType, shopAppointmentType: appointmentType,
providerNumber, providerNumber
}, }
}; };
} }
if (apiStartDate < apiEndDate) if (apiStartDate < apiEndDate) storeActionConfigs.push(storeActionConfig);
storeActionConfigs.push(storeActionConfig);
} }
const timeSlotsResponsesData = { const timeSlotsResponsesData = {
days: [], days: []
}; };
function compareDayStrings(a, b) { function compareDayStrings(a, b) {
@ -193,33 +192,31 @@ const getAvailableDates = async (
} }
const makeParallelCalls = async () => { const makeParallelCalls = async () => {
await Promise.all( await Promise.all(storeActionConfigs.map(async (storeAction) => {
storeActionConfigs.map(async (storeAction) => { let timeSlotsResponse = null;
let timeSlotsResponse = null; if (storeAction.storeAction === GET_SHOP_TIME_SLOTS) {
if (storeAction.storeAction === GET_SHOP_TIME_SLOTS) { timeSlotsResponse = await useMainStore().getShopTimeSlots(
timeSlotsResponse = await useMainStore().getShopTimeSlots( storeAction.payload.startDate,
storeAction.payload.startDate, storeAction.payload.endDate,
storeAction.payload.endDate, storeAction.payload.shopAppointmentType,
storeAction.payload.shopAppointmentType, storeAction.payload.providerNumber
storeAction.payload.providerNumber );
); } else {
} else { timeSlotsResponse = await useMainStore().getMobileTimeSlots(
timeSlotsResponse = await useMainStore().getMobileTimeSlots( storeAction.payload.startDate,
storeAction.payload.startDate, storeAction.payload.endDate
storeAction.payload.endDate );
); }
}
timeSlotsResponsesData.estimatedServiceMinutesMinimum = timeSlotsResponsesData.estimatedServiceMinutesMinimum =
timeSlotsResponse.data.estimatedServiceMinutesMinimum; timeSlotsResponse.data.estimatedServiceMinutesMinimum;
timeSlotsResponsesData.estimatedServiceMinutesMaximum = timeSlotsResponsesData.estimatedServiceMinutesMaximum =
timeSlotsResponse.data.estimatedServiceMinutesMaximum; timeSlotsResponse.data.estimatedServiceMinutesMaximum;
timeSlotsResponsesData.days = [ timeSlotsResponsesData.days = [
...timeSlotsResponsesData.days, ...timeSlotsResponsesData.days,
...timeSlotsResponse.data.days, ...timeSlotsResponse.data.days
]; ];
}) }));
);
}; };
return makeParallelCalls().then(() => { return makeParallelCalls().then(() => {
@ -240,7 +237,7 @@ export default {
siteFooter, siteFooter,
textBlock, textBlock,
// eslint-disable-next-line vue/no-reserved-component-names // eslint-disable-next-line vue/no-reserved-component-names
Form, Form
}, },
mixins: [BaseFormMixin], mixins: [BaseFormMixin],
async beforeRouteEnter(to, from, next) { async beforeRouteEnter(to, from, next) {
@ -257,7 +254,7 @@ export default {
selectableDatesSetting: 'custom', selectableDatesSetting: 'custom',
initialViewRowsToShow: 5, initialViewRowsToShow: 5,
customSelectableDatesCallback: getAvailableDates, customSelectableDatesCallback: getAvailableDates,
preSelectedDate, preSelectedDate
}); });
const premiumFeePromise = useMainStore().getMobilePremiumFee(); const premiumFeePromise = useMainStore().getMobilePremiumFee();
@ -278,29 +275,27 @@ export default {
const promiseResultMap = [ const promiseResultMap = [
{ {
resultKey: 'cmsContent', resultKey: 'cmsContent',
promise: cmsContentPromise, promise: cmsContentPromise
}, },
{ {
resultKey: 'alertReasons', resultKey: 'alertReasons',
promise: alertReasonsPromise, promise: alertReasonsPromise
}, },
{ {
resultKey: 'datePickerInitialData', resultKey: 'datePickerInitialData',
promise: datePickerInitialDataPromise, promise: datePickerInitialDataPromise
}, },
{ {
resultKey: 'premiumFeeWithPrice', resultKey: 'premiumFeeWithPrice',
promise: premiumFeeWithPricePromise, promise: premiumFeeWithPricePromise
}, }
]; ];
// use resultMap to populate layout content. // use resultMap to populate layout content.
const resultMap = await settleAllPromises(promiseResultMap); const resultMap = await settleAllPromises(promiseResultMap);
next((vm) => { next((vm) => {
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
vm.$refs.datePicker.initializeComponent( vm.$refs.datePicker.initializeComponent(resultMap.datePickerInitialData);
resultMap.datePickerInitialData
);
vm.$refs.locationAlerts.initializeComponent(resultMap.alertReasons); vm.$refs.locationAlerts.initializeComponent(resultMap.alertReasons);
vm.setData( vm.setData(
resultMap.datePickerInitialData.initialShopTimeSlotsResponse, resultMap.datePickerInitialData.initialShopTimeSlotsResponse,
@ -318,7 +313,7 @@ export default {
selectedDate: this.getSelectedDate(), selectedDate: this.getSelectedDate(),
selectedTimeSlotInfo: this.getSelectedTimeSlotInfo(), selectedTimeSlotInfo: this.getSelectedTimeSlotInfo(),
selectableDatesData: [], selectableDatesData: [],
mobilePremiumAppointmentFee: null, mobilePremiumAppointmentFee: null
}; };
}, },
computed: { computed: {
@ -336,13 +331,11 @@ export default {
return null; return null;
} }
return this.selectableDatesData.days?.find( return this.selectableDatesData.days?.find((selectableDate) => selectableDate.date === this.selectedDate);
(selectableDate) => selectableDate.date === this.selectedDate
);
}, },
supportingItems() { supportingItems() {
return useMainStore().lineItems.supportingItems; return useMainStore().lineItems.supportingItems;
}, }
}, },
watch: { watch: {
selectedDate(newValue, oldValue) { selectedDate(newValue, oldValue) {
@ -355,34 +348,34 @@ export default {
startTime: null, startTime: null,
endTime: null, endTime: null,
jobMaxMinutes: null, jobMaxMinutes: null,
jobMinMinutes: null, jobMinMinutes: null
}, },
isPremiumAppointment: null, isPremiumAppointment: null
}; };
} }
}, },
selectedTimeSlotInfo(newValue) { selectedTimeSlotInfo(newValue) {
this.updateFooterButtonText(newValue); this.updateFooterButtonText(newValue);
}, }
}, },
methods: { methods: {
splitCopyOnCMSPlaceHolder, splitCopyOnCMSPlaceHolder,
arePagePrerequisitesValid() { arePagePrerequisitesValid() {
const { serviceLocation } = useMainStore().order; const { serviceLocation } = useMainStore().order;
const serviceLocationPreReqs = const serviceLocationPreReqs =
serviceLocation.zipCode && serviceLocation.zipCode
serviceLocation.zipCodeCtu && && serviceLocation.zipCodeCtu
serviceLocation.appointmentType && && serviceLocation.appointmentType
(serviceLocation.appointmentType === && (serviceLocation.appointmentType
AppointmentTypeStrings.MOBILE || === AppointmentTypeStrings.MOBILE
serviceLocation.appointmentType === || serviceLocation.appointmentType
AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP || === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP
serviceLocation.provider.providerNumber); || serviceLocation.provider.providerNumber);
const supportingItems = this.supportingItems !== null; const supportingItems = this.supportingItems !== null;
const damageInfo = const damageInfo =
useMainStore().order.damage.isRepair || useMainStore().order.damage.isRepair
(useMainStore().order.lineItems?.glassParts != null && || (useMainStore().order.lineItems?.glassParts != null
useMainStore().order.lineItems.glassParts.length > 0); && useMainStore().order.lineItems.glassParts.length > 0);
return serviceLocationPreReqs && supportingItems && damageInfo; return serviceLocationPreReqs && supportingItems && damageInfo;
}, },
@ -417,15 +410,13 @@ export default {
getSelectedTimeSlotInfo() { getSelectedTimeSlotInfo() {
const isPremiumAppointment = const isPremiumAppointment =
!!( !!(
this.supportingItems?.filter( this.supportingItems?.filter((lineItem) =>
(lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) ?? []
lineItem.partType === PREMIUM_FEE_PART_TYPE
) ?? []
).length > 0; ).length > 0;
const selectedTimeSlotInfo = { const selectedTimeSlotInfo = {
timeSlot: this.mainStore.order.schedule, timeSlot: this.mainStore.order.schedule,
isPremiumAppointment, isPremiumAppointment
}; };
return selectedTimeSlotInfo; return selectedTimeSlotInfo;
@ -441,16 +432,12 @@ export default {
if (!timeSlotInfo || !timeSlotInfo.timeSlot.date) { if (!timeSlotInfo || !timeSlotInfo.timeSlot.date) {
navbarButtonText = 'Continue'; navbarButtonText = 'Continue';
} else { } else {
navbarButtonText = `Select ${this.convertSelectedDateToShortMonthAndDay( navbarButtonText = `Select ${this.convertSelectedDateToShortMonthAndDay(timeSlotInfo.timeSlot.date)}`;
timeSlotInfo.timeSlot.date
)}`;
if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) { if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
navbarButtonText += ` at ${this.getDisplayTextForMilitaryTime( navbarButtonText += ` at ${this.getDisplayTextForMilitaryTime(timeSlotInfo.timeSlot.startTime)}`;
timeSlotInfo.timeSlot.startTime
)}`;
} else if ( } else if (
this.appointmentType === AppointmentTypeStrings.MOBILE && this.appointmentType === AppointmentTypeStrings.MOBILE
!timeSlotInfo.isPremiumAppointment && !timeSlotInfo.isPremiumAppointment
) { ) {
navbarButtonText += ` at ${this.getDisplayTextForMilitaryTime( navbarButtonText += ` at ${this.getDisplayTextForMilitaryTime(
timeSlotInfo.timeSlot.startTime, timeSlotInfo.timeSlot.startTime,
@ -468,7 +455,7 @@ export default {
const dateObject = convertDateStringToDate(selectedDate); const dateObject = convertDateStringToDate(selectedDate);
return dateObject.toLocaleDateString('en-us', { return dateObject.toLocaleDateString('en-us', {
month: 'short', month: 'short',
day: 'numeric', day: 'numeric'
}); });
}, },
getDisplayTextForMilitaryTime( getDisplayTextForMilitaryTime(
@ -496,8 +483,8 @@ export default {
this.navigationScenarios.CLICKED_FORWARD, this.navigationScenarios.CLICKED_FORWARD,
this.$route this.$route
); );
}, }
}, }
}; };
</script> </script>