Add opcode and bodyshop query to main

This commit is contained in:
Patrick Fic
2025-03-21 08:33:41 -07:00
parent 6345b5a9a8
commit 6da5822197
9 changed files with 199 additions and 40 deletions

View File

@@ -49,17 +49,15 @@ if (import.meta.env.DEV) {
log.debug("[IPC Debug Functions] Adding Debug Handlers");
ipcMain.on(ipcTypes.toMain.debug.decodeEstimate, async (): Promise<void> => {
// const relativeEmsFilepath = `_reference/ems/MPI_1/3698420.ENV`;
// // Get the app's root directory and create an absolute path
// const rootDir = app.getAppPath();
// const absoluteFilepath = path.join(rootDir, relativeEmsFilepath);
// console.log("*** ~ ipcMain.on ~ absoluteFilepath:", absoluteFilepath);
const relativeEmsFilepath = `_reference/ems/MPI_1/3698420.ENV`;
// Get the app's root directory and create an absolute path
const rootDir = app.getAppPath();
const absoluteFilepath = path.join(rootDir, relativeEmsFilepath);
// log.debug("[IPC Debug Function] Decode test Estimate", absoluteFilepath);
// await ImportJob(absoluteFilepath);
log.debug("[IPC Debug Function] Decode test Estimate", absoluteFilepath);
await ImportJob(absoluteFilepath);
const job2 = `/Users/pfic/Downloads/12285264/2285264.ENV`;
const job3 = `/Users/pfic/Downloads/14033376/4033376.ENV`;
await ImportJob(job2);
await ImportJob(job3);

View File

@@ -1,12 +1,38 @@
import { IpcMainEvent } from "electron";
import { User } from "firebase/auth";
import client from "../graphql/graphql-client";
import {
ActiveBodyshopQueryResult,
MasterdataQueryResult,
QUERY_ACTIVE_BODYSHOP_TYPED,
QUERY_MASTERDATA_TYPED,
} from "../graphql/queries";
import Store from "../store/store";
import log from "electron-log/main";
const ipcMainHandleAuthStateChanged = async (
event: IpcMainEvent,
user: User | null
): Promise<void> => {
Store.set("user", user);
//Need to query the currently active shop, and store the metadata as well.
//Also need to query the OP Codes for decoding reference.
const activeBodyshop: ActiveBodyshopQueryResult = await client.request(
QUERY_ACTIVE_BODYSHOP_TYPED
);
Store.set("app.bodyshop", activeBodyshop.bodyshops[0]);
const OpCodes: MasterdataQueryResult = await client.request(
QUERY_MASTERDATA_TYPED,
{
key: `${activeBodyshop.bodyshops[0].region_config}_ciecaopcodes`,
}
);
Store.set("app.masterdata.opcodes", JSON.parse(OpCodes.masterdata[0]?.value));
log.debug("Received authentication state change from Renderer.", user);
log.debug("Requery shop information & master data.");
};
export { ipcMainHandleAuthStateChanged };