Convert rest of the mutations to typed

All mutations (vehicle, damage, service location, customer, schedule, line items, payment, referral, application user, RESET, external params, updateStateWithOrderInformation, updateExperiments, updateTriggeredSiteEntry, updateAffiliateCookies, updateHasTriggeredError) use RootState and typed payloads
This commit is contained in:
Matt Sykes 2026-03-09 16:51:55 -04:00
parent 2d9fcc0383
commit 10357cb4a6
4 changed files with 329 additions and 249 deletions

View file

@ -173,7 +173,7 @@ export function hasInsuranceInfo(order, logQueue = null) {
}
/**
* Checks whether the scheduling information is valid for the order.
* 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.

View file

@ -35,9 +35,7 @@ vueApp.config.errorHandler = (err: unknown, vm: unknown, info: string) => {
vm && typeof (vm as { getPageName?: () => string }).getPageName === "function"
? (vm as { getPageName: () => string }).getPageName()
: "Unknown";
global.$logger.logError(
`Page Name - ${pageName} - ${info}: ${error.message}\n${error.stack}`
);
global.$logger.logError(`Page Name - ${pageName} - ${info}: ${error.message}\n${error.stack}`);
};
vueApp.mount("#app");

View file

@ -3,6 +3,15 @@ import type {
RootState,
VehicleUpdatePayload,
RegistrationUpdatePayload,
ServiceZipUpdatePayload,
ServiceLocationUpdatePayload,
MobileDetailsUpdatePayload,
ScheduleUpdatePayload,
CustomerDetailsUpdatePayload,
PageDataUpdatePayload,
EventBusEventPayload,
CcTokenUpdatePayload,
FlexibleRecord,
} from "./types";
import { endpoints } from "@/constants/endpoints.js";
import { storeMutations } from "@/constants/store-mutations";
@ -280,121 +289,124 @@ export const mutations = {
updateCapabilityQuestionAnswers(state: RootState, answersArray: unknown[] | null) {
state.order.damage.capabilityQuestionAnswers = answersArray;
},
updateGlassParts(state, partsData) {
updateGlassParts(state: RootState, partsData: unknown[] | null) {
state.order.lineItems.glassParts = partsData;
},
updateVaps(state, partsData) {
updateVaps(state: RootState, partsData: unknown[] | null) {
state.order.lineItems.vaps = partsData;
},
updateSupportingItems(state, partsData) {
updateSupportingItems(state: RootState, partsData: unknown[] | null) {
state.order.lineItems.supportingItems = partsData;
},
updateLineItemsServerData(state, serverData) {
updateLineItemsServerData(state: RootState, serverData: unknown) {
state.order.lineItems.serverData = serverData;
},
updateInactivePromos(state, inactivePromos) {
updateInactivePromos(state: RootState, inactivePromos: unknown[] | null) {
state.order.payment.inactivePromos = inactivePromos;
},
updatePromos(state, promos) {
updatePromos(state: RootState, promos: unknown[] | null) {
state.order.lineItems.promos = promos;
},
updatePageData(state, pageData) {
updatePageData(state: RootState, pageData: PageDataUpdatePayload) {
state.applicationUser.pageData[pageData.page] = pageData.data;
},
updateReferralCorrelationId(state, referralCorrelationId) {
updateReferralCorrelationId(state: RootState, referralCorrelationId: string | null) {
state.order.referralCorrelationId = referralCorrelationId;
},
updateReferralNumber(state, referralNumber) {
updateReferralNumber(state: RootState, referralNumber: string | null) {
state.order.referralNumber = referralNumber;
},
updateReferralSequenceNumber(state, referralSequenceNumber) {
updateReferralSequenceNumber(state: RootState, referralSequenceNumber: string | null) {
state.order.referralSequenceNumber = referralSequenceNumber;
},
updateReferralDate(state, referralDate) {
updateReferralDate(state: RootState, referralDate: string | null) {
state.order.referralDate = referralDate;
},
updateParentAcctNumber(state, parentAcctNumber) {
updateParentAcctNumber(state: RootState, parentAcctNumber: number) {
state.order.payment.parentAccountNumber = parentAcctNumber;
},
updateBillToAcctNumber(state, billToAcctNumber) {
updateBillToAcctNumber(state: RootState, billToAcctNumber: string | null) {
state.order.payment.billToAccountNumber = billToAcctNumber;
},
updateEON(state, eon) {
updateEON(state: RootState, eon: string | null) {
state.order.eon = eon;
},
updateIsInsurance(state, isInsurance) {
state.order.payment.isInsurance = isInsurance;
},
updateIsPia(state, isPia) {
updateIsPia(state: RootState, isPia: boolean | null) {
state.order.payment.isPia = isPia;
},
updatePiaType(state, piaType) {
updatePiaType(state: RootState, piaType: string | null) {
state.order.payment.piaType = piaType;
},
updateWorkOrderNumber(state, workOrderNumber) {
updateWorkOrderNumber(state: RootState, workOrderNumber: string | null) {
state.order.workOrderNumber = workOrderNumber;
},
updateWorkOrderId(state, workOrderId) {
updateWorkOrderId(state: RootState, workOrderId: string | null) {
state.order.workOrderId = workOrderId;
},
updateCustomerPortalLoginToken(state, customerPortalLoginToken) {
updateCustomerPortalLoginToken(state: RootState, customerPortalLoginToken: string | null) {
state.order.customerPortalLoginToken = customerPortalLoginToken;
},
updateLockToken(state, lockToken) {
updateLockToken(state: RootState, lockToken: string | null) {
state.order.lockToken = lockToken;
},
updateSettledTenderAmount(state, settledTenderAmount) {
updateSettledTenderAmount(state: RootState, settledTenderAmount: number) {
state.order.settledTenderAmount = settledTenderAmount;
},
updateIsRecalAckOptIn(state, isRecalAckOptIn) {
updateIsRecalAckOptIn(state: RootState, isRecalAckOptIn: boolean) {
state.order.isRecalAckOptIn = isRecalAckOptIn;
},
updateIsRecalAcknowledgedForScheduling(state, isRecalAcknowledgedForScheduling) {
updateIsRecalAcknowledgedForScheduling(
state: RootState,
isRecalAcknowledgedForScheduling: string
) {
state.order.isRecalAcknowledgedForScheduling = isRecalAcknowledgedForScheduling;
},
updateIsOemGlassSelected(state: RootState, isOemGlassSelected: boolean | null) {
state.order.damage.installOemGlass = isOemGlassSelected;
},
updateIsMSRFeeApplicable(state, isMSRFeeApplicable) {
updateIsMSRFeeApplicable(state: RootState, isMSRFeeApplicable: boolean) {
state.order.isMSRFeeApplicable = isMSRFeeApplicable;
},
updateCashPriceSubTotal(state, cashPriceSubTotal) {
updateCashPriceSubTotal(state: RootState, cashPriceSubTotal: string | number) {
state.order.cashPriceSubTotal =
cashPriceSubTotal === "" ? null : cashPriceSubTotal.toString();
},
updateCCToken(state, ccToken) {
state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId;
state.order.payment.ccToken.expMonth = ccToken.expMonth;
state.order.payment.ccToken.expYear = ccToken.expYear;
state.order.payment.ccToken.cardType = ccToken.cardType;
state.order.payment.ccToken.billToPostalCode = ccToken.billToPostalCode;
state.order.payment.ccToken.billToFirstName = ccToken.billToFirstName;
state.order.payment.ccToken.billToLastName = ccToken.billToLastName;
state.order.payment.ccToken.referenceNumber = ccToken.referenceNumber;
state.order.payment.ccToken.authCode = ccToken.authCode;
state.order.payment.ccToken.transactionId = ccToken.transactionId;
state.order.payment.ccToken.transReferenceNumber = ccToken.transReferenceNumber;
state.order.payment.ccToken.lastFour = ccToken.lastFour;
updateCCToken(state: RootState, ccToken: CcTokenUpdatePayload) {
state.order.payment.ccToken.subscriptionId = ccToken.subscriptionId ?? null;
state.order.payment.ccToken.expMonth = ccToken.expMonth ?? null;
state.order.payment.ccToken.expYear = ccToken.expYear ?? null;
state.order.payment.ccToken.cardType = ccToken.cardType ?? null;
state.order.payment.ccToken.billToPostalCode = ccToken.billToPostalCode ?? null;
state.order.payment.ccToken.billToFirstName = ccToken.billToFirstName ?? null;
state.order.payment.ccToken.billToLastName = ccToken.billToLastName ?? null;
state.order.payment.ccToken.referenceNumber = ccToken.referenceNumber ?? null;
state.order.payment.ccToken.authCode = ccToken.authCode ?? null;
state.order.payment.ccToken.transactionId = ccToken.transactionId ?? null;
state.order.payment.ccToken.transReferenceNumber = ccToken.transReferenceNumber ?? null;
state.order.payment.ccToken.lastFour = ccToken.lastFour ?? null;
},
updatePaypalToken(state, ppToken) {
updatePaypalToken(state: RootState, ppToken: string | null) {
state.order.payment.paypalToken = ppToken;
},
updateNextGenSettledAmount(state, nextGenSettledAmount) {
updateNextGenSettledAmount(state: RootState, nextGenSettledAmount: number) {
state.order.payment.nextGenSettledAmount = nextGenSettledAmount;
},
updateInsuranceVerifiedStatus(state, isVerified) {
updateInsuranceVerifiedStatus(state: RootState, isVerified: boolean | null) {
state.order.payment.insuranceCoverage.isVerified = isVerified;
},
updateCustomerEmailAddress(state, customerEmailAddress) {
updateCustomerEmailAddress(state: RootState, customerEmailAddress: string | null) {
state.order.customer.emailAddress = customerEmailAddress;
},
updateCustomerPhoneNumber(state, phoneNumber) {
updateCustomerPhoneNumber(state: RootState, phoneNumber: string | null) {
state.order.customer.phoneNumber = phoneNumber;
},
updateCustomerIsSmsOptin(state, isSmsOptIn) {
updateCustomerIsSmsOptin(state: RootState, isSmsOptIn: boolean | null) {
state.order.customer.isSmsOptIn = isSmsOptIn;
},
updateCustomerWaitListRequested(state, waitListRequested) {
updateCustomerWaitListRequested(state: RootState, waitListRequested: boolean | null) {
state.order.customer.waitListRequested = waitListRequested;
},
updateVehicle(state: RootState, vehicleInfo: VehicleUpdatePayload) {
@ -411,88 +423,88 @@ export const mutations = {
state.order.vehicle.imageColor = vehicleInfo.imageVifColor ?? null;
},
updateRegistration(state: RootState, registrationInfo: RegistrationUpdatePayload) {
state.order.vehicle.registration.licensePlate =
registrationInfo?.licensePlate ?? null;
state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate ?? null;
},
updateServiceZip(state, serviceZipInfo) {
state.order.serviceLocation.state = serviceZipInfo.state;
state.order.serviceLocation.zipCode = serviceZipInfo.zipCode;
state.order.serviceLocation.zipCodeCtu = serviceZipInfo.zipCodeCtu;
updateServiceZip(state: RootState, serviceZipInfo: ServiceZipUpdatePayload) {
state.order.serviceLocation.state = serviceZipInfo.state ?? null;
state.order.serviceLocation.zipCode = serviceZipInfo.zipCode ?? null;
state.order.serviceLocation.zipCodeCtu = serviceZipInfo.zipCodeCtu ?? null;
},
updateServiceLocation(state, serviceLocationInfo) {
state.order.serviceLocation.address = serviceLocationInfo.address;
state.order.serviceLocation.address2 = serviceLocationInfo.address2;
state.order.serviceLocation.city = serviceLocationInfo.city;
state.order.serviceLocation.state = serviceLocationInfo.state;
state.order.serviceLocation.zipCode = serviceLocationInfo.zipCode;
state.order.serviceLocation.zipCodeCtu = serviceLocationInfo.zipCodeCtu;
state.order.serviceLocation.appointmentType = serviceLocationInfo.appointmentType;
state.order.serviceLocation.isVehicleProtected = serviceLocationInfo.isVehicleProtected;
updateServiceLocation(state: RootState, serviceLocationInfo: ServiceLocationUpdatePayload) {
state.order.serviceLocation.address = serviceLocationInfo.address ?? null;
state.order.serviceLocation.address2 = serviceLocationInfo.address2 ?? null;
state.order.serviceLocation.city = serviceLocationInfo.city ?? null;
state.order.serviceLocation.state = serviceLocationInfo.state ?? null;
state.order.serviceLocation.zipCode = serviceLocationInfo.zipCode ?? null;
state.order.serviceLocation.zipCodeCtu = serviceLocationInfo.zipCodeCtu ?? null;
state.order.serviceLocation.appointmentType = serviceLocationInfo.appointmentType ?? null;
state.order.serviceLocation.isVehicleProtected =
serviceLocationInfo.isVehicleProtected ?? null;
state.order.serviceLocation.provider = {
providerNumber: serviceLocationInfo.provider?.providerNumber,
providerNumber: serviceLocationInfo.provider?.providerNumber ?? null,
address: {
streetAddress: serviceLocationInfo.provider?.address?.streetAddress,
city: serviceLocationInfo.provider?.address?.city,
state: serviceLocationInfo.provider?.address?.state,
zipCode: serviceLocationInfo.provider?.address?.zipCode,
zipCodeCtu: serviceLocationInfo.provider?.address?.zipCodeCtu,
streetAddress: serviceLocationInfo.provider?.address?.streetAddress ?? null,
city: serviceLocationInfo.provider?.address?.city ?? null,
state: serviceLocationInfo.provider?.address?.state ?? null,
zipCode: serviceLocationInfo.provider?.address?.zipCode ?? null,
zipCodeCtu: serviceLocationInfo.provider?.address?.zipCodeCtu ?? null,
},
};
},
updateMobileDetails(state, mobileDetails) {
state.order.serviceLocation.address = mobileDetails.address;
state.order.serviceLocation.address2 = mobileDetails.address2;
state.order.serviceLocation.city = mobileDetails.city;
state.order.serviceLocation.isVehicleProtected = mobileDetails.isVehicleProtected;
updateMobileDetails(state: RootState, mobileDetails: MobileDetailsUpdatePayload) {
state.order.serviceLocation.address = mobileDetails.address ?? null;
state.order.serviceLocation.address2 = mobileDetails.address2 ?? null;
state.order.serviceLocation.city = mobileDetails.city ?? null;
state.order.serviceLocation.isVehicleProtected = mobileDetails.isVehicleProtected ?? null;
},
updateServiceLocationTechNotes(state, techNotes) {
updateServiceLocationTechNotes(state: RootState, techNotes: string | null) {
state.order.serviceLocation.techNotes = techNotes;
},
updateSchedule(state, scheduleInfo) {
updateSchedule(state: RootState, scheduleInfo: ScheduleUpdatePayload | null) {
if (scheduleInfo) {
state.order.schedule.date = scheduleInfo.date;
state.order.schedule.startTime = scheduleInfo.startTime;
state.order.schedule.endTime = scheduleInfo.endTime;
state.order.schedule.routeCode = scheduleInfo.routeCode;
state.order.schedule.jobMaxMinutes = scheduleInfo.jobMaxMinutes;
state.order.schedule.jobMinMinutes = scheduleInfo.jobMinMinutes;
state.order.schedule.date = scheduleInfo.date ?? null;
state.order.schedule.startTime = scheduleInfo.startTime ?? null;
state.order.schedule.endTime = scheduleInfo.endTime ?? null;
state.order.schedule.routeCode = scheduleInfo.routeCode ?? null;
state.order.schedule.jobMaxMinutes = scheduleInfo.jobMaxMinutes ?? null;
state.order.schedule.jobMinMinutes = scheduleInfo.jobMinMinutes ?? null;
}
},
updateCustomerDetails(state, customerDetails) {
updateCustomerDetails(state: RootState, customerDetails: CustomerDetailsUpdatePayload | null) {
if (customerDetails) {
state.order.customer.firstName = customerDetails.firstName;
state.order.customer.lastName = customerDetails.lastName;
state.order.customer.emailAddress = customerDetails.emailAddress;
state.order.customer.phoneNumber = customerDetails.phoneNumber;
state.order.customer.isSmsOptIn = customerDetails.isSmsOptIn;
state.order.customer.firstName = customerDetails.firstName ?? null;
state.order.customer.lastName = customerDetails.lastName ?? null;
state.order.customer.emailAddress = customerDetails.emailAddress ?? null;
state.order.customer.phoneNumber = customerDetails.phoneNumber ?? null;
state.order.customer.isSmsOptIn = customerDetails.isSmsOptIn ?? null;
}
},
// applicationUser MUTATIONS
updateSaveSessionPromise(state, saveSessionPromise) {
updateSaveSessionPromise(state: RootState, saveSessionPromise: Promise<unknown> | null) {
state.applicationUser.saveSessionPromise = saveSessionPromise;
},
updateSavedSessionId(state, savedSessionId) {
updateSavedSessionId(state: RootState, savedSessionId: string | null) {
state.applicationUser.savedSessionId = savedSessionId;
},
updateCrmCustomerId(state, crmCustomerId) {
updateCrmCustomerId(state: RootState, crmCustomerId: string | null) {
state.applicationUser.crmCustomerId = crmCustomerId;
},
updateLastPageVisited(state, lastPageVisited) {
updateLastPageVisited(state: RootState, lastPageVisited: string | null) {
state.applicationUser.lastPageVisited = lastPageVisited;
},
updateLoggingOption(state, loggingOption) {
updateLoggingOption(state: RootState, loggingOption: boolean) {
state.applicationUser.loggingOption = loggingOption;
},
// EVENT BUS MUTATIONS
addEventToBus(state, event) {
addEventToBus(state: RootState, event: EventBusEventPayload) {
state.applicationUser.eventBus.push(event);
},
removeEventFromBus(state, eventData) {
removeEventFromBus(state: RootState, eventData: EventBusEventPayload) {
const matchedEvent = state.applicationUser.eventBus.find(
({ category, subCategory }) =>
category === eventData.category && subCategory === eventData.subCategory
(e: EventBusEventPayload) =>
e.category === eventData.category && e.subCategory === eventData.subCategory
);
const itemIndex = state.applicationUser.eventBus.indexOf(matchedEvent);
@ -502,68 +514,68 @@ export const mutations = {
}
},
//ExternalParameter MUTATIONS
updateIsExternalParameter(state, isExternalParameter) {
updateIsExternalParameter(state: RootState, isExternalParameter: string) {
externalParameterState.isExternalParameter = isExternalParameter;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterYear(state, year) {
updateExternalParameterYear(state: RootState, year: string | null) {
externalParameterState.vehicle.year = year;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterMake(state, make) {
updateExternalParameterMake(state: RootState, make: string | null) {
externalParameterState.vehicle.make = make;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterModel(state, model) {
updateExternalParameterModel(state: RootState, model: string | null) {
externalParameterState.vehicle.model = model;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterStyle(state, style) {
updateExternalParameterStyle(state: RootState, style: string | null) {
externalParameterState.vehicle.style = style;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterQsStash(state, qsStash) {
updateExternalParameterQsStash(state: RootState, qsStash: unknown) {
externalParameterState.qsStash = qsStash;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterIsRepair(state, isRepair) {
updateExternalParameterIsRepair(state: RootState, isRepair: boolean | null) {
externalParameterState.vehicleDamage.isRepair = isRepair;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterNumberOfChips(state, numberOfChips) {
updateExternalParameterNumberOfChips(state: RootState, numberOfChips: number | null) {
externalParameterState.vehicleDamage.numberOfChips = numberOfChips;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterDamageType(state, damageType) {
updateExternalParameterDamageType(state: RootState, damageType: string | null) {
externalParameterState.vehicleDamage.damageType = damageType;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterZipCode(state, zipCode) {
updateExternalParameterZipCode(state: RootState, zipCode: string | null) {
externalParameterState.serviceZip.zipCode = zipCode;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterEmailAddress(state, emailAddress) {
updateExternalParameterEmailAddress(state: RootState, emailAddress: string | null) {
externalParameterState.customer.emailAddress = emailAddress;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterIsInsurance(state, isInsurance) {
updateExternalParameterIsInsurance(state: RootState, isInsurance: boolean | null) {
externalParameterState.quote.isInsurance = isInsurance;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterVinSelection(state, vinSelection) {
updateExternalParameterVinSelection(state: RootState, vinSelection: string | null) {
externalParameterState.estimate.vinSelection = vinSelection;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterServicePackage(state, servicePackage) {
updateExternalParameterServicePackage(state: RootState, servicePackage: string | null) {
externalParameterState.quote.servicePackage = servicePackage;
saveExternalParameterState(externalParameterState);
},
updateExternalParameterPhoneNumber(state, phoneNumber) {
updateExternalParameterPhoneNumber(state: RootState, phoneNumber: string | null) {
externalParameterState.customer.phoneNumber = phoneNumber;
saveExternalParameterState(externalParameterState);
},
//RESET ExternalParameter MUTATIONS
resetExternalParameterVehicleState(state) {
resetExternalParameterVehicleState(state: RootState) {
externalParameterState.vehicle.year = null;
externalParameterState.vehicle.make = null;
externalParameterState.vehicle.model = null;
@ -571,38 +583,38 @@ export const mutations = {
saveExternalParameterState(externalParameterState);
},
resetExternalParameterDamageState(state) {
resetExternalParameterDamageState(state: RootState) {
externalParameterState.vehicleDamage.isRepair = null;
externalParameterState.vehicleDamage.numberOfChips = null;
externalParameterState.vehicleDamage.damageType = null;
saveExternalParameterState(externalParameterState);
},
resetExternalParameterEstimateState(state) {
resetExternalParameterEstimateState(state: RootState) {
externalParameterState.estimate.vinSelection = null;
saveExternalParameterState(externalParameterState);
},
resetExternalParameterServiceZipState(state) {
resetExternalParameterServiceZipState(state: RootState) {
externalParameterState.serviceZip.zipCode = null;
saveExternalParameterState(externalParameterState);
},
resetExternalParameterQuoteState(state) {
resetExternalParameterQuoteState(state: RootState) {
externalParameterState.quote.servicePackage = null;
externalParameterState.quote.isInsurance = null;
saveExternalParameterState(externalParameterState);
},
resetIsExternalParameter(state) {
resetIsExternalParameter(state: RootState) {
externalParameterState.isExternalParameter = externalParameterStatus.INACTIVE;
saveExternalParameterState(externalParameterState);
},
resetExternalParameterCustomerState(state) {
resetExternalParameterCustomerState(state: RootState) {
externalParameterState.customer.emailAddress = null;
externalParameterState.customer.phoneNumber = null;
saveExternalParameterState(externalParameterState);
},
// RESET DEPENDENCY MUTATIONS
resetVehicleState(state) {
resetVehicleState(state: RootState) {
state.order.vehicle.year = null;
state.order.vehicle.make = null;
state.order.vehicle.model = null;
@ -614,15 +626,15 @@ export const mutations = {
state.order.vehicle.imageVifNumber = null;
state.order.vehicle.imageColor = null;
},
resetDamageState(state) {
resetDamageState(state: RootState) {
state.order.damage.isRepair = null;
state.order.damage.numberOfChips = null;
state.order.damage.glassToReplace = null;
},
resetRegistrationState(state) {
resetRegistrationState(state: RootState) {
state.order.vehicle.registration.licensePlate = null;
},
resetGlassPartsState(state) {
resetGlassPartsState(state: RootState) {
state.order.lineItems.glassParts = null;
state.order.damage.partQuestionAnswers = null;
state.order.damage.moldingQuestionAnswers = null;
@ -632,7 +644,7 @@ export const mutations = {
state.applicationUser.pageData[routeData.MOLDING_QUESTIONS.name] = null;
state.applicationUser.pageData[routeData.CAPABILITY_QUESTIONS.name] = null;
},
resetSchedule(state) {
resetSchedule(state: RootState) {
state.order.schedule.date = null;
state.order.schedule.startTime = null;
state.order.schedule.endTime = null;
@ -643,7 +655,7 @@ export const mutations = {
//premium appointment fee used on schedule page also needs reset when schedule is reset
const supportingItems = state.order.lineItems.supportingItems;
const premiumAppointmentFeeIndex = supportingItems?.findIndex(
(item) => item.partType == PREMIUM_FEE_PART_TYPE
(item: { partType?: string }) => item.partType == PREMIUM_FEE_PART_TYPE
);
if (premiumAppointmentFeeIndex >= 0) {
@ -651,16 +663,16 @@ export const mutations = {
state.order.lineItems.supportingItems = supportingItems;
}
},
resetState(state) {
resetState(state: RootState) {
Object.assign(state, getDefaultState());
},
resetSaveSessionPromise(state) {
resetSaveSessionPromise(state: RootState) {
state.applicationUser.saveSessionPromise = null;
},
resetServiceLocationAppointmentType(state) {
resetServiceLocationAppointmentType(state: RootState) {
state.order.serviceLocation.appointmentType = null;
},
resetServiceLocationProvider(state) {
resetServiceLocationProvider(state: RootState) {
state.order.serviceLocation.provider = {
providerNumber: null,
address: {
@ -672,37 +684,40 @@ export const mutations = {
},
};
},
resetServiceLocationMobileAddress(state) {
resetServiceLocationMobileAddress(state: RootState) {
state.order.serviceLocation.address = null;
state.order.serviceLocation.address2 = null;
state.order.serviceLocation.city = null;
state.order.serviceLocation.state = null;
state.order.serviceLocation.isVehicleProtected = null;
},
resetPaymentMethodChoice(state) {
resetPaymentMethodChoice(state: RootState) {
state.order.payment.isPia = null;
state.order.payment.piaType = null;
},
// Misc Mutations
updateStateWithOrderInformation(state, sessionInformation) {
state.order.referralNumber = sessionInformation.order.referralNumber;
state.order.referralSequenceNumber = sessionInformation.order.referralSequenceNumber;
state.order.referralDate = sessionInformation.order.referralDate;
state.order.referralCorrelationId = sessionInformation.order.referralCorrelationId;
state.order.eon = sessionInformation.order.eon;
state.order.customerPortalLoginToken = sessionInformation.order.CustomerPortalLoginToken;
state.order.isRecalAckOptIn = sessionInformation.order.isRecalAckOptIn;
state.order.workOrderId = sessionInformation.order.workOrderId
? sessionInformation.order.workOrderId
: null;
state.order.workOrderNumber = sessionInformation.order.workOrderNumber
? sessionInformation.order.workOrderNumber
: null;
state.order.lockToken = sessionInformation.order.lockToken
? sessionInformation.order.lockToken
: null;
updateStateWithOrderInformation(
state: RootState,
sessionInformation: {
order?: Record<string, unknown>;
applicationUser?: Record<string, unknown>;
}
) {
// Session API has dynamic structure - FlexibleRecord allows nested access
const order = (sessionInformation?.order ?? {}) as FlexibleRecord;
const applicationUser = (sessionInformation?.applicationUser ?? {}) as FlexibleRecord;
state.order.referralNumber = order.referralNumber as string | null;
state.order.referralSequenceNumber = order.referralSequenceNumber as string | null;
state.order.referralDate = order.referralDate as string | null;
state.order.referralCorrelationId = order.referralCorrelationId;
state.order.eon = order.eon;
state.order.customerPortalLoginToken = order.CustomerPortalLoginToken;
state.order.isRecalAckOptIn = order.isRecalAckOptIn;
state.order.workOrderId = order.workOrderId ? order.workOrderId : null;
state.order.workOrderNumber = order.workOrderNumber ? order.workOrderNumber : null;
state.order.lockToken = order.lockToken ? order.lockToken : null;
if (state.order.vehicle.vin !== sessionInformation.order.vehicle?.vin) {
if (state.order.vehicle.vin !== order.vehicle?.vin) {
state.applicationUser.pageData[routeData.PART_QUESTIONS.name] = null;
state.applicationUser.pageData[routeData.VEHICLE_PARTS.name] = null;
state.applicationUser.pageData[routeData.MOLDING_QUESTIONS.name] = null;
@ -710,162 +725,146 @@ export const mutations = {
}
state.order.vehicle = Object.assign(state.order.vehicle, {
year: sessionInformation.order.vehicle?.year,
make: sessionInformation.order.vehicle?.make,
model: sessionInformation.order.vehicle?.model,
style: sessionInformation.order.vehicle?.style,
vin: sessionInformation.order.vehicle?.vin,
carId: sessionInformation.order.vehicle?.carId,
category: sessionInformation.order.vehicle?.category,
imageUrl: sessionInformation.order.vehicle?.imageUrl,
imageVifNumber: sessionInformation.order.vehicle?.imageVifNumber,
imageColor: sessionInformation.order.vehicle?.imageVifColor,
vehicleSubType: sessionInformation.order.vehicle?.vehicleSubType,
vehicleSpecialClass: sessionInformation.order.vehicle?.vehicleSpecialClass,
isBigTruck: sessionInformation.order.vehicle?.isBigTruck,
canSafeliteService: sessionInformation.order.vehicle?.canSafeliteService,
year: order.vehicle?.year,
make: order.vehicle?.make,
model: order.vehicle?.model,
style: order.vehicle?.style,
vin: order.vehicle?.vin,
carId: order.vehicle?.carId,
category: order.vehicle?.category,
imageUrl: order.vehicle?.imageUrl,
imageVifNumber: order.vehicle?.imageVifNumber,
imageColor: order.vehicle?.imageVifColor,
vehicleSubType: order.vehicle?.vehicleSubType,
vehicleSpecialClass: order.vehicle?.vehicleSpecialClass,
isBigTruck: order.vehicle?.isBigTruck,
canSafeliteService: order.vehicle?.canSafeliteService,
});
state.order.damage.glassToReplace = sessionInformation.order.damage.glassToReplace;
state.order.damage.isRepair = sessionInformation.order.damage.isRepair;
state.order.damage.numberOfChips = sessionInformation.order.damage.numberOfChips;
state.order.damage.dateOfLoss = sessionInformation.order.damage?.dateOfLoss;
state.order.damage.damageCause = sessionInformation.order.damage?.damageCause;
state.order.damage.glassToReplace = order.damage.glassToReplace;
state.order.damage.isRepair = order.damage.isRepair;
state.order.damage.numberOfChips = order.damage.numberOfChips;
state.order.damage.dateOfLoss = order.damage?.dateOfLoss;
state.order.damage.damageCause = order.damage?.damageCause;
state.order.damage.partQuestionAnswers =
sessionInformation.order.damage.partQuestionAnswers;
state.order.damage.moldingQuestionAnswers =
sessionInformation.order.damage.moldingQuestionAnswers;
state.order.damage.capabilityQuestionAnswers =
sessionInformation.order.damage.capabilityQuestionAnswers;
state.order.damage.partQuestionAnswers = order.damage.partQuestionAnswers;
state.order.damage.moldingQuestionAnswers = order.damage.moldingQuestionAnswers;
state.order.damage.capabilityQuestionAnswers = order.damage.capabilityQuestionAnswers;
state.order.damage.installOemGlass = sessionInformation.order.damage.installOemGlass;
state.order.damage.installOemGlass = order.damage.installOemGlass;
state.order.lineItems.glassParts = sessionInformation.order.lineItems.glassParts;
state.order.lineItems.supportingItems = sessionInformation.order.lineItems.supportingItems;
state.order.lineItems.vaps = sessionInformation.order.lineItems.vaps ?? [];
state.order.lineItems.promos = sessionInformation.order.lineItems.promos;
state.order.lineItems.serverData = sessionInformation.order.lineItems.serverData;
state.order.lineItems.glassParts = order.lineItems.glassParts;
state.order.lineItems.supportingItems = order.lineItems.supportingItems;
state.order.lineItems.vaps = order.lineItems.vaps ?? [];
state.order.lineItems.promos = order.lineItems.promos;
state.order.lineItems.serverData = order.lineItems.serverData;
state.order.payment.parentAccountNumber =
sessionInformation.order.payment.parentAccountNumber;
state.order.payment.billToAccountNumber =
sessionInformation.order.payment.billToAccountNumber;
state.order.payment.inactivePromos = sessionInformation.order.payment.inactivePromos;
state.order.payment.parentAccountNumber = order.payment.parentAccountNumber;
state.order.payment.billToAccountNumber = order.payment.billToAccountNumber;
state.order.payment.inactivePromos = order.payment.inactivePromos;
//Do not assign default service type once user make service type selection
if (state.order.serviceLocation.appointmentType == null) {
state.order.serviceLocation.address =
sessionInformation.order.serviceLocation.streetAddress;
state.order.serviceLocation.address2 =
sessionInformation.order.serviceLocation.streetAddress2;
state.order.serviceLocation.city = sessionInformation.order.serviceLocation.city;
state.order.serviceLocation.state = sessionInformation.order.serviceLocation.state;
state.order.serviceLocation.zipCode = sessionInformation.order.serviceLocation.zipCode;
state.order.serviceLocation.zipCodeCtu =
sessionInformation.order.serviceLocation.zipCodeCtu;
state.order.serviceLocation.address = order.serviceLocation.streetAddress;
state.order.serviceLocation.address2 = order.serviceLocation.streetAddress2;
state.order.serviceLocation.city = order.serviceLocation.city;
state.order.serviceLocation.state = order.serviceLocation.state;
state.order.serviceLocation.zipCode = order.serviceLocation.zipCode;
state.order.serviceLocation.zipCodeCtu = order.serviceLocation.zipCodeCtu;
state.order.serviceLocation.appointmentType =
sessionInformation.order.serviceLocation.appointmentType;
state.order.serviceLocation.appointmentType = order.serviceLocation.appointmentType;
state.order.serviceLocation.isVehicleProtected =
sessionInformation.order.serviceLocation.isVehicleProtected;
order.serviceLocation.isVehicleProtected;
state.order.serviceLocation.provider.providerNumber =
sessionInformation.order.serviceLocation.provider?.providerNumber;
order.serviceLocation.provider?.providerNumber;
state.order.serviceLocation.provider.address.streetAddress =
sessionInformation.order.serviceLocation.provider?.address?.streetAddress;
order.serviceLocation.provider?.address?.streetAddress;
state.order.serviceLocation.provider.address.city =
sessionInformation.order.serviceLocation.provider?.address?.city;
order.serviceLocation.provider?.address?.city;
state.order.serviceLocation.provider.address.state =
sessionInformation.order.serviceLocation.provider?.address?.state;
order.serviceLocation.provider?.address?.state;
state.order.serviceLocation.provider.address.zipCode =
sessionInformation.order.serviceLocation.provider?.address?.zipCode;
order.serviceLocation.provider?.address?.zipCode;
state.order.serviceLocation.provider.address.zipCodeCtu =
sessionInformation.order.serviceLocation.provider?.address?.zipCodeCtu;
state.order.serviceLocation.techNotes =
sessionInformation.order.serviceLocation.techNotes;
order.serviceLocation.provider?.address?.zipCodeCtu;
state.order.serviceLocation.techNotes = order.serviceLocation.techNotes;
}
// if we're loading a session and we do not have a provider number yet, then set isInsurance to null so that
// a service package is not selected by default on the quote page.
if (
(sessionInformation.order.payment.isInsurance === null ||
sessionInformation.order.payment.isInsurance === undefined) &&
!sessionInformation.order.serviceLocation.provider?.providerNumber
(order.payment.isInsurance === null || order.payment.isInsurance === undefined) &&
!order.serviceLocation.provider?.providerNumber
) {
state.order.payment.isInsurance = null;
} else {
state.order.payment.isInsurance = sessionInformation.order.payment.isInsurance;
state.order.payment.isInsurance = order.payment.isInsurance;
}
state.order.payment.insuranceCoverage.isVerified =
coverageStatusValue(sessionInformation?.order.insuranceCoverage.coverageStatus) ===
coverageStatus.VERIFIED
coverageStatusValue(order.insuranceCoverage.coverageStatus) === coverageStatus.VERIFIED
? true
: false;
state.order.payment.insuranceCoverage.coverageStatus = coverageStatusValue(
sessionInformation?.order.insuranceCoverage.coverageStatus
order.insuranceCoverage.coverageStatus
);
state.order.payment.insuranceCoverage.coverageSubStatus =
sessionInformation?.order.insuranceCoverage.coverageSubStatus;
order.insuranceCoverage.coverageSubStatus;
state.order.payment.insuranceCoverage.coverageType = coverageTypeValue(
sessionInformation?.order.insuranceCoverage.coverageType
order.insuranceCoverage.coverageType
);
state.order.payment.insuranceCoverage.coverageVerificationType =
sessionInformation?.order.insuranceCoverage.coverageVerificationType;
order.insuranceCoverage.coverageVerificationType;
state.order.customer.emailAddress = sessionInformation.order.customer.emailAddress;
state.order.customer.firstName = sessionInformation.order.customer.firstName;
state.order.customer.lastName = sessionInformation.order.customer.lastName;
state.order.customer.phoneNumber = sessionInformation.order.customer.homePhone;
state.order.customer.isSmsOptIn = sessionInformation.order.customer.isSmsOptIn;
state.order.customer.emailAddress = order.customer.emailAddress;
state.order.customer.firstName = order.customer.firstName;
state.order.customer.lastName = order.customer.lastName;
state.order.customer.phoneNumber = order.customer.homePhone;
state.order.customer.isSmsOptIn = order.customer.isSmsOptIn;
state.applicationUser.experiments = sessionInformation.applicationUser.experiments;
state.applicationUser.crmCustomerId = sessionInformation.applicationUser.crmCustomerId;
state.applicationUser.pageData = sessionInformation.applicationUser.pageData;
state.applicationUser.lastPage = sessionInformation.applicationUser.lastPage;
state.applicationUser.experiments = applicationUser.experiments;
state.applicationUser.crmCustomerId = applicationUser.crmCustomerId;
state.applicationUser.pageData = applicationUser.pageData;
state.applicationUser.lastPageVisited = applicationUser.lastPage as string | null;
if (sessionInformation.applicationUser.savedSessionId) {
state.applicationUser.savedSessionId =
sessionInformation.applicationUser.savedSessionId;
if (applicationUser.savedSessionId) {
state.applicationUser.savedSessionId = applicationUser.savedSessionId;
}
//Do not assign default schedule details once user make schedule selection
if (state.order.schedule.date == null) {
state.order.schedule.date = sessionInformation.order.schedule?.date;
state.order.schedule.startTime = sessionInformation.order.schedule?.startTime;
state.order.schedule.endTime = sessionInformation.order.schedule?.endTime;
state.order.schedule.routeCode = sessionInformation.order.schedule?.routeCode;
state.order.schedule.jobMaxMinutes = sessionInformation.order.schedule?.jobMaxMinutes;
state.order.schedule.jobMinMinutes = sessionInformation.order.schedule?.jobMinMinutes;
state.order.schedule.date = order.schedule?.date;
state.order.schedule.startTime = order.schedule?.startTime;
state.order.schedule.endTime = order.schedule?.endTime;
state.order.schedule.routeCode = order.schedule?.routeCode;
state.order.schedule.jobMaxMinutes = order.schedule?.jobMaxMinutes;
state.order.schedule.jobMinMinutes = order.schedule?.jobMinMinutes;
}
state.order.policy.currentDeductible = sessionInformation.order.policy?.currentDeductible;
state.order.policy.originalDeductible = sessionInformation.order.policy?.originalDeductible;
state.order.policy.additionalAuthFlag = sessionInformation.order.policy?.additionalAuthFlag;
state.order.policy.currentDeductible = order.policy?.currentDeductible;
state.order.policy.originalDeductible = order.policy?.originalDeductible;
state.order.policy.additionalAuthFlag = order.policy?.additionalAuthFlag;
state.order.policy.isItac =
coverageTypeValue(sessionInformation?.order.insuranceCoverage.coverageType) ===
coverageType.ITAC
coverageTypeValue(order.insuranceCoverage.coverageType) === coverageType.ITAC
? true
: false;
state.order.policy.policyNumber = sessionInformation.order.policy?.policyNumber;
state.order.policy.insuranceCompanyName =
sessionInformation.order.policy?.insuranceCompanyName;
state.order.policy.policyNumber = order.policy?.policyNumber;
state.order.policy.insuranceCompanyName = order.policy?.insuranceCompanyName;
state.order.policy.isNoComp =
coverageTypeValue(sessionInformation?.order.insuranceCoverage.coverageType) ===
coverageType.NOCOMP
coverageTypeValue(order.insuranceCoverage.coverageType) === coverageType.NOCOMP
? true
: false;
sessionInformation.order.policy?.noComprehensive;
order.policy?.noComprehensive;
},
updateExperiments(state, experiments) {
updateExperiments(state: RootState, experiments: unknown[]) {
state.applicationUser.experiments = experiments;
},
updateTriggeredSiteEntry(state, wasSiteEntryTriggered) {
updateTriggeredSiteEntry(state: RootState, wasSiteEntryTriggered: boolean) {
state.applicationUser.triggeredSiteEntry = wasSiteEntryTriggered;
},
updateAffiliateCookies(state, affiliateCookies) {
updateAffiliateCookies(state: RootState, affiliateCookies: unknown[]) {
state.applicationUser.affiliateCookies = affiliateCookies;
},
updateHasTriggeredError(state, hasTriggeredError) {
updateHasTriggeredError(state: RootState, hasTriggeredError: boolean) {
state.applicationUser.hasAlreadyTriggeredError = hasTriggeredError;
},
};

View file

@ -3,6 +3,10 @@
* Mirrors the structure from getDefaultState() in store/index.ts
*/
/** Permissive type for API responses with dynamic structure - allows nested property access */
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type FlexibleRecord = { [key: string]: any };
export interface VehicleRegistration {
licensePlate: string | null;
}
@ -44,6 +48,68 @@ export interface RegistrationUpdatePayload {
licensePlate?: string | null;
}
/** Payload for updateServiceZip mutation */
export interface ServiceZipUpdatePayload {
state?: string | null;
zipCode?: string | null;
zipCodeCtu?: string | null;
}
/** Payload for updateServiceLocation mutation */
export interface ServiceLocationUpdatePayload {
address?: string | null;
address2?: string | null;
city?: string | null;
state?: string | null;
zipCode?: string | null;
zipCodeCtu?: string | null;
appointmentType?: string | null;
isVehicleProtected?: boolean | null;
provider?: {
providerNumber?: string | null;
address?: Partial<ProviderAddress>;
};
}
/** Payload for updateMobileDetails mutation */
export interface MobileDetailsUpdatePayload {
address?: string | null;
address2?: string | null;
city?: string | null;
isVehicleProtected?: boolean | null;
}
/** Payload for updateSchedule mutation */
export interface ScheduleUpdatePayload {
date?: string | null;
startTime?: string | null;
endTime?: string | null;
routeCode?: string | null;
jobMaxMinutes?: number | null;
jobMinMinutes?: number | null;
}
/** Payload for updateCustomerDetails mutation */
export interface CustomerDetailsUpdatePayload {
firstName?: string | null;
lastName?: string | null;
emailAddress?: string | null;
phoneNumber?: string | null;
isSmsOptIn?: boolean | null;
}
/** Payload for updatePageData mutation */
export interface PageDataUpdatePayload {
page: string;
data: unknown;
}
/** Payload for addEventToBus / removeEventFromBus */
export interface EventBusEventPayload {
category: string;
subCategory: string;
}
export interface ProviderAddress {
streetAddress: string | null;
city: string | null;
@ -122,6 +188,22 @@ export interface CcTokenState {
lastFour: string | null;
}
/** Payload for updateCCToken mutation */
export interface CcTokenUpdatePayload {
subscriptionId?: string | null;
expMonth?: string | null;
expYear?: string | null;
cardType?: string | null;
billToPostalCode?: string | null;
billToFirstName?: string | null;
billToLastName?: string | null;
referenceNumber?: string | null;
authCode?: string | null;
transactionId?: string | null;
transReferenceNumber?: string | null;
lastFour?: string | null;
}
export interface PaymentState {
isInsurance: boolean | null;
insuranceCoverage: InsuranceCoverageState;
@ -176,6 +258,7 @@ export interface OrderState {
isRecalAckOptIn: boolean;
isRecalAcknowledgedForScheduling: string;
isMSRFeeApplicable: boolean;
cashPriceSubTotal?: string | null;
}
export interface ApplicationUserState {