Add job status & correct claimant info checks.
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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<void> {
|
||||
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()
|
||||
|
||||
@@ -121,8 +121,8 @@ async function StopWatcher(): Promise<boolean> {
|
||||
}
|
||||
|
||||
async function HandleNewFile(path): Promise<void> {
|
||||
await ImportJob(path);
|
||||
log.log("Received a new file", path);
|
||||
await ImportJob(path);
|
||||
}
|
||||
|
||||
export {
|
||||
|
||||
@@ -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: <NavLink to="/">{t("navigation.home")}</NavLink>, key: "home" },
|
||||
{
|
||||
@@ -13,16 +16,24 @@ const NavigationHeader: React.FC = () => {
|
||||
},
|
||||
];
|
||||
return (
|
||||
<Layout.Header style={{ display: "flex", alignItems: "center" }}>
|
||||
<div className="demo-logo" />
|
||||
<Menu
|
||||
theme="dark"
|
||||
mode="horizontal"
|
||||
defaultSelectedKeys={["2"]}
|
||||
items={menuItems}
|
||||
style={{ flex: 1, minWidth: 0 }}
|
||||
/>
|
||||
</Layout.Header>
|
||||
<Badge.Ribbon
|
||||
text={
|
||||
isWatcherStarted
|
||||
? t("settings.labels.started")
|
||||
: t("settings.labels.stopped")
|
||||
}
|
||||
color={isWatcherStarted ? "green" : "red"}
|
||||
>
|
||||
<Layout.Header style={{ display: "flex", alignItems: "center" }}>
|
||||
<Menu
|
||||
theme="dark"
|
||||
mode="horizontal"
|
||||
defaultSelectedKeys={["2"]}
|
||||
items={menuItems}
|
||||
style={{ flex: 1, minWidth: 0 }}
|
||||
/>
|
||||
</Layout.Header>
|
||||
</Badge.Ribbon>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -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 (
|
||||
<>
|
||||
<Button onClick={handleStart}>
|
||||
{t("settings.actions.startwatcher")}
|
||||
</Button>
|
||||
<Button onClick={handleStop}>{t("settings.actions.stopwatcher")}</Button>
|
||||
{isWatcherStarted}
|
||||
{watcherError}
|
||||
<Space>
|
||||
{isWatcherStarted ? (
|
||||
<Button onClick={handleStop}>
|
||||
{t("settings.actions.stopwatcher")}
|
||||
</Button>
|
||||
) : (
|
||||
<Button onClick={handleStart}>
|
||||
{t("settings.actions.startwatcher")}
|
||||
</Button>
|
||||
)}
|
||||
{isWatcherStarted ? (
|
||||
<Space>
|
||||
<CheckCircleOutlined style={{ color: "green" }} />
|
||||
@@ -44,7 +46,8 @@ const SettingsWatcher: React.FC = () => {
|
||||
{t("settings.labels.stopped")}
|
||||
</Space>
|
||||
)}
|
||||
</>
|
||||
{watcherError && <Alert message={watcherError} />}
|
||||
</Space>
|
||||
);
|
||||
};
|
||||
export default SettingsWatcher;
|
||||
|
||||
Reference in New Issue
Block a user