Added a few method comments and make prettier happier
This commit is contained in:
parent
3b950302ff
commit
7ae16a5610
4 changed files with 64 additions and 9 deletions
|
|
@ -3,6 +3,12 @@ import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
|||
import { coverageStatus } from "@/constants/insurance";
|
||||
import { applicationConfig } from "@/constants/application-config";
|
||||
|
||||
/**
|
||||
* Logs the start of the page prerequisites check.
|
||||
* Should be used on pages before the page prerequisites check is executed.
|
||||
* @param {string} source - The source of the page prerequisites check.
|
||||
* @param {boolean} preReqResult - The result of the page prerequisites check.
|
||||
*/
|
||||
export function logPagePrereqsStart(source, preReqResult) {
|
||||
// prettier-ignore
|
||||
{
|
||||
|
|
@ -10,6 +16,12 @@ export function logPagePrereqsStart(source, preReqResult) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs the end of the page prerequisites check.
|
||||
* Should be used on pages after the page prerequisites check is executed.
|
||||
* @param {string} source - The source of the page prerequisites check.
|
||||
* @param {boolean} preReqResult - The result of the page prerequisites check.
|
||||
*/
|
||||
export function logPagePrereqsEnd(source, preReqResult) {
|
||||
// prettier-ignore
|
||||
{
|
||||
|
|
@ -17,18 +29,34 @@ export function logPagePrereqsEnd(source, preReqResult) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Flushes the page prerequisites logs.
|
||||
* @param {string} source - The source of the page prerequisites check. This is the page name most places.
|
||||
* @param {boolean} preReqResult - The result of the page prerequisites check.
|
||||
* @param {Array} logQueue - The queue of log functions.
|
||||
*/
|
||||
export function flushPagePrereqsLogs(source, preReqResult, logQueue) {
|
||||
logPagePrereqsStart(source, preReqResult);
|
||||
logQueue.forEach((fn) => fn());
|
||||
logPagePrereqsEnd(source, preReqResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushes a log function to the log queue.
|
||||
* @param {Array} logQueue - The queue of log functions.
|
||||
* @param {Function} logFn - The log function to be executed.
|
||||
*/
|
||||
function queueLogging(logQueue, logFn) {
|
||||
if (logQueue) {
|
||||
logQueue.push(logFn);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the service zip code information is valid for the order.
|
||||
* Should be used on pages after service zip code collection is complete.
|
||||
* Returns true if the zip code and zip code CTU are present on serviceLocation.
|
||||
*/
|
||||
export function hasServiceZipInfo(order, logQueue = null) {
|
||||
const serviceLocation = order.serviceLocation;
|
||||
const result = !!(serviceLocation.zipCode && serviceLocation.zipCodeCtu);
|
||||
|
|
@ -46,6 +74,12 @@ export function hasServiceZipInfo(order, logQueue = null) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the service location information is valid for the appointment.
|
||||
* Returns true if the required info is present for the chosen appointment type.
|
||||
* For MOBILE: address, city, state, and zipCode must be present on serviceLocation.
|
||||
* For INSHOP/DROPOFF: all provider address fields must be present.
|
||||
*/
|
||||
export function hasServiceLocationInfo(order, logQueue = null) {
|
||||
const serviceLocation = order.serviceLocation;
|
||||
const mobileReqs = !!(
|
||||
|
|
@ -86,6 +120,10 @@ export function hasServiceLocationInfo(order, logQueue = null) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the insurance information is valid for the order. To be used after all insurance info collection is complete.
|
||||
* Returns true if cash selected or if insurance is selected and some insurance fields are present.
|
||||
*/
|
||||
export function hasInsuranceInfo(order, logQueue = null) {
|
||||
const isInsurance = order.payment?.isInsurance;
|
||||
const insuranceCoverageStatus = order.payment?.insuranceCoverage?.coverageStatus;
|
||||
|
|
@ -134,6 +172,13 @@ export function hasInsuranceInfo(order, logQueue = null) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the scheduling information is valid for the order.
|
||||
* Should be used on pages after scheduling info collection is complete.
|
||||
* Returns true if the required info is present for the chosen appointment type.
|
||||
* For MOBILE: date, startTime, endTime, jobMaxMinutes, and jobMinMinutes must be present on schedule.
|
||||
* For INSHOP/DROPOFF: all provider scheduling fields must be present.
|
||||
*/
|
||||
export function hasSchedulingInfo(order, logQueue = null) {
|
||||
const schedule = order.schedule;
|
||||
const result = !!(
|
||||
|
|
@ -160,6 +205,11 @@ export function hasSchedulingInfo(order, logQueue = null) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the customer information is valid for the order.
|
||||
* Should be used on pages after customer info collection is complete.
|
||||
* Returns true if the firstName, lastName, phoneNumber, and emailAddress are present on customer.
|
||||
*/
|
||||
export function hasCustomerInfo(order, logQueue = null) {
|
||||
const customer = order.customer;
|
||||
const result = !!(
|
||||
|
|
@ -184,6 +234,11 @@ export function hasCustomerInfo(order, logQueue = null) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the glass parts or repair information is valid for the order.
|
||||
* Should be used on pages after glass parts or repair info collection is complete.
|
||||
* Returns true if the isRepair is true or if the glassParts array is not empty.
|
||||
*/
|
||||
export function hasGlassPartsOrRepairInfo(order, logQueue = null) {
|
||||
const isRepair = order.damage?.isRepair;
|
||||
const glassParts = order.lineItems?.glassParts;
|
||||
|
|
@ -203,6 +258,11 @@ export function hasGlassPartsOrRepairInfo(order, logQueue = null) {
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the payment method information is valid for the order.
|
||||
* Should only be used on pages after payment method info collection is complete which is only the payment collection pages.
|
||||
* Returns true if the isPia is true or if the piaType is set.
|
||||
*/
|
||||
export function hasPaymentMethodInfo(order, logQueue = null) {
|
||||
const payment = order.payment;
|
||||
const result = payment.isPia !== null && (payment.isPia || !!payment.piaType);
|
||||
|
|
|
|||
|
|
@ -37,10 +37,7 @@ describe("page-prerequisites-helper.js", () => {
|
|||
|
||||
describe("flushPagePrereqsLogs", () => {
|
||||
test("calls logPagePrereqsStart, executes logQueue, and logPagePrereqsEnd", () => {
|
||||
const logQueue = [
|
||||
jest.fn(),
|
||||
jest.fn(),
|
||||
];
|
||||
const logQueue = [jest.fn(), jest.fn()];
|
||||
|
||||
pagePrereqsHelper.flushPagePrereqsLogs("payment.vue", true, logQueue);
|
||||
|
||||
|
|
|
|||
|
|
@ -78,10 +78,7 @@ import { settleAllPromises } from "@/helpers/layout-helper";
|
|||
import { AppointmentTypeStrings } from "@/constants/schedule-constants";
|
||||
import textLink from "@/ux-components/text-link/text-link";
|
||||
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||
import {
|
||||
flushPagePrereqsLogs,
|
||||
hasSchedulingInfo,
|
||||
} from "@/helpers/page-prerequisites-helper";
|
||||
import { flushPagePrereqsLogs, hasSchedulingInfo } from "@/helpers/page-prerequisites-helper";
|
||||
export default {
|
||||
name: "MobileDetails",
|
||||
data() {
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,8 @@ export default {
|
|||
? true
|
||||
: !!supportingItemsInfo;
|
||||
|
||||
const preReqResult = serviceZip && insuranceInfo && glassPartsOrRepair && supportingItemsPreReqs;
|
||||
const preReqResult =
|
||||
serviceZip && insuranceInfo && glassPartsOrRepair && supportingItemsPreReqs;
|
||||
|
||||
logQueue.push(() => {
|
||||
debugLog(
|
||||
|
|
|
|||
Loading…
Reference in a new issue