feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Cashiering Checkpoint
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useSplitTreatments } from "@splitsoftware/splitio-react";
|
||||
import { Alert, Button, Checkbox, Col, message, Table } from "antd";
|
||||
import { Alert, Button, Checkbox, Col, message, Space, Table } from "antd";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { connect } from "react-redux";
|
||||
@@ -58,7 +58,14 @@ function rrAddressToString(addr) {
|
||||
return parts.join(", ");
|
||||
}
|
||||
|
||||
export function DmsCustomerSelector({ bodyshop, jobid, rrOpenRoLimit = false, onRrOpenRoFinished }) {
|
||||
export function DmsCustomerSelector({
|
||||
bodyshop,
|
||||
jobid,
|
||||
rrOpenRoLimit = false,
|
||||
onRrOpenRoFinished,
|
||||
rrCashierPending = false,
|
||||
onRrCashierFinished
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [customerList, setcustomerList] = useState([]);
|
||||
const [open, setOpen] = useState(false);
|
||||
@@ -87,6 +94,14 @@ export function DmsCustomerSelector({ bodyshop, jobid, rrOpenRoLimit = false, on
|
||||
}, [customerList]);
|
||||
const rrHasVinOwner = rrOwnerSet.size > 0;
|
||||
|
||||
// If cashiering is pending, surface this banner by opening selector
|
||||
useEffect(() => {
|
||||
if (dms === "rr" && rrCashierPending) {
|
||||
setOpen(true);
|
||||
setDmsType("rr");
|
||||
}
|
||||
}, [dms, rrCashierPending]);
|
||||
|
||||
useEffect(() => {
|
||||
if (dms === "rr") {
|
||||
const handleRrSelectCustomer = (list) => {
|
||||
@@ -160,10 +175,11 @@ export function DmsCustomerSelector({ bodyshop, jobid, rrOpenRoLimit = false, on
|
||||
}
|
||||
|
||||
if (dmsType === "rr") {
|
||||
wsssocket.emit("rr-selected-customer", { jobId: jobid, custNo: String(selectedCustomer) }, (ack) => {
|
||||
// Keep the selector open; server will raise rr-cashiering-required
|
||||
wsssocket.emit("rr-selected-customer", { jobId: jobid, create: true }, (ack) => {
|
||||
if (ack?.ok) {
|
||||
setOpen(false);
|
||||
setSelectedCustomer(null);
|
||||
message.success(t("dms.messages.customerCreated"));
|
||||
// Keep dialog open; cashiering banner will appear via `rr-cashiering-required`
|
||||
} else if (ack?.error) {
|
||||
message.error(ack.error);
|
||||
}
|
||||
@@ -200,10 +216,10 @@ export function DmsCustomerSelector({ bodyshop, jobid, rrOpenRoLimit = false, on
|
||||
if (dmsType === "rr" && rrHasVinOwner) return;
|
||||
|
||||
if (dmsType === "rr") {
|
||||
// Keep open; server will raise rr-cashiering-required
|
||||
wsssocket.emit("rr-selected-customer", { jobId: jobid, create: true }, (ack) => {
|
||||
if (ack?.ok) {
|
||||
if (ack.custNo) setSelectedCustomer(String(ack.custNo));
|
||||
setOpen(false);
|
||||
message.success(t("dms.messages.customerCreated"));
|
||||
} else if (ack?.error) {
|
||||
message.error(ack.error);
|
||||
@@ -388,6 +404,31 @@ export function DmsCustomerSelector({ bodyshop, jobid, rrOpenRoLimit = false, on
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* NEW: Cashiering required banner */}
|
||||
{dmsType === "rr" && rrCashierPending && (
|
||||
<Alert
|
||||
type="info"
|
||||
showIcon
|
||||
message="Complete cashiering in Reynolds"
|
||||
description={
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: 8 }}>
|
||||
<div>
|
||||
We created the Repair Order in Reynolds. Please complete the cashiering/closeout steps in
|
||||
Reynolds. When done, click <strong>Finished/Close</strong> to finalize and mark this export as
|
||||
complete.
|
||||
</div>
|
||||
<div>
|
||||
<Space>
|
||||
<Button type="primary" onClick={onRrCashierFinished}>
|
||||
Finished / Close
|
||||
</Button>
|
||||
</Space>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
|
||||
<Button onClick={onUseSelected} disabled={!selectedCustomer || (dmsType === "rr" && rrOpenRoLimit)}>
|
||||
{t("jobs.actions.dms.useselected")}
|
||||
@@ -405,7 +446,7 @@ export function DmsCustomerSelector({ bodyshop, jobid, rrOpenRoLimit = false, on
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* NEW: VIN ownership enforced with Refresh */}
|
||||
{/* VIN ownership enforced with Refresh */}
|
||||
{dmsType === "rr" && rrHasVinOwner && (
|
||||
<Alert
|
||||
type="warning"
|
||||
|
||||
Reference in New Issue
Block a user