IO-233 CDK WIP

This commit is contained in:
Patrick Fic
2021-07-06 09:31:01 -07:00
parent 84b39f3d2b
commit f0d6c5e1b1
5 changed files with 82 additions and 60 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,4 +1,4 @@
<babeledit_project version="1.2" be_version="2.7.1"> <babeledit_project be_version="2.7.1" version="1.2">
<!-- <!--
BabelEdit project file BabelEdit project file

View File

@@ -1,75 +1,73 @@
import React, { useEffect, useState } from "react"; import { Button, Table } from "antd";
import { socket } from "../../pages/dms/dms.container"; import React, { useState } from "react";
import { alphaSort } from "../../utils/sorters";
import { Table } from "antd";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { socket } from "../../pages/dms/dms.container";
import PhoneFormatter from "../../utils/PhoneFormatter";
import { alphaSort } from "../../utils/sorters";
export default function DmsCustomerSelector() { export default function DmsCustomerSelector() {
const { t } = useTranslation(); const { t } = useTranslation();
const [customerList, setcustomerList] = useState([]); const [customerList, setcustomerList] = useState([]);
const [visible, setVisible] = useState(false);
const [selectedCustomer, setSelectedCustomer] = useState(null); const [selectedCustomer, setSelectedCustomer] = useState(null);
useEffect(() => {
socket.on("cdk-select-customer", (customerList) => {
setcustomerList(customerList);
console.log("Received a customer list.", customerList);
});
return () => { socket.on("cdk-select-customer", (customerList, callback) => {
socket.removeListener("cdk-select-customer"); setVisible(true);
}; setcustomerList(customerList);
// eslint-disable-next-line react-hooks/exhaustive-deps });
}, []);
const onOk = () => {
setVisible(false);
socket.emit("cdk-selected-customer", selectedCustomer);
};
const columns = [ const columns = [
{ {
title: t("owners.fields.ownr_ln"), title: t("dms.fields.name1"),
dataIndex: "ownr_ln", dataIndex: ["name1", "fullName"],
key: "ownr_ln", key: "name1",
sorter: (a, b) => alphaSort(a.ownr_ln, b.ownr_ln), sorter: (a, b) => alphaSort(a.name1?.fullName, b.name1?.fullName),
}, },
{ {
title: t("owners.fields.ownr_fn"), title: t("dms.fields.name2"),
dataIndex: "ownr_fn", dataIndex: ["name2", "fullName"],
key: "ownr_fn", key: "name2",
sorter: (a, b) => alphaSort(a.ownr_fn, b.ownr_fn), sorter: (a, b) => alphaSort(a.name2?.fullName, b.name2?.fullName),
}, },
{ {
title: t("owners.fields.ownr_co_nm"), title: t("dms.fields.phone"),
dataIndex: "ownr_co_nm", dataIndex: ["contactInfo", "mainTelephoneNumber", "value"],
key: "ownr_co_nm", key: "phone",
sorter: (a, b) => alphaSort(a.ownr_co_nm, b.ownr_co_nm), render: (record, value) => (
<PhoneFormatter>
{record.contactInfo?.mainTelephoneNumber?.value}
</PhoneFormatter>
),
}, },
{ {
title: t("owners.fields.ownr_addr1"), title: t("dms.fields.address"),
dataIndex: "ownr_addr1", //dataIndex: ["name2", "fullName"],
key: "ownr_addr1", key: "address",
sorter: (a, b) => alphaSort(a.ownr_addr1, b.ownr_addr1), render: (record, value) =>
}, `${record.address?.addressLine[0]}, ${record.address?.city} ${record.address?.stateOrProvince} ${record.address?.postalCode}`,
{
title: t("owners.fields.ownr_city"),
dataIndex: "ownr_city",
key: "ownr_city",
sorter: (a, b) => alphaSort(a.ownr_city, b.ownr_city),
},
{
title: t("owners.fields.ownr_ea"),
dataIndex: "ownr_ea",
key: "ownr_ea",
sorter: (a, b) => alphaSort(a.ownr_ea, b.ownr_ea),
}, },
]; ];
if (!visible) return <></>;
return ( return (
<Table <Table
//scroll={{ x: true }} title={() => (
<div>
<Button onClick={onOk}>Select</Button>
</div>
)}
pagination={{ position: "top" }} pagination={{ position: "top" }}
columns={columns} columns={columns}
rowKey="id.value" rowKey={(record) => record.id.value}
dataSource={customerList} dataSource={customerList}
//onChange={handleTableChange} //onChange={handleTableChange}
rowSelection={{ rowSelection={{
onSelect: (props) => { onSelect: (props) => {
setSelectedCustomer(props.id); setSelectedCustomer(props.id.value);
}, },
type: "radio", type: "radio",
selectedRowKeys: [selectedCustomer], selectedRowKeys: [selectedCustomer],

View File

@@ -26,8 +26,8 @@ exports.default = async function (socket, jobid) {
"DEBUG", "DEBUG",
`Received Job export request for id ${jobid}` `Received Job export request for id ${jobid}`
); );
socket["cdk-job-export"] = {}; //The following values will be stored on the socket to allow callbacks.
let clVFV, clADPV, clADPC; //let clVFV, clADPV, clADPC;
const JobData = await QueryJobData(socket, jobid); const JobData = await QueryJobData(socket, jobid);
console.log(JSON.stringify(JobData, null, 2)); console.log(JSON.stringify(JobData, null, 2));
const DealerId = JobData.bodyshop.cdk_dealerid; const DealerId = JobData.bodyshop.cdk_dealerid;
@@ -38,8 +38,8 @@ exports.default = async function (socket, jobid) {
); );
//{1} Begin Calculate DMS Vehicle Id //{1} Begin Calculate DMS Vehicle Id
clVFV = await CalculateDmsVid(socket, JobData); socket.clVFV = await CalculateDmsVid(socket, JobData);
if (clVFV.newId === "Y") { if (socket.clVFV.newId === "Y") {
//{1.2} This is a new Vehicle ID //{1.2} This is a new Vehicle ID
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
@@ -49,7 +49,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
"TRACE", "TRACE",
`{1.2} clVFV: ${JSON.stringify(clVFV, null, 2)}` `{1.2} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
); );
//Check if DMSCustId is Empty - which it should always be? //Check if DMSCustId is Empty - which it should always be?
//{6.6} Should check to see if a customer exists so that we can marry it to the new vehicle. //{6.6} Should check to see if a customer exists so that we can marry it to the new vehicle.
@@ -87,7 +87,7 @@ exports.default = async function (socket, jobid) {
); );
socket.emit("cdk-select-customer", strIDS); socket.emit("cdk-select-customer", strIDS);
//TOOD: Need to find a way to wait and determine which customer to use. return;
} }
} else { } else {
CdkBase.createLogEvent( CdkBase.createLogEvent(
@@ -108,7 +108,11 @@ exports.default = async function (socket, jobid) {
); );
//Use the new customer number to insert the customer record. //Use the new customer number to insert the customer record.
clADPC = await CreateCustomerInDms(socket, JobData, newCustomerNumber); socket.clADPC = await CreateCustomerInDms(
socket,
JobData,
newCustomerNumber
);
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
"DEBUG", "DEBUG",
@@ -117,7 +121,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
"TRACE", "TRACE",
`{11.1} clADPC: ${JSON.stringify(clADPC, null, 2)}` `{11.1} clADPC: ${JSON.stringify(socket.clADPC, null, 2)}`
); );
} }
} else { } else {
@@ -125,14 +129,14 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
"TRACE", "TRACE",
`{1.1} clVFV: ${JSON.stringify(clVFV, null, 2)}` `{1.1} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
); );
//{2} Begin Find Vehicle in DMS //{2} Begin Find Vehicle in DMS
clADPV = await FindVehicleInDms(socket, JobData, clVFV); //TODO: Verify that this should always return a result. If an ID was found previously, it should be correct? socket.clADPV = await FindVehicleInDms(socket, JobData, socket.clVFV); //TODO: Verify that this should always return a result. If an ID was found previously, it should be correct?
//{2.2} Check if the vehicle was found in the DMS. //{2.2} Check if the vehicle was found in the DMS.
if (clADPV.AppErrorNo === "0") { if (socket.clADPV.AppErrorNo === "0") {
//Vehicle was found. //Vehicle was found.
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
@@ -142,7 +146,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
"TRACE", "TRACE",
`{1.4} clADPV: ${JSON.stringify(clADPV, null, 2)}` `{1.4} clADPV: ${JSON.stringify(socket.clADPV, null, 2)}`
); );
} else { } else {
//Vehicle was not found. //Vehicle was not found.
@@ -154,7 +158,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent( CdkBase.createLogEvent(
socket, socket,
"TRACE", "TRACE",
`{6.4} clVFV: ${JSON.stringify(clVFV, null, 2)}` `{6.4} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
); );
} }
} }
@@ -167,6 +171,11 @@ exports.default = async function (socket, jobid) {
} finally { } finally {
//Ensure we always insert logEvents //Ensure we always insert logEvents
//GQL to insert logevents. //GQL to insert logevents.
CdkBase.createLogEvent(
socket,
"DEBUG",
`Capturing log events to database.`
);
} }
}; };

View File

@@ -45,6 +45,15 @@ io.on("connection", (socket) => {
socket.on("cdk-export-job", (jobid) => { socket.on("cdk-export-job", (jobid) => {
CdkJobExport(socket, jobid); CdkJobExport(socket, jobid);
}); });
socket.on("cdk-selected-customer", (selectedCustomerId) => {
createLogEvent(
socket,
"DEBUG",
`User selected customer ID ${selectedCustomerId}`
);
socket.selectedCustomerId = selectedCustomerId;
//CdkJobExport(socket, jobid);
});
socket.on("disconnect", () => { socket.on("disconnect", () => {
createLogEvent(socket, "DEBUG", `User disconnected.`); createLogEvent(socket, "DEBUG", `User disconnected.`);