Add api key check.
This commit is contained in:
@@ -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.",
|
||||
|
||||
@@ -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<string> {
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user