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

View File

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

View File

@@ -26,8 +26,8 @@ exports.default = async function (socket, jobid) {
"DEBUG",
`Received Job export request for id ${jobid}`
);
socket["cdk-job-export"] = {};
let clVFV, clADPV, clADPC;
//The following values will be stored on the socket to allow callbacks.
//let clVFV, clADPV, clADPC;
const JobData = await QueryJobData(socket, jobid);
console.log(JSON.stringify(JobData, null, 2));
const DealerId = JobData.bodyshop.cdk_dealerid;
@@ -38,8 +38,8 @@ exports.default = async function (socket, jobid) {
);
//{1} Begin Calculate DMS Vehicle Id
clVFV = await CalculateDmsVid(socket, JobData);
if (clVFV.newId === "Y") {
socket.clVFV = await CalculateDmsVid(socket, JobData);
if (socket.clVFV.newId === "Y") {
//{1.2} This is a new Vehicle ID
CdkBase.createLogEvent(
socket,
@@ -49,7 +49,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent(
socket,
"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?
//{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);
//TOOD: Need to find a way to wait and determine which customer to use.
return;
}
} else {
CdkBase.createLogEvent(
@@ -108,7 +108,11 @@ exports.default = async function (socket, jobid) {
);
//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(
socket,
"DEBUG",
@@ -117,7 +121,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent(
socket,
"TRACE",
`{11.1} clADPC: ${JSON.stringify(clADPC, null, 2)}`
`{11.1} clADPC: ${JSON.stringify(socket.clADPC, null, 2)}`
);
}
} else {
@@ -125,14 +129,14 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent(
socket,
"TRACE",
`{1.1} clVFV: ${JSON.stringify(clVFV, null, 2)}`
`{1.1} clVFV: ${JSON.stringify(socket.clVFV, null, 2)}`
);
//{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.
if (clADPV.AppErrorNo === "0") {
if (socket.clADPV.AppErrorNo === "0") {
//Vehicle was found.
CdkBase.createLogEvent(
socket,
@@ -142,7 +146,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent(
socket,
"TRACE",
`{1.4} clADPV: ${JSON.stringify(clADPV, null, 2)}`
`{1.4} clADPV: ${JSON.stringify(socket.clADPV, null, 2)}`
);
} else {
//Vehicle was not found.
@@ -154,7 +158,7 @@ exports.default = async function (socket, jobid) {
CdkBase.createLogEvent(
socket,
"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 {
//Ensure we always 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) => {
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", () => {
createLogEvent(socket, "DEBUG", `User disconnected.`);