From 469818c022cce32fcd4b63a0dc6a01457e8afb8e Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Tue, 10 Oct 2023 12:29:04 -0400 Subject: [PATCH] Add prerequisite method --- src/layouts/payment-method/payment-method.vue | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index cc688ca27..5bb749726 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -105,6 +105,7 @@ import { storeActions } from "@/constants/store-actions"; import store from "@/store"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { Form } from "vee-validate"; +import { AppointmentTypeStrings } from "@/constants/schedule-constants"; export default { name: "paymentMethod", @@ -193,7 +194,58 @@ export default { }, methods: { arePagePrerequisitesValid() { - return true; + // Line Items + const lineItems = store.getters.order.lineItems; + // damageReqs handles checking for damage, even though it is also required for this section. + const packageReqs = !!(lineItems.supportingItems && lineItems.vaps); + + // Service Location + const serviceLocation = store.getters.order.serviceLocation; + const mobileReqs = !!( + serviceLocation.address && + serviceLocation.city && + serviceLocation.state && + serviceLocation.zipCode + ); + + const providerLocation = serviceLocation.provider.address; + const dropOffInshopReqs = !!( + providerLocation.streetAddress && + providerLocation.city && + providerLocation.state && + providerLocation.zipCode + ); + + const isMobile = serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE; + + const serviceLocationReqs = + (isMobile && mobileReqs) || (!isMobile && dropOffInshopReqs); + + // Insurance + const isInsuranceSet = store.getters.order.payment.isInsurance !== null; + + // Schedule + const schedule = store.getters.order.schedule; + const scheduleReqs = !!( + schedule.date && + schedule.startTime && + schedule.endTime && + schedule.jobMaxMinutes && + schedule.jobMinMinutes + ); + + // Customer + const customer = store.getters.order.customer; + const customerReqs = !!( + customer.firstName && + customer.lastName && + customer.phoneNumber && + customer.emailAddress + ); + + return ( + packageReqs && serviceLocationReqs && isInsuranceSet && scheduleReqs && customerReqs + ); }, getPaypalAlert() { return store.getters.order.payment.piaErrorCode ? true : false;