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 { createStore } from "vuex";
|
||||||
import type { RootState } from "./types";
|
import type {
|
||||||
|
RootState,
|
||||||
|
VehicleUpdatePayload,
|
||||||
|
RegistrationUpdatePayload,
|
||||||
|
} from "./types";
|
||||||
import { endpoints } from "@/constants/endpoints.js";
|
import { endpoints } from "@/constants/endpoints.js";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
import { sessionStorageKeyConstants } from "@/constants/session-storage.js";
|
import { sessionStorageKeyConstants } from "@/constants/session-storage.js";
|
||||||
|
|
@ -216,64 +220,64 @@ export const externalParameterState = getExternalParameterDefaultState();
|
||||||
// Export Mutations
|
// Export Mutations
|
||||||
export const mutations = {
|
export const mutations = {
|
||||||
// VEHICLE MUTATIONS
|
// VEHICLE MUTATIONS
|
||||||
updateYear(state, year) {
|
updateYear(state: RootState, year: number | null) {
|
||||||
state.order.vehicle.year = year;
|
state.order.vehicle.year = year;
|
||||||
},
|
},
|
||||||
updateMake(state, make) {
|
updateMake(state: RootState, make: string | null) {
|
||||||
state.order.vehicle.make = make;
|
state.order.vehicle.make = make;
|
||||||
},
|
},
|
||||||
updateModel(state, model) {
|
updateModel(state: RootState, model: string | null) {
|
||||||
state.order.vehicle.model = model;
|
state.order.vehicle.model = model;
|
||||||
},
|
},
|
||||||
updateStyle(state, style) {
|
updateStyle(state: RootState, style: string | null) {
|
||||||
state.order.vehicle.style = style;
|
state.order.vehicle.style = style;
|
||||||
},
|
},
|
||||||
updateVehicleSubType(state, vehicleSubType) {
|
updateVehicleSubType(state: RootState, vehicleSubType: string | null) {
|
||||||
state.order.vehicle.vehicleSubType = vehicleSubType;
|
state.order.vehicle.vehicleSubType = vehicleSubType;
|
||||||
},
|
},
|
||||||
updateVehicleSpecialClass(state, vehicleSpecialClass) {
|
updateVehicleSpecialClass(state: RootState, vehicleSpecialClass: string | null) {
|
||||||
state.order.vehicle.vehicleSpecialClass = vehicleSpecialClass;
|
state.order.vehicle.vehicleSpecialClass = vehicleSpecialClass;
|
||||||
},
|
},
|
||||||
updateIsBigTruck(state, isBigTruck) {
|
updateIsBigTruck(state: RootState, isBigTruck: boolean) {
|
||||||
state.order.vehicle.isBigTruck = isBigTruck;
|
state.order.vehicle.isBigTruck = isBigTruck;
|
||||||
},
|
},
|
||||||
updateCarId(state, carId) {
|
updateCarId(state: RootState, carId: string | null) {
|
||||||
state.order.vehicle.carId = carId;
|
state.order.vehicle.carId = carId;
|
||||||
},
|
},
|
||||||
updateVehicleCategory(state, category) {
|
updateVehicleCategory(state: RootState, category: string | null) {
|
||||||
state.order.vehicle.category = category;
|
state.order.vehicle.category = category;
|
||||||
},
|
},
|
||||||
updateVehicleCanSafeliteService(state, canSafeliteService) {
|
updateVehicleCanSafeliteService(state: RootState, canSafeliteService: boolean | null) {
|
||||||
state.order.vehicle.canSafeliteService = canSafeliteService;
|
state.order.vehicle.canSafeliteService = canSafeliteService;
|
||||||
},
|
},
|
||||||
updateVehicleImageUrl(state, imageUrl) {
|
updateVehicleImageUrl(state: RootState, imageUrl: string | null) {
|
||||||
state.order.vehicle.imageUrl = imageUrl;
|
state.order.vehicle.imageUrl = imageUrl;
|
||||||
},
|
},
|
||||||
updateVehicleImageVifNumber(state, imageVifNumber) {
|
updateVehicleImageVifNumber(state: RootState, imageVifNumber: string | null) {
|
||||||
state.order.vehicle.imageVifNumber = imageVifNumber;
|
state.order.vehicle.imageVifNumber = imageVifNumber;
|
||||||
},
|
},
|
||||||
updateVehicleImageColor(state, imageColor) {
|
updateVehicleImageColor(state: RootState, imageColor: string | null) {
|
||||||
state.order.vehicle.imageColor = imageColor;
|
state.order.vehicle.imageColor = imageColor;
|
||||||
},
|
},
|
||||||
updateVehicleVin(state, vin) {
|
updateVehicleVin(state: RootState, vin: string | null) {
|
||||||
state.order.vehicle.vin = vin;
|
state.order.vehicle.vin = vin;
|
||||||
},
|
},
|
||||||
updateIsRepair(state, isRepair) {
|
updateIsRepair(state: RootState, isRepair: boolean | null) {
|
||||||
state.order.damage.isRepair = isRepair;
|
state.order.damage.isRepair = isRepair;
|
||||||
},
|
},
|
||||||
updateNumberOfChips(state, numberOfChips) {
|
updateNumberOfChips(state: RootState, numberOfChips: number | null) {
|
||||||
state.order.damage.numberOfChips = numberOfChips;
|
state.order.damage.numberOfChips = numberOfChips;
|
||||||
},
|
},
|
||||||
updateGlassToReplace(state, glassToReplace) {
|
updateGlassToReplace(state: RootState, glassToReplace: string | null) {
|
||||||
state.order.damage.glassToReplace = glassToReplace;
|
state.order.damage.glassToReplace = glassToReplace;
|
||||||
},
|
},
|
||||||
updatePartQuestionAnswers(state, answersArray) {
|
updatePartQuestionAnswers(state: RootState, answersArray: unknown[] | null) {
|
||||||
state.order.damage.partQuestionAnswers = answersArray;
|
state.order.damage.partQuestionAnswers = answersArray;
|
||||||
},
|
},
|
||||||
updateMoldingQuestionAnswers(state, answersArray) {
|
updateMoldingQuestionAnswers(state: RootState, answersArray: unknown[] | null) {
|
||||||
state.order.damage.moldingQuestionAnswers = answersArray;
|
state.order.damage.moldingQuestionAnswers = answersArray;
|
||||||
},
|
},
|
||||||
updateCapabilityQuestionAnswers(state, answersArray) {
|
updateCapabilityQuestionAnswers(state: RootState, answersArray: unknown[] | null) {
|
||||||
state.order.damage.capabilityQuestionAnswers = answersArray;
|
state.order.damage.capabilityQuestionAnswers = answersArray;
|
||||||
},
|
},
|
||||||
updateGlassParts(state, partsData) {
|
updateGlassParts(state, partsData) {
|
||||||
|
|
@ -348,7 +352,7 @@ export const mutations = {
|
||||||
updateIsRecalAcknowledgedForScheduling(state, isRecalAcknowledgedForScheduling) {
|
updateIsRecalAcknowledgedForScheduling(state, isRecalAcknowledgedForScheduling) {
|
||||||
state.order.isRecalAcknowledgedForScheduling = isRecalAcknowledgedForScheduling;
|
state.order.isRecalAcknowledgedForScheduling = isRecalAcknowledgedForScheduling;
|
||||||
},
|
},
|
||||||
updateIsOemGlassSelected(state, isOemGlassSelected) {
|
updateIsOemGlassSelected(state: RootState, isOemGlassSelected: boolean | null) {
|
||||||
state.order.damage.installOemGlass = isOemGlassSelected;
|
state.order.damage.installOemGlass = isOemGlassSelected;
|
||||||
},
|
},
|
||||||
updateIsMSRFeeApplicable(state, isMSRFeeApplicable) {
|
updateIsMSRFeeApplicable(state, isMSRFeeApplicable) {
|
||||||
|
|
@ -393,21 +397,22 @@ export const mutations = {
|
||||||
updateCustomerWaitListRequested(state, waitListRequested) {
|
updateCustomerWaitListRequested(state, waitListRequested) {
|
||||||
state.order.customer.waitListRequested = waitListRequested;
|
state.order.customer.waitListRequested = waitListRequested;
|
||||||
},
|
},
|
||||||
updateVehicle(state, vehicleInfo) {
|
updateVehicle(state: RootState, vehicleInfo: VehicleUpdatePayload) {
|
||||||
state.order.vehicle.year = vehicleInfo.year;
|
state.order.vehicle.year = vehicleInfo.year ?? null;
|
||||||
state.order.vehicle.make = vehicleInfo.make;
|
state.order.vehicle.make = vehicleInfo.make ?? null;
|
||||||
state.order.vehicle.model = vehicleInfo.model;
|
state.order.vehicle.model = vehicleInfo.model ?? null;
|
||||||
state.order.vehicle.style = vehicleInfo.style;
|
state.order.vehicle.style = vehicleInfo.style ?? null;
|
||||||
state.order.vehicle.carId = vehicleInfo.carId;
|
state.order.vehicle.carId = vehicleInfo.carId ?? null;
|
||||||
state.order.vehicle.category = vehicleInfo.category;
|
state.order.vehicle.category = vehicleInfo.category ?? null;
|
||||||
state.order.vehicle.vin = vehicleInfo.vin;
|
state.order.vehicle.vin = vehicleInfo.vin ?? null;
|
||||||
|
|
||||||
state.order.vehicle.imageUrl = vehicleInfo.imageUrl;
|
state.order.vehicle.imageUrl = vehicleInfo.imageUrl ?? null;
|
||||||
state.order.vehicle.imageVifNumber = vehicleInfo.imageVifNumber;
|
state.order.vehicle.imageVifNumber = vehicleInfo.imageVifNumber ?? null;
|
||||||
state.order.vehicle.imageColor = vehicleInfo.imageVifColor;
|
state.order.vehicle.imageColor = vehicleInfo.imageVifColor ?? null;
|
||||||
},
|
},
|
||||||
updateRegistration(state, registrationInfo) {
|
updateRegistration(state: RootState, registrationInfo: RegistrationUpdatePayload) {
|
||||||
state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate;
|
state.order.vehicle.registration.licensePlate =
|
||||||
|
registrationInfo?.licensePlate ?? null;
|
||||||
},
|
},
|
||||||
updateServiceZip(state, serviceZipInfo) {
|
updateServiceZip(state, serviceZipInfo) {
|
||||||
state.order.serviceLocation.state = serviceZipInfo.state;
|
state.order.serviceLocation.state = serviceZipInfo.state;
|
||||||
|
|
@ -1252,7 +1257,7 @@ export const actions = {
|
||||||
getVehicle(context, { payload: { year, make, model, style }, pageNameToLog }) {
|
getVehicle(context, { payload: { year, make, model, style }, pageNameToLog }) {
|
||||||
return globalMethods
|
return globalMethods
|
||||||
.callHttpClient({
|
.callHttpClient({
|
||||||
methods: endpoints.GetVehicle.method,
|
method: endpoints.GetVehicle.method,
|
||||||
endpoint: `${endpoints.GetVehicle.url}/${year}/${make}/${model}/${style}`,
|
endpoint: `${endpoints.GetVehicle.url}/${year}/${make}/${model}/${style}`,
|
||||||
payload: {},
|
payload: {},
|
||||||
logApiCall: true,
|
logApiCall: true,
|
||||||
|
|
@ -1265,7 +1270,7 @@ export const actions = {
|
||||||
|
|
||||||
getDamageOptions(context, { payload: { carId }, pageNameToLog }) {
|
getDamageOptions(context, { payload: { carId }, pageNameToLog }) {
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
methods: endpoints.GetDamageOptions.method,
|
method: endpoints.GetDamageOptions.method,
|
||||||
endpoint: `${endpoints.GetDamageOptions.url}/${carId}`,
|
endpoint: `${endpoints.GetDamageOptions.url}/${carId}`,
|
||||||
payload: {},
|
payload: {},
|
||||||
additionalSuccessEventDataHandler: (response) =>
|
additionalSuccessEventDataHandler: (response) =>
|
||||||
|
|
@ -1278,7 +1283,7 @@ export const actions = {
|
||||||
validateZip(context, { payload: { zip }, pageNameToLog }) {
|
validateZip(context, { payload: { zip }, pageNameToLog }) {
|
||||||
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
const damageType = context.getters.damage.isRepair ? "Repair" : "Replace";
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
methods: endpoints.ValidateZip.method,
|
method: endpoints.ValidateZip.method,
|
||||||
endpoint: `${endpoints.ValidateZip.url}/${zip}/${damageType}`,
|
endpoint: `${endpoints.ValidateZip.url}/${zip}/${damageType}`,
|
||||||
logApiCall: true,
|
logApiCall: true,
|
||||||
pageNameToLog: pageNameToLog,
|
pageNameToLog: pageNameToLog,
|
||||||
|
|
@ -1287,7 +1292,7 @@ export const actions = {
|
||||||
|
|
||||||
getClosestApplicableShops(context, { payload: { zip, carId }, pageNameToLog }) {
|
getClosestApplicableShops(context, { payload: { zip, carId }, pageNameToLog }) {
|
||||||
return globalMethods.callHttpClient({
|
return globalMethods.callHttpClient({
|
||||||
methods: endpoints.ClosestApplicableShops.method,
|
method: endpoints.ClosestApplicableShops.method,
|
||||||
endpoint: `${endpoints.ClosestApplicableShops.url}/${zip}/${carId}`,
|
endpoint: `${endpoints.ClosestApplicableShops.url}/${zip}/${carId}`,
|
||||||
logApiCall: true,
|
logApiCall: true,
|
||||||
pageNameToLog: pageNameToLog,
|
pageNameToLog: pageNameToLog,
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,25 @@ export interface VehicleState {
|
||||||
registration: VehicleRegistration;
|
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 {
|
export interface ProviderAddress {
|
||||||
streetAddress: string | null;
|
streetAddress: string | null;
|
||||||
city: string | null;
|
city: string | null;
|
||||||
|
|
@ -162,7 +181,7 @@ export interface OrderState {
|
||||||
export interface ApplicationUserState {
|
export interface ApplicationUserState {
|
||||||
eventBus: unknown[];
|
eventBus: unknown[];
|
||||||
pageData: Record<string, unknown>;
|
pageData: Record<string, unknown>;
|
||||||
savedSessionTimeout: Date | null;
|
savedSessionTimeout: string | null;
|
||||||
saveSessionPromise: Promise<unknown> | null;
|
saveSessionPromise: Promise<unknown> | null;
|
||||||
savedSessionId: string | null;
|
savedSessionId: string | null;
|
||||||
crmCustomerId: string | null;
|
crmCustomerId: string | null;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue