diff --git a/package.json b/package.json index 14a3591..7503056 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "esdp", "productName": "EMS Uploader", - "version": "0.0.2", + "version": "0.0.3", "description": "EMS Uploader", "main": "./out/main/index.js", "author": "ImEX Systems Inc.", diff --git a/src/main/estimate-scrubber/estimate-scrubber.ts b/src/main/estimate-scrubber/estimate-scrubber.ts index a1b574e..69db4a1 100644 --- a/src/main/estimate-scrubber/estimate-scrubber.ts +++ b/src/main/estimate-scrubber/estimate-scrubber.ts @@ -9,6 +9,7 @@ import store from "../store/store"; import ipcTypes from "../../util/ipcTypes.json"; import { insertScrubRun } from "../db/scrub-history-db"; import { Notification } from "electron/main"; +import getMainWindow from "../../util/getMainWindow"; // Function to write job object to logs subfolder async function writeJobToLogsFolder(job, fileName): Promise { @@ -69,10 +70,24 @@ async function ScrubEstimate({ } log.log(`Estimate Scrubber URL: [${currentChannel} |`, estimateScrubberUrl); - + const mainWindow = getMainWindow(); try { const esApiKey = store.get("settings.esApiKey") as string; + if (!esApiKey || esApiKey.trim() === "") { + const notificationError = new Notification({ + title: "No API Key Set", + body: "You must have a valid and active API key set in order to scrub estimates.", + }); + + notificationError.show(); + + mainWindow?.webContents.send(ipcTypes.toRenderer.scrub.scrubError, { + message: + "You must have a valid and active API key set in order to scrub estimates.", + }); + } + if (!job) { console.error("No job provided to ScrubEstimate"); return; @@ -134,7 +149,6 @@ async function ScrubEstimate({ const err = error as AxiosError; log.error("Error while scrubbing estimate:", err.message, err.stack); log.error("Error Response Data:", err.response?.data); - const mainWindow = BrowserWindow.getAllWindows()[0]; const status = err.response?.status; const responseData = err.response?.data;