From df3dca74a63bf79c854b08fc2d518555f91c7acd Mon Sep 17 00:00:00 2001 From: Matt Sykes Date: Mon, 9 Mar 2026 15:26:03 -0400 Subject: [PATCH] Convert vehicle mutuations and damage mutations to typescript --- src/store/index.ts | 83 ++++++++++++++++++++++++---------------------- src/store/types.ts | 21 +++++++++++- 2 files changed, 64 insertions(+), 40 deletions(-) diff --git a/src/store/index.ts b/src/store/index.ts index 2f1ca0329..0df4679b8 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,5 +1,9 @@ import { createStore } from "vuex"; -import type { RootState } from "./types"; +import type { + RootState, + VehicleUpdatePayload, + RegistrationUpdatePayload, +} from "./types"; import { endpoints } from "@/constants/endpoints.js"; import { storeMutations } from "@/constants/store-mutations"; import { sessionStorageKeyConstants } from "@/constants/session-storage.js"; @@ -216,64 +220,64 @@ export const externalParameterState = getExternalParameterDefaultState(); // Export Mutations export const mutations = { // VEHICLE MUTATIONS - updateYear(state, year) { + updateYear(state: RootState, year: number | null) { state.order.vehicle.year = year; }, - updateMake(state, make) { + updateMake(state: RootState, make: string | null) { state.order.vehicle.make = make; }, - updateModel(state, model) { + updateModel(state: RootState, model: string | null) { state.order.vehicle.model = model; }, - updateStyle(state, style) { + updateStyle(state: RootState, style: string | null) { state.order.vehicle.style = style; }, - updateVehicleSubType(state, vehicleSubType) { + updateVehicleSubType(state: RootState, vehicleSubType: string | null) { state.order.vehicle.vehicleSubType = vehicleSubType; }, - updateVehicleSpecialClass(state, vehicleSpecialClass) { + updateVehicleSpecialClass(state: RootState, vehicleSpecialClass: string | null) { state.order.vehicle.vehicleSpecialClass = vehicleSpecialClass; }, - updateIsBigTruck(state, isBigTruck) { + updateIsBigTruck(state: RootState, isBigTruck: boolean) { state.order.vehicle.isBigTruck = isBigTruck; }, - updateCarId(state, carId) { + updateCarId(state: RootState, carId: string | null) { state.order.vehicle.carId = carId; }, - updateVehicleCategory(state, category) { + updateVehicleCategory(state: RootState, category: string | null) { state.order.vehicle.category = category; }, - updateVehicleCanSafeliteService(state, canSafeliteService) { + updateVehicleCanSafeliteService(state: RootState, canSafeliteService: boolean | null) { state.order.vehicle.canSafeliteService = canSafeliteService; }, - updateVehicleImageUrl(state, imageUrl) { + updateVehicleImageUrl(state: RootState, imageUrl: string | null) { state.order.vehicle.imageUrl = imageUrl; }, - updateVehicleImageVifNumber(state, imageVifNumber) { + updateVehicleImageVifNumber(state: RootState, imageVifNumber: string | null) { state.order.vehicle.imageVifNumber = imageVifNumber; }, - updateVehicleImageColor(state, imageColor) { + updateVehicleImageColor(state: RootState, imageColor: string | null) { state.order.vehicle.imageColor = imageColor; }, - updateVehicleVin(state, vin) { + updateVehicleVin(state: RootState, vin: string | null) { state.order.vehicle.vin = vin; }, - updateIsRepair(state, isRepair) { + updateIsRepair(state: RootState, isRepair: boolean | null) { state.order.damage.isRepair = isRepair; }, - updateNumberOfChips(state, numberOfChips) { + updateNumberOfChips(state: RootState, numberOfChips: number | null) { state.order.damage.numberOfChips = numberOfChips; }, - updateGlassToReplace(state, glassToReplace) { + updateGlassToReplace(state: RootState, glassToReplace: string | null) { state.order.damage.glassToReplace = glassToReplace; }, - updatePartQuestionAnswers(state, answersArray) { + updatePartQuestionAnswers(state: RootState, answersArray: unknown[] | null) { state.order.damage.partQuestionAnswers = answersArray; }, - updateMoldingQuestionAnswers(state, answersArray) { + updateMoldingQuestionAnswers(state: RootState, answersArray: unknown[] | null) { state.order.damage.moldingQuestionAnswers = answersArray; }, - updateCapabilityQuestionAnswers(state, answersArray) { + updateCapabilityQuestionAnswers(state: RootState, answersArray: unknown[] | null) { state.order.damage.capabilityQuestionAnswers = answersArray; }, updateGlassParts(state, partsData) { @@ -348,7 +352,7 @@ export const mutations = { updateIsRecalAcknowledgedForScheduling(state, isRecalAcknowledgedForScheduling) { state.order.isRecalAcknowledgedForScheduling = isRecalAcknowledgedForScheduling; }, - updateIsOemGlassSelected(state, isOemGlassSelected) { + updateIsOemGlassSelected(state: RootState, isOemGlassSelected: boolean | null) { state.order.damage.installOemGlass = isOemGlassSelected; }, updateIsMSRFeeApplicable(state, isMSRFeeApplicable) { @@ -393,21 +397,22 @@ export const mutations = { updateCustomerWaitListRequested(state, waitListRequested) { state.order.customer.waitListRequested = waitListRequested; }, - updateVehicle(state, vehicleInfo) { - state.order.vehicle.year = vehicleInfo.year; - state.order.vehicle.make = vehicleInfo.make; - state.order.vehicle.model = vehicleInfo.model; - state.order.vehicle.style = vehicleInfo.style; - state.order.vehicle.carId = vehicleInfo.carId; - state.order.vehicle.category = vehicleInfo.category; - state.order.vehicle.vin = vehicleInfo.vin; + updateVehicle(state: RootState, vehicleInfo: VehicleUpdatePayload) { + state.order.vehicle.year = vehicleInfo.year ?? null; + state.order.vehicle.make = vehicleInfo.make ?? null; + state.order.vehicle.model = vehicleInfo.model ?? null; + state.order.vehicle.style = vehicleInfo.style ?? null; + state.order.vehicle.carId = vehicleInfo.carId ?? null; + state.order.vehicle.category = vehicleInfo.category ?? null; + state.order.vehicle.vin = vehicleInfo.vin ?? null; - state.order.vehicle.imageUrl = vehicleInfo.imageUrl; - state.order.vehicle.imageVifNumber = vehicleInfo.imageVifNumber; - state.order.vehicle.imageColor = vehicleInfo.imageVifColor; + state.order.vehicle.imageUrl = vehicleInfo.imageUrl ?? null; + state.order.vehicle.imageVifNumber = vehicleInfo.imageVifNumber ?? null; + state.order.vehicle.imageColor = vehicleInfo.imageVifColor ?? null; }, - updateRegistration(state, registrationInfo) { - state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate; + updateRegistration(state: RootState, registrationInfo: RegistrationUpdatePayload) { + state.order.vehicle.registration.licensePlate = + registrationInfo?.licensePlate ?? null; }, updateServiceZip(state, serviceZipInfo) { state.order.serviceLocation.state = serviceZipInfo.state; @@ -1252,7 +1257,7 @@ export const actions = { getVehicle(context, { payload: { year, make, model, style }, pageNameToLog }) { return globalMethods .callHttpClient({ - methods: endpoints.GetVehicle.method, + method: endpoints.GetVehicle.method, endpoint: `${endpoints.GetVehicle.url}/${year}/${make}/${model}/${style}`, payload: {}, logApiCall: true, @@ -1265,7 +1270,7 @@ export const actions = { getDamageOptions(context, { payload: { carId }, pageNameToLog }) { return globalMethods.callHttpClient({ - methods: endpoints.GetDamageOptions.method, + method: endpoints.GetDamageOptions.method, endpoint: `${endpoints.GetDamageOptions.url}/${carId}`, payload: {}, additionalSuccessEventDataHandler: (response) => @@ -1278,7 +1283,7 @@ export const actions = { validateZip(context, { payload: { zip }, pageNameToLog }) { const damageType = context.getters.damage.isRepair ? "Repair" : "Replace"; return globalMethods.callHttpClient({ - methods: endpoints.ValidateZip.method, + method: endpoints.ValidateZip.method, endpoint: `${endpoints.ValidateZip.url}/${zip}/${damageType}`, logApiCall: true, pageNameToLog: pageNameToLog, @@ -1287,7 +1292,7 @@ export const actions = { getClosestApplicableShops(context, { payload: { zip, carId }, pageNameToLog }) { return globalMethods.callHttpClient({ - methods: endpoints.ClosestApplicableShops.method, + method: endpoints.ClosestApplicableShops.method, endpoint: `${endpoints.ClosestApplicableShops.url}/${zip}/${carId}`, logApiCall: true, pageNameToLog: pageNameToLog, diff --git a/src/store/types.ts b/src/store/types.ts index 9c5428177..5ca6561c0 100644 --- a/src/store/types.ts +++ b/src/store/types.ts @@ -25,6 +25,25 @@ export interface VehicleState { registration: VehicleRegistration; } +/** Payload for updateVehicle mutation */ +export interface VehicleUpdatePayload { + year?: number | null; + make?: string | null; + model?: string | null; + style?: string | null; + carId?: string | null; + category?: string | null; + vin?: string | null; + imageUrl?: string | null; + imageVifNumber?: string | null; + imageVifColor?: string | null; +} + +/** Payload for updateRegistration mutation */ +export interface RegistrationUpdatePayload { + licensePlate?: string | null; +} + export interface ProviderAddress { streetAddress: string | null; city: string | null; @@ -162,7 +181,7 @@ export interface OrderState { export interface ApplicationUserState { eventBus: unknown[]; pageData: Record; - savedSessionTimeout: Date | null; + savedSessionTimeout: string | null; saveSessionPromise: Promise | null; savedSessionId: string | null; crmCustomerId: string | null;