Refactor decode to match existing partner.

This commit is contained in:
Patrick Fic
2025-03-20 13:44:23 -07:00
parent 45209bd9e4
commit 4310b3779a
10 changed files with 83 additions and 7 deletions

View File

@@ -19,5 +19,5 @@ export interface DecodedStlLine {
ttl_amt?: number;
}
export interface DecodedStl {
cieca_stl: DecodedStlLine[];
cieca_stl: { data: DecodedStlLine[] };
}

View File

@@ -57,6 +57,6 @@ const DecodeStl = async (
//Apply business logic transfomrations.
//We don't have an inspection date, we instead have `date_estimated`
return { cieca_stl: rawStlData };
return { cieca_stl: { data: rawStlData } };
};
export default DecodeStl;

View File

@@ -25,7 +25,7 @@ export interface VehicleRecordInterface {
impact2?: string;
};
// Paint code information
paint_codes: {
v_paint_codes: {
paint_cd1: string;
paint_cd2: string;
paint_cd3: string;

View File

@@ -77,7 +77,7 @@ const DecodeVeh = async (
delete rawVehData.impact_2;
//Consolidate Paint Code information.
rawVehData.paint_codes = {
rawVehData.v_paint_codes = {
paint_cd1: rawVehData.paint_cd1 ?? "",
paint_cd2: rawVehData.paint_cd2 ?? "",
paint_cd3: rawVehData.paint_cd3 ?? "",

View File

@@ -34,4 +34,13 @@ export const { increment, decrement, incrementByAmount } = appSlice.actions;
// Other code such as selectors can use the imported `RootState` type
export const selectCount = (state: RootState): number => state.app.value;
//Async Functions - Thunks
// Define a thunk that dispatches those action creators
const fetchUsers = () => async (dispatch) => {
dispatch(increment());
//Some sort of async action.
dispatch(incrementByAmount(100));
};
export default appSlice.reducer;

View File

@@ -1,8 +1,10 @@
import { configureStore } from "@reduxjs/toolkit";
import logger from "redux-logger";
import appReducer from "./app.slice";
const store = configureStore({
reducer: { app: appReducer },
middleware: (getDefaultMiddleware) => getDefaultMiddleware().concat(logger),
});
// Infer the `RootState` and `AppDispatch` types from the store itself

View File

@@ -2,7 +2,8 @@ import type { TypedUseSelectorHook } from "react-redux";
import { useDispatch, useSelector, useStore } from "react-redux";
import type { AppDispatch, AppStore, RootState } from "./redux-store";
// Use throughout your app instead of plain `useDispatch` and `useSelector`
//Use these custom hooks to access the Redux store from your component with type safety.
export const useAppDispatch: () => AppDispatch = useDispatch;
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
export const useAppStore: () => AppStore = useStore;

View File

@@ -0,0 +1,12 @@
//Set up all of the IPC handlers.
import ipcTypes from "../../../util/ipcTypes.json";
const ipcRenderer = window.electron.ipcRenderer;
ipcRenderer.on(
ipcTypes.toRenderer.test,
(event: Electron.IpcRendererEvent, arg) => {
console.log("Received test message from main process");
console.log(arg);
}
);