diff --git a/src/layouts/order-confirmation/order-confirmation.vue b/src/layouts/order-confirmation/order-confirmation.vue index 9ca4f5ea..464d0b24 100644 --- a/src/layouts/order-confirmation/order-confirmation.vue +++ b/src/layouts/order-confirmation/order-confirmation.vue @@ -26,7 +26,7 @@
-

{{ appointmentDateFormatted }}

+

{{ formatDate(schedule.date) }}

{{ appointmentTimeFormatted }}

+ :scheduleDate="schedule.date" + :scheduleStartTime="schedule.startTime" + :scheduleEndTime="schedule.endTime" />
@@ -54,7 +54,7 @@
'); }, orderConfirmationHeaderText() { - return this.getCmsContent('OrderConfirmationContent', 'HeaderText'); + return this.getCmsContent( + this.widgets.orderConfirmation, + widgetFields.CONTENT_GROUP_WIDGET.HEADER_TEXT); }, orderConfirmationImage() { - return this.getCmsContent('OrderConfirmationContent', 'Image'); - }, - appointmentType() { - return this.submittedOrder.serviceLocation.appointmentType; - }, - appointmentDate() { - return this.submittedOrder.schedule.date; - }, - appointmentStartTime() { - return this.submittedOrder.schedule.startTime; - }, - appointmentEndTime() { - return this.submittedOrder.schedule.endTime; - }, - appointmentDateFormatted() { - // This conversion ensures we don't get get GMT induced date changes - const dateObject = convertDateStringToDate(this.appointmentDate); - // Ex: Tuesday, April 22 - return dateObject.toLocaleDateString('en-us', { - weekday: 'long', - month: 'long', - day: 'numeric' - }); + return this.getCmsContent( + this.widgets.orderConfirmation, + widgetFields.CONTENT_GROUP_WIDGET.IMAGE); }, appointmentTimeFormatted() { - return this.formatAppointmentTime(this.appointmentType); + const { startTime, endTime } = this.schedule; + var appointmentTime = null; + if (this.isDropOffAppointment){ + appointmentTime = 'Drop off before 9:30 AM'; + } + if (this.isInShopAppointment){ + const formattedStartTime = get12HourTimeFormat(startTime); + appointmentTime = `at ${formattedStartTime}` + } + if (this.isMobileAppointment) { + const mobileStartTime = get12HourTimeMobileFormat(startTime); + const mobileEndTime = get12HourTimeMobileFormat(endTime); + appointmentTime = `Between ${mobileStartTime} - ${mobileEndTime}`; + } + return appointmentTime; }, mobileWordingText() { - //return this.getCmsContent('MobileWordingWidget', 'BodyText'); - var content = this.getCmsContent('MobileWordingWidget','BodyText'); - return getStringWithCustomValues(content, this.customValueMap); + return this.getCmsContentWithCustomValues( + this.widgets.mobile, + widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT); }, mobileWordingText2() { - return this.getCmsContent('MobileWordingWidget', 'BodyText2'); + return this.getCmsContent( + this.widgets.mobile, + widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2); }, dropOffAndInShopWordingText() { - // return this.getCmsContent( - // 'DropOffAndInShopWordingWidget', - // 'BodyText' - // ); - var content = this.getCmsContent('DropOffAndInShopWordingWidget','BodyText'); - return getStringWithCustomValues(content, this.customValueMap); + return this.getCmsContentWithCustomValues( + this.widgets.dropOffAndInShop, + widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT); }, dropOffAndInShopWordingText2() { - // var content = this.getCmsContent('DropOffAndInShopWordingWidget','BodyText2'); - // return getStringWithCustomValues(content, this.customValueMap); - //return this.getBodyText2FromCms('DropOffAndInShopWordingWidget'); - return this.getTextFromCmsWithCustomValues('DropOffAndInShopWordingWidget', 'BodyText2'); + return this.getCmsContentWithCustomValues( + this.widgets.dropOffAndInShop, + widgetFields.CONTENT_GROUP_WIDGET.BODY_TEXT_2); }, serviceLocationFullAddress() { - // eslint-disable-next-line max-len - return `${this.serviceLocationAddress}, ${ - this.serviceLocationAddress2 - ? `${this.serviceLocationAddress2},` + // var { address, address2, city, state, zipCode } = this.serviceLocation; + // console.log(JSON.stringify(this.serviceLocation)); + // return `${address}, ${address2 ? `${address2},` : ''}
${city}, ${state} ${zipCode}`; + + return `${this.serviceLocation.address}, ${ + this.serviceLocation.address2 + ? `${this.serviceLocation.address2},` : '' - }
${this.serviceLocationCity}, ${this.serviceLocationState} ${ - this.serviceLocationZipCode + }
${this.serviceLocation.city}, ${this.serviceLocation.state} ${ + this.serviceLocation.zipCode }`; }, providerAddress() { - return toTitleCase(this.submittedOrder.serviceLocation.provider.address - .streetAddress); + return toTitleCase(this.providerAddress?.streetAddress); }, providerCity() { - return toTitleCase(this.submittedOrder.serviceLocation.provider.address.city); - }, - providerState() { - return this.submittedOrder.serviceLocation.provider.address.state; - }, - providerZipCode() { - return this.submittedOrder.serviceLocation.provider.address.zipCode; + return toTitleCase(this.providerAddress?.city); }, providerFullAddress() { - // eslint-disable-next-line max-len - return this.submittedOrder.serviceLocation?.provider?.address - ? `${this.providerAddress},
${this.providerCity}, ${this.providerState} ${this.providerZipCode}` + var { state, zipCode } = this.providerAddress; + return this.providerAddress + ? `${this.providerAddress},
${this.providerCity}, ${state} ${zipCode}` : ''; }, appointmentWordingText() { - const wordingMap = { - [AppointmentTypeStrings.MOBILE]: this.mobileWordingText, - [AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP]: this.mobileWordingText, - [AppointmentTypeStrings.DROP_OFF]: this.dropOffAndInShopWordingText, - [AppointmentTypeStrings.IN_SHOP]: this.dropOffAndInShopWordingText - }; - - return wordingMap[this.appointmentType] || null; + var wording = null; + if (this.isMobileAppointment){ + wording = this.mobileWordingText; + } + if (this.isInShopAppointment || this.isDropOffAppointment){ + wording = this.dropOffAndInShopWordingText; + } + return wording; }, appointmentWordingText2() { - const wordingMap = { - [AppointmentTypeStrings.MOBILE]: this.mobileWordingText2, - [AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP]: this.mobileWordingText2, - [AppointmentTypeStrings.DROP_OFF]: this.dropOffAndInShopWordingText2, - [AppointmentTypeStrings.IN_SHOP]: this.dropOffAndInShopWordingText2 - }; - - return wordingMap[this.appointmentType] || null; + var wording = null; + if (this.isMobileAppointment){ + wording = this.mobileWordingText2; + } + if (this.isInShopAppointment || this.isDropOffAppointment){ + wording = this.dropOffAndInShopWordingText2; + } + return wording; }, - mobileAppointment() { - return ( - this.submittedOrder.serviceLocation.appointmentType - === AppointmentTypeStrings.MOBILE - || this.submittedOrder.serviceLocation.appointmentType - === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP - ); + isMobileAppointment() { + const mobileAppointmentTypes = [ + AppointmentTypeStrings.MOBILE, + AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP + ] + return mobileAppointmentTypes.includes(this.appointmentType); }, - inShopAppointment() { - return ( - this.submittedOrder.serviceLocation.appointmentType - === AppointmentTypeStrings.IN_SHOP - ); + isInShopAppointment() { + return this.appointmentType === AppointmentTypeStrings.IN_SHOP; }, - dropOffAppointment() { - return ( - this.submittedOrder.serviceLocation.appointmentType - === AppointmentTypeStrings.DROP_OFF - ); + isDropOffAppointment() { + return this.appointmentType === AppointmentTypeStrings.DROP_OFF; }, inShopAppointmentDuration() { - const inshopDurationTime = getDisplayTextForDurationLength( - this.submittedOrder.schedule.jobMinMinutes, - this.submittedOrder.schedule.jobMaxMinutes + return getDisplayTextForDurationLength( + this.schedule.jobMinMinutes, + this.schedule.jobMaxMinutes ); - return inshopDurationTime; - }, - isPayInAdvance() { - return this.submittedOrder.payment.isPayInAdvance; - }, - selectedVaps() { - return this.submittedOrder.lineItems.vaps; } }, mounted() { @@ -392,58 +382,24 @@ export default { forwardButtonAction() { this.$router.navigateToExternalUrl(this.carrierUrl); }, - formatAppointmentTime(appointmentType) { - switch (appointmentType) { - case AppointmentTypeStrings.MOBILE: - case AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP: - // eslint-disable-next-line max-len - return `Between ${get12HourTimeMobileFormat(this.appointmentStartTime)} - ${get12HourTimeMobileFormat(this.appointmentEndTime)}`; - case AppointmentTypeStrings.DROP_OFF: - return 'Drop off before 9:30 AM'; - case AppointmentTypeStrings.IN_SHOP: - return `at ${get12HourTimeFormat(this.appointmentStartTime)}`; - default: - return null; - } - }, - processIfStatements, - getTextFromCmsWithCustomValues(widgetName, widgetField) { + getCmsContentWithCustomValues(widgetName, widgetField) { const rawText = this.getCmsContent(widgetName, widgetField); - return processIfStatements( + const processedIfStatements = processIfStatements( rawText, 'custom', - //this.getCustomValueFromString - (v) => { - console.log(v); - return this.customValueMap[v]; - } - ); + (v) => { return this.customValueMap[v] } + ) + return getStringWithCustomValues(processedIfStatements, this.customValueMap); }, - getCustomValueFromString(str) { - switch (str) { - case 'inShopAppointment': - return this.inShopAppointment; - case 'dropOffAppointment': - return this.dropOffAppointment; - case 'vehicleMake': - return 'Test Make'; //this.submittedOrder.vehicle.make; - case 'vehicleModel': - return 'Test model';//this.submittedOrder.vehicle.model; - case 'vehicleYear': - return '1000';//this.submittedOrder.vehicle.year; - case 'email': - return 'test@email.com';//this.submittedOrder.customer.emailAddress; - case 'address': - return 'a'; - case 'inShopDuration': - return this.inShopAppointmentDuration; - case 'CUSTOMER_PORTAL_URL': - return applicationConfig.CUSTOMER_PORTAL_URL; - case 'CUSTOMER_PORTAL_LOGIN_TOKEN': - return this.submittedOrder.customerPortalLoginToken; - default: - return null; - } + formatDate(date) { + // This conversion ensures we don't get get GMT induced date changes + const dateObject = convertDateStringToDate(date); + // Ex: Tuesday, April 22 + return dateObject.toLocaleDateString('en-us', { + weekday: 'long', + month: 'long', + day: 'numeric' + }); } } };