From 2fd226d43ace39e5b69b68e0e77d4ecdfaec47e8 Mon Sep 17 00:00:00 2001 From: Patrick Fic Date: Fri, 21 Mar 2025 15:38:30 -0700 Subject: [PATCH] Add job status & correct claimant info checks. --- src/main/decoder/decode-ad2.ts | 34 ++++++------ src/main/decoder/decoder.ts | 52 +++++++++++++++++++ src/main/watcher/watcher.ts | 2 +- .../NavigationHeader/Navigationheader.tsx | 33 ++++++++---- .../components/Settings/Settings.Watcher.tsx | 25 +++++---- 5 files changed, 106 insertions(+), 40 deletions(-) diff --git a/src/main/decoder/decode-ad2.ts b/src/main/decoder/decode-ad2.ts index 49957da..ab80873 100644 --- a/src/main/decoder/decode-ad2.ts +++ b/src/main/decoder/decode-ad2.ts @@ -30,23 +30,23 @@ const DecodeAD2 = async ( const rawAd2Data: DecodedAD2 = deepLowerCaseKeys( _.pick(rawDBFRecord[0], [ //TODO: Add typings for EMS File Formats. - // "CLMT_LN", //TODO: This claimant info shouldnt be passed back. Just for the owner info. - // "CLMT_FN", - // "CLMT_TITLE", - // "CLMT_CO_NM", - // "CLMT_ADDR1", - // "CLMT_ADDR2", - // "CLMT_CITY", - // "CLMT_ST", - // "CLMT_ZIP", - // "CLMT_CTRY", - // "CLMT_PH1", - //"CLMT_PH1X", - //"CLMT_PH2", - //"CLMT_PH2X", - //"CLMT_FAX", - //"CLMT_FAXX", - //"CLMT_EA", + "CLMT_LN", //TODO: This claimant info shouldnt be passed back. Just for the owner info. + "CLMT_FN", + "CLMT_TITLE", + "CLMT_CO_NM", + "CLMT_ADDR1", + "CLMT_ADDR2", + "CLMT_CITY", + "CLMT_ST", + "CLMT_ZIP", + "CLMT_CTRY", + "CLMT_PH1", + "CLMT_PH1X", + "CLMT_PH2", + "CLMT_PH2X", + "CLMT_FAX", + "CLMT_FAXX", + "CLMT_EA", //"EST_CO_ID", "EST_CO_NM", "EST_ADDR1", diff --git a/src/main/decoder/decoder.ts b/src/main/decoder/decoder.ts index 2c14ddb..12f004d 100644 --- a/src/main/decoder/decoder.ts +++ b/src/main/decoder/decoder.ts @@ -2,6 +2,7 @@ import { UUID } from "crypto"; import { Notification } from "electron"; import log from "electron-log/main"; import fs from "fs"; +import _ from "lodash"; import path from "path"; import errorTypeCheck from "../../util/errorTypeCheck"; import client from "../graphql/graphql-client"; @@ -83,6 +84,57 @@ async function ImportJob(filepath: string): Promise { shopid: store.get("app.bodyshop.id") as UUID, }; + //In some scenarios, the owner information is missing. So we use the claimant instead. + //We pull the claimant info for this, but we don't store it in our system, so it needs to be deleted regardless. + if ( + _.isEmpty(jobObject.ownr_ln) && + _.isEmpty(jobObject.ownr_fn) && + _.isEmpty(jobObject.ownr_co_nm) + ) { + jobObject.ownr_ln = jobObject.clmt_ln; + jobObject.ownr_fn = jobObject.clmt_fn; + jobObject.ownr_title = jobObject.clmt_title; + jobObject.ownr_co_nm = jobObject.clmt_co_nm; + jobObject.ownr_addr1 = jobObject.clmt_addr1; + jobObject.ownr_addr2 = jobObject.clmt_addr2; + jobObject.ownr_city = jobObject.clmt_city; + jobObject.ownr_st = jobObject.clmt_st; + jobObject.ownr_zip = jobObject.clmt_zip; + jobObject.ownr_ctry = jobObject.clmt_ctry; + jobObject.ownr_ph1 = jobObject.clmt_ph1; + jobObject.ownr_ph2 = jobObject.clmt_ph2; + jobObject.ownr_ea = jobObject.clmt_ea; + + jobObject.owner.data.ownr_ln = jobObject.clmt_ln; + jobObject.owner.data.ownr_fn = jobObject.clmt_fn; + jobObject.owner.data.ownr_title = jobObject.clmt_title; + jobObject.owner.data.ownr_co_nm = jobObject.clmt_co_nm; + jobObject.owner.data.ownr_addr1 = jobObject.clmt_addr1; + jobObject.owner.data.ownr_addr2 = jobObject.clmt_addr2; + jobObject.owner.data.ownr_city = jobObject.clmt_city; + jobObject.owner.data.ownr_st = jobObject.clmt_st; + jobObject.owner.data.ownr_zip = jobObject.clmt_zip; + jobObject.owner.data.ownr_ctry = jobObject.clmt_ctry; + jobObject.owner.data.ownr_ph1 = jobObject.clmt_ph1; + jobObject.owner.data.ownr_ph2 = jobObject.clmt_ph2; + jobObject.owner.data.ownr_ea = jobObject.clmt_ea; + } + + //Delete the claimant info as it's not needed. + delete jobObject.clmt_ln; + delete jobObject.clmt_fn; + delete jobObject.clmt_title; + delete jobObject.clmt_co_nm; + delete jobObject.clmt_addr1; + delete jobObject.clmt_addr2; + delete jobObject.clmt_city; + delete jobObject.clmt_st; + delete jobObject.clmt_zip; + delete jobObject.clmt_ctry; + delete jobObject.clmt_ph1; + delete jobObject.clmt_ph2; + delete jobObject.clmt_ea; + // Save jobObject to a timestamped JSON file const timestamp = new Date() .toISOString() diff --git a/src/main/watcher/watcher.ts b/src/main/watcher/watcher.ts index 53330d1..ab15c99 100644 --- a/src/main/watcher/watcher.ts +++ b/src/main/watcher/watcher.ts @@ -121,8 +121,8 @@ async function StopWatcher(): Promise { } async function HandleNewFile(path): Promise { - await ImportJob(path); log.log("Received a new file", path); + await ImportJob(path); } export { diff --git a/src/renderer/src/components/NavigationHeader/Navigationheader.tsx b/src/renderer/src/components/NavigationHeader/Navigationheader.tsx index 942f554..3acfa5d 100644 --- a/src/renderer/src/components/NavigationHeader/Navigationheader.tsx +++ b/src/renderer/src/components/NavigationHeader/Navigationheader.tsx @@ -1,10 +1,13 @@ -import { Layout, Menu } from "antd"; +import { selectWatcherStatus } from "@renderer/redux/app.slice"; +import { useAppSelector } from "@renderer/redux/reduxHooks"; +import { Badge, Layout, Menu } from "antd"; import { MenuItemType } from "antd/es/menu/interface"; import { useTranslation } from "react-i18next"; import { NavLink } from "react-router"; const NavigationHeader: React.FC = () => { const { t } = useTranslation(); + const isWatcherStarted = useAppSelector(selectWatcherStatus); const menuItems: MenuItemType[] = [ { label: {t("navigation.home")}, key: "home" }, { @@ -13,16 +16,24 @@ const NavigationHeader: React.FC = () => { }, ]; return ( - -
- - + + + + + ); }; diff --git a/src/renderer/src/components/Settings/Settings.Watcher.tsx b/src/renderer/src/components/Settings/Settings.Watcher.tsx index 55be840..54bb566 100644 --- a/src/renderer/src/components/Settings/Settings.Watcher.tsx +++ b/src/renderer/src/components/Settings/Settings.Watcher.tsx @@ -6,8 +6,8 @@ import { selectWatcherError, selectWatcherStatus, } from "@renderer/redux/app.slice"; -import { useAppDispatch, useAppSelector } from "@renderer/redux/reduxHooks"; -import { Button, Space } from "antd"; +import { useAppSelector } from "@renderer/redux/reduxHooks"; +import { Alert, Button, Space } from "antd"; import { useTranslation } from "react-i18next"; import ipcTypes from "../../../../util/ipcTypes.json"; @@ -15,7 +15,6 @@ const SettingsWatcher: React.FC = () => { const { t } = useTranslation(); const isWatcherStarted = useAppSelector(selectWatcherStatus); const watcherError = useAppSelector(selectWatcherError); - const dispatch = useAppDispatch(); const handleStart = (): void => { window.electron.ipcRenderer.send(ipcTypes.toMain.watcher.start); @@ -26,13 +25,16 @@ const SettingsWatcher: React.FC = () => { }; return ( - <> - - - {isWatcherStarted} - {watcherError} + + {isWatcherStarted ? ( + + ) : ( + + )} {isWatcherStarted ? ( @@ -44,7 +46,8 @@ const SettingsWatcher: React.FC = () => { {t("settings.labels.stopped")} )} - + {watcherError && } + ); }; export default SettingsWatcher;