-
Notifications
You must be signed in to change notification settings - Fork 1
/
preload.js
43 lines (39 loc) · 1.46 KB
/
preload.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
const { contextBridge, ipcRenderer } = require("electron");
let getAccessToken;
let getVehicleData;
let validateVehicleForRedeployment;
let redeployVehicle;
let businessModelsReverse;
let getTravelSheet;
try {
getAccessToken = require("./tokenLogic/getAccessToken").getAccessToken;
getVehicleData = require("./vehicleRedeployment/getVehicle").getVehicleData;
validateVehicleForRedeployment =
require("./vehicleRedeployment/checkVehicle").validateVehicleForRedeployment;
redeployVehicle =
require("./vehicleRedeployment/changeVehicleBM").redeployVehicle;
businessModelsReverse = require("./businessModelsReverses.json");
getTravelSheet = require("./travelSheets/travelSheet").getTravelSheet;
contextBridge.exposeInMainWorld("api", {
saveRefreshToken: (newRefreshToken) =>
ipcRenderer.invoke("save-refresh-token", newRefreshToken),
refreshToken: () => ipcRenderer.invoke("get-refresh-token"),
getAccessToken,
getVehicleData,
validateVehicleForRedeployment,
redeployVehicle,
businessModelsReverse,
getTravelSheet,
saveFile: (reservationNumber, data) => {
ipcRenderer.send("save-file", { reservationNumber, data });
},
onFileSaved: (callback) => {
ipcRenderer.on("file-saved", (_, message) => callback(message));
},
onSaveError: (callback) => {
ipcRenderer.on("save-error", (_, errorMessage) => callback(errorMessage));
},
});
} catch (error) {
console.error("Error in preload.js:", error);
}