CASH-60
CASH-60 handle scenarios where the user may be using browser navigation. try to wait for promises. reset pia indicator. also add route from customer-details for pay-now scenario. the browser back/forward seems to trigger 2 scenarios on customer-details so just sending the pay-now scenario back to payment-method page instead of causing a script error
This commit is contained in:
parent
ccc04b667b
commit
b593d921cc
5 changed files with 84 additions and 10 deletions
|
|
@ -87,6 +87,7 @@ import { required, regex } from "@/helpers/validation-rules";
|
||||||
import { Form, defineRule } from "vee-validate";
|
import { Form, defineRule } from "vee-validate";
|
||||||
import { useField, validate } from "vee-validate";
|
import { useField, validate } from "vee-validate";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
|
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
defineRule("first-name-required", required(errorMessages.FIRST_NAME_REQUIRED));
|
defineRule("first-name-required", required(errorMessages.FIRST_NAME_REQUIRED));
|
||||||
|
|
@ -162,7 +163,7 @@ export default {
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
this.dispatchStoreAction(
|
this.dispatchStoreAction(
|
||||||
this.storeActions.SAVE_CUSTOMER_DETAILS,
|
this.storeActions.SAVE_CUSTOMER_DETAILS,
|
||||||
{
|
{
|
||||||
|
|
@ -181,6 +182,17 @@ export default {
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// if the user has resorted to using browser back/forward buttons we could have promises unresolved if they clicked back before pia work order submission.
|
||||||
|
// so attempt to wait for them to finish.
|
||||||
|
if (store.getters.order.payment.isPia) {
|
||||||
|
this.dispatchStoreAction(
|
||||||
|
storeActions.SAVE_PAYMENT_METHOD_CHOICE,
|
||||||
|
paymentMethods.NONE,
|
||||||
|
false
|
||||||
|
);
|
||||||
|
await store.getters.applicationUser.saveSessionPromise;
|
||||||
|
}
|
||||||
|
|
||||||
this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route);
|
this.$router.navigateWithSaving(this.navigationScenarios.CLICKED_FORWARD, this.$route);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -483,7 +483,7 @@ export default {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
async arePagePrerequisitesValid() {
|
||||||
// Service Location
|
// Service Location
|
||||||
const serviceLocation = store.getters.order.serviceLocation;
|
const serviceLocation = store.getters.order.serviceLocation;
|
||||||
const mobileReqs = !!(
|
const mobileReqs = !!(
|
||||||
|
|
@ -532,13 +532,58 @@ export default {
|
||||||
store.getters.order.payment.isPia !== null &&
|
store.getters.order.payment.isPia !== null &&
|
||||||
(store.getters.order.payment.isPia || !!store.getters.order.payment.piaType);
|
(store.getters.order.payment.isPia || !!store.getters.order.payment.piaType);
|
||||||
|
|
||||||
return (
|
const preReqResult =
|
||||||
serviceLocationReqs &&
|
serviceLocationReqs &&
|
||||||
isInsuranceSet &&
|
isInsuranceSet &&
|
||||||
scheduleReqs &&
|
scheduleReqs &&
|
||||||
customerReqs &&
|
customerReqs &&
|
||||||
paymentMethodReqs
|
paymentMethodReqs;
|
||||||
);
|
|
||||||
|
// prettier-ignore
|
||||||
|
{
|
||||||
|
if (store.getters.applicationUser.loggingOption || !preReqResult) {
|
||||||
|
console.log("------------- payment.vue pagePrereqs start -----------------");
|
||||||
|
console.log(new Date() + "mobileReqs:" + mobileReqs);
|
||||||
|
console.log(new Date() + "serviceLocation.address:" + serviceLocation.address);
|
||||||
|
console.log(new Date() + "serviceLocation.city:" + serviceLocation.city);
|
||||||
|
console.log(new Date() + "serviceLocation.state:" + serviceLocation.state);
|
||||||
|
console.log(new Date() + "serviceLocation.zipCode:" + serviceLocation.zipCode);
|
||||||
|
console.log("");
|
||||||
|
console.log(new Date() + "dropOffInshopReqs:" + dropOffInshopReqs);
|
||||||
|
console.log(new Date() + "serviceLocationReqs:" + serviceLocationReqs);
|
||||||
|
console.log(new Date() + "providerLocation.streetAddress:" + providerLocation.streetAddress);
|
||||||
|
console.log(new Date() + "providerLocation.city:" + providerLocation.city);
|
||||||
|
console.log(new Date() + "providerLocation.state:" + providerLocation.state);
|
||||||
|
console.log(new Date() + "providerLocation.zipCode:" + providerLocation.zipCode);
|
||||||
|
console.log("");
|
||||||
|
console.log(new Date() + "isInsuranceSet:" + isInsuranceSet);
|
||||||
|
console.log("");
|
||||||
|
console.log(new Date() + "scheduleReqs:" + scheduleReqs);
|
||||||
|
console.log(new Date() + "schedule.date:" + schedule.date);
|
||||||
|
console.log(new Date() + "schedule.startTime:" + schedule.startTime);
|
||||||
|
console.log(new Date() + "schedule.endTime:" + schedule.endTime);
|
||||||
|
console.log(new Date() + "schedule.jobMaxMinutes:" + schedule.jobMaxMinutes);
|
||||||
|
console.log(new Date() + "schedule.jobMinMinutes:" + schedule.jobMinMinutes);
|
||||||
|
console.log("");
|
||||||
|
console.log(new Date() + "customerReqs:" + customerReqs);
|
||||||
|
console.log(new Date() + "customer.firstName:" + customer.firstName);
|
||||||
|
console.log(new Date() + "customer.lastName:" + customer.lastName);
|
||||||
|
console.log(new Date() + "customer.phoneNumber:" + customer.phoneNumber);
|
||||||
|
console.log(new Date() + "customer.emailAddress:" + customer.emailAddress);
|
||||||
|
console.log("");
|
||||||
|
console.log(new Date() + "paymentMethodReqs:" + paymentMethodReqs);
|
||||||
|
console.log(new Date() + "store.getters.order.payment.isPia:" + store.getters.order.payment.isPia);
|
||||||
|
console.log(new Date() + "store.getters.order.payment.piaType:" + store.getters.order.payment.piaType);
|
||||||
|
console.log("------------- payment.vue pagePrereqs end -------------------");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!preReqResult) {
|
||||||
|
await store.getters.applicationUser.saveSessionPromise;
|
||||||
|
this.backButtonAction();
|
||||||
|
}
|
||||||
|
|
||||||
|
return preReqResult;
|
||||||
},
|
},
|
||||||
getWOrkOrderNumber() {
|
getWOrkOrderNumber() {
|
||||||
if (store.getters.order.workOrderNumber) {
|
if (store.getters.order.workOrderNumber) {
|
||||||
|
|
|
||||||
|
|
@ -380,6 +380,8 @@ router.navigateWithSaving = (
|
||||||
};
|
};
|
||||||
|
|
||||||
router.navigateToExternalUrl = (url, optionalQuery = {}) => {
|
router.navigateToExternalUrl = (url, optionalQuery = {}) => {
|
||||||
|
log("------------- router navigateToExternalUrl -----------------");
|
||||||
|
log("url:", url)
|
||||||
navigateToUrl(url, optionalQuery);
|
navigateToUrl(url, optionalQuery);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -397,6 +399,13 @@ router.overrideNavigation = (
|
||||||
optionalParams = {},
|
optionalParams = {},
|
||||||
optionalPageData
|
optionalPageData
|
||||||
) => {
|
) => {
|
||||||
|
log("------------- router overrideNavigation -----------------");
|
||||||
|
log("scenario:", scenario);
|
||||||
|
log("currentRoute:", currentRoute);
|
||||||
|
log("isSavingNavigation:", isSavingNavigation);
|
||||||
|
log("optionalQuery:", optionalQuery);
|
||||||
|
log("optionalParams:", optionalParams);
|
||||||
|
log("optionalPageData:", optionalPageData);
|
||||||
navigate(
|
navigate(
|
||||||
scenario,
|
scenario,
|
||||||
currentRoute,
|
currentRoute,
|
||||||
|
|
@ -508,6 +517,9 @@ async function navigate(
|
||||||
// Get navigation map depending on the scenario and the current 'page' you're on.
|
// Get navigation map depending on the scenario and the current 'page' you're on.
|
||||||
function getNavigationMap(scenario, currentRoute) {
|
function getNavigationMap(scenario, currentRoute) {
|
||||||
const fmgPageValue = currentRoute.query.fmgPage;
|
const fmgPageValue = currentRoute.query.fmgPage;
|
||||||
|
log("------------- router index.js getNavigationMap start -----------------");
|
||||||
|
log("fmgPage: " + fmgPageValue + " scenario: " + scenario, "");
|
||||||
|
log("------------- router index.js getNavigationMap end -----------------");
|
||||||
const matchedQueryValue = routingTable(store)
|
const matchedQueryValue = routingTable(store)
|
||||||
.filter(
|
.filter(
|
||||||
(item) =>
|
(item) =>
|
||||||
|
|
@ -525,7 +537,7 @@ function log(message, data) {
|
||||||
data = data ?? "";
|
data = data ?? "";
|
||||||
const outData = typeof data === "object" ? JSON.stringify(data) : data;
|
const outData = typeof data === "object" ? JSON.stringify(data) : data;
|
||||||
|
|
||||||
if (log === "true") {
|
if (log === "true" || store.getters.applicationUser.loggingOption) {
|
||||||
console.log(new Date() + message + outData);
|
console.log(new Date() + message + outData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -470,6 +470,10 @@ const routingTable = function (store) {
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD,
|
scenario: navigationScenarios.CLICKED_FORWARD,
|
||||||
destinationFmgPageValue: fmgPageValues.PAYMENT_METHOD,
|
destinationFmgPageValue: fmgPageValues.PAYMENT_METHOD,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_PAY_NOW,
|
||||||
|
destinationFmgPageValue: fmgPageValues.PAYMENT_METHOD,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2005,8 +2005,7 @@ export const actions = {
|
||||||
order.payment.insuranceCoverage.coverageStatus?.toString(),
|
order.payment.insuranceCoverage.coverageStatus?.toString(),
|
||||||
coverageVerificationType:
|
coverageVerificationType:
|
||||||
order.payment.insuranceCoverage.coverageVerificationType,
|
order.payment.insuranceCoverage.coverageVerificationType,
|
||||||
coverageSubStatus:
|
coverageSubStatus: order.payment.insuranceCoverage.coverageSubStatus,
|
||||||
order.payment.insuranceCoverage.coverageSubStatus,
|
|
||||||
},
|
},
|
||||||
isInsurance: order.payment.isInsurance,
|
isInsurance: order.payment.isInsurance,
|
||||||
parentAccountNumber: order.payment.parentAccountNumber,
|
parentAccountNumber: order.payment.parentAccountNumber,
|
||||||
|
|
@ -2462,10 +2461,12 @@ export const actions = {
|
||||||
},
|
},
|
||||||
|
|
||||||
savePaymentMethodChoice(context, paymentMethod) {
|
savePaymentMethodChoice(context, paymentMethod) {
|
||||||
const isPia = paymentMethod !== paymentMethods.LATER;
|
var isPia = null;
|
||||||
|
if (paymentMethod !== paymentMethods.NONE) {
|
||||||
|
isPia = paymentMethod !== paymentMethods.LATER;
|
||||||
|
}
|
||||||
|
|
||||||
context.commit(storeMutations.UPDATE_IS_PIA, isPia);
|
context.commit(storeMutations.UPDATE_IS_PIA, isPia);
|
||||||
|
|
||||||
context.commit(storeMutations.UPDATE_PIA_TYPE, isPia ? paymentMethod : null);
|
context.commit(storeMutations.UPDATE_PIA_TYPE, isPia ? paymentMethod : null);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue