feature/IO-2924-Refactor-Production-Board-For-Sockets - Checkpoint
Signed-off-by: Dave Richer <dave@imexsystems.ca>
This commit is contained in:
@@ -20,7 +20,7 @@ export function DmsAllocationsSummaryAp({ bodyshop, billids, title }) {
|
||||
const { socket } = useContext(SocketContext);
|
||||
|
||||
useEffect(() => {
|
||||
if (!socket) return;
|
||||
if (!socket || !socket.connected) return;
|
||||
|
||||
const handleSuccess = async (billid) => {
|
||||
setAllocationsSummary((allocationsSummary) =>
|
||||
@@ -45,21 +45,10 @@ export function DmsAllocationsSummaryAp({ bodyshop, billids, title }) {
|
||||
}
|
||||
};
|
||||
|
||||
const handleFailure = ({ billid, error }) => {
|
||||
setAllocationsSummary((allocationsSummary) =>
|
||||
allocationsSummary.map((a) => {
|
||||
if (a.billid !== billid) return a;
|
||||
return { ...a, status: error };
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
socket.on("ap-export-success", handleSuccess);
|
||||
socket.on("ap-export-failure", handleFailure);
|
||||
|
||||
return () => {
|
||||
socket.off("ap-export-success", handleSuccess);
|
||||
socket.off("ap-export-failure", handleFailure);
|
||||
};
|
||||
}, [socket]);
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export function DmsAllocationsSummary({ socket, bodyshop, jobId, title }) {
|
||||
const [allocationsSummary, setAllocationsSummary] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
if (socket.connected) {
|
||||
if (socket && socket.connected) {
|
||||
socket.emit("cdk-calculate-allocations", jobId, (ack) => {
|
||||
setAllocationsSummary(ack);
|
||||
socket.allocationsSummary = ack;
|
||||
|
||||
@@ -60,7 +60,7 @@ export function DmsContainer({ setBreadcrumbs, setSelectedHeader }) {
|
||||
{
|
||||
timestamp: new Date(),
|
||||
level: "WARNING",
|
||||
message: "Reconnected to CDK Export Service"
|
||||
message: "Reconnected to DMS Export Service"
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
@@ -90,7 +90,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
{
|
||||
timestamp: new Date(),
|
||||
level: "WARNING",
|
||||
message: "Reconnected to CDK Export Service"
|
||||
message: "Reconnected to DMS Export Service"
|
||||
}
|
||||
]);
|
||||
};
|
||||
@@ -201,7 +201,7 @@ export function DmsContainer({ bodyshop, setBreadcrumbs, setSelectedHeader, inse
|
||||
<Select.Option key="WARNING">WARNING</Select.Option>
|
||||
<Select.Option key="ERROR">ERROR</Select.Option>
|
||||
</Select>
|
||||
4<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||
<Button onClick={() => setLogs([])}>Clear Logs</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
setLogs([]);
|
||||
|
||||
@@ -24,6 +24,7 @@ import UpdateAlert from "../../components/update-alert/update-alert.component";
|
||||
import InstanceRenderManager from "../../utils/instanceRenderMgr.js";
|
||||
import "./manage.page.styles.scss";
|
||||
import SocketContext from "../../contexts/SocketIO/socketContext.jsx";
|
||||
import { requestForToken } from "../../firebase/firebase.utils.js";
|
||||
|
||||
const JobsPage = lazy(() => import("../jobs/jobs.page"));
|
||||
|
||||
@@ -112,6 +113,17 @@ export function Manage({ conflict, bodyshop }) {
|
||||
const [chatVisible] = useState(false);
|
||||
const { socket, clientId } = useContext(SocketContext);
|
||||
|
||||
useEffect(() => {
|
||||
const widgetId = InstanceRenderManager({
|
||||
imex: "IABVNO4scRKY11XBQkNr",
|
||||
rome: "mQdqARMzkZRUVugJ6TdS"
|
||||
});
|
||||
window.noticeable.render("widget", widgetId);
|
||||
requestForToken().catch((error) => {
|
||||
console.error(`Unable to request for token.`, error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
document.title = InstanceRenderManager({
|
||||
imex: t("titles.imexonline"),
|
||||
|
||||
@@ -38,7 +38,9 @@ const SOCKETIO_CORS_ORIGIN = [
|
||||
"https://www.test.promanager.web-est.com",
|
||||
"https://test.promanager.web-est.com",
|
||||
"https://www.promanager.web-est.com",
|
||||
"https://www.promanager.web-est.com"
|
||||
"https://www.promanager.web-est.com",
|
||||
"https://old.imex.online",
|
||||
"https://www.old.imex.online"
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,12 +60,11 @@ async function registerSocketEvents(socket) {
|
||||
// CDK-specific socket events
|
||||
function registerCdkEvents(socket) {
|
||||
socket.on("cdk-export-job", (jobid) => CdkJobExport(socket, jobid));
|
||||
|
||||
socket.on("cdk-selected-customer", async (selectedCustomerId) => {
|
||||
await createLogEvent(socket, "DEBUG", `User selected customer ID ${selectedCustomerId}`);
|
||||
CdkSelectedCustomer(socket, selectedCustomerId).catch((err) =>
|
||||
console.error(`Error in cdk-selected-customer: ${err}`)
|
||||
);
|
||||
await setSessionData(socket.id, "selectedCustomer", selectedCustomerId);
|
||||
CdkSelectedCustomer(socket, selectedCustomerId);
|
||||
await setSessionData(socket.id, "selectedCustomerId ", selectedCustomerId);
|
||||
});
|
||||
|
||||
socket.on("cdk-get-makes", async (cdk_dealerid, callback) => {
|
||||
@@ -73,16 +72,15 @@ function registerCdkEvents(socket) {
|
||||
const makes = await CdkGetMakes(socket, cdk_dealerid);
|
||||
callback(makes);
|
||||
} catch (error) {
|
||||
await createLogEvent(socket, "ERROR", `Error in cdk-get-makes WS call. ${JSON.stringify(error)}`);
|
||||
await createLogEvent(socket, "ERROR", `Error in cdk-get-makes WS call. ${JSON.stringify(error, null, 2)}`);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("cdk-calculate-allocations", async (jobid, callback) => {
|
||||
const allocations = await CdkCalculateAllocations(socket, jobid);
|
||||
await createLogEvent(socket, "DEBUG", `Allocations calculated.`);
|
||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
|
||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
|
||||
callback(allocations);
|
||||
await setSessionData(socket.id, "cdk_allocations", allocations);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -91,18 +89,18 @@ function registerPbsArEvents(socket) {
|
||||
socket.on("pbs-calculate-allocations", async (jobid, callback) => {
|
||||
const allocations = await CdkCalculateAllocations(socket, jobid);
|
||||
await createLogEvent(socket, "DEBUG", `PBS AR allocations calculated.`);
|
||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
|
||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
|
||||
callback(allocations);
|
||||
await setSessionData(socket.id, "pbs_allocations", allocations);
|
||||
});
|
||||
|
||||
socket.on("pbs-export-job", (jobid) => PbsExportJob(socket, jobid));
|
||||
|
||||
socket.on("pbs-selected-customer", async (selectedCustomerId) => {
|
||||
await createLogEvent(socket, "DEBUG", `PBS AR selected customer ID ${selectedCustomerId}`);
|
||||
PbsSelectedCustomer(socket, selectedCustomerId).catch((err) =>
|
||||
console.error(`Error in pbs-selected-customer: ${err}`)
|
||||
);
|
||||
await setSessionData(socket.id, "selectedCustomer", selectedCustomerId);
|
||||
await setSessionData(socket.id, "selectedCustomerId", selectedCustomerId);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -111,13 +109,13 @@ function registerPbsApEvents(socket) {
|
||||
socket.on("pbs-calculate-allocations-ap", async (billids, callback) => {
|
||||
const allocations = await PbsCalculateAllocationsAp(socket, billids);
|
||||
await createLogEvent(socket, "DEBUG", `PBS AP allocations calculated.`);
|
||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations)}`);
|
||||
await createLogEvent(socket, "TRACE", `Allocations details: ${JSON.stringify(allocations, null, 2)}`);
|
||||
callback(allocations);
|
||||
await setSessionData(socket.id, "pbs_ap_allocations", allocations);
|
||||
});
|
||||
|
||||
socket.on("pbs-export-ap", async ({ billids, txEnvelope }) => {
|
||||
await setSessionData(socket.id, "pbs_txEnvelope", txEnvelope);
|
||||
await setSessionData(socket.id, "txEnvelope", txEnvelope);
|
||||
PbsExportAp(socket, {
|
||||
billids,
|
||||
txEnvelope
|
||||
|
||||
Reference in New Issue
Block a user