Convert vehicle mutuations and damage mutations to typescript
This commit is contained in:
parent
90bc0a3684
commit
df3dca74a6
2 changed files with 64 additions and 40 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<string, unknown>;
|
||||
savedSessionTimeout: Date | null;
|
||||
savedSessionTimeout: string | null;
|
||||
saveSessionPromise: Promise<unknown> | null;
|
||||
savedSessionId: string | null;
|
||||
crmCustomerId: string | null;
|
||||
|
|
|
|||
Loading…
Reference in a new issue