feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Cache advisors for a week / allow them to refresh said cache

This commit is contained in:
Dave
2025-11-07 12:26:25 -05:00
parent b0b73f1af8
commit 9ce022b5e8
3 changed files with 152 additions and 20 deletions

View File

@@ -61,7 +61,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
const getAdvisorNumber = (a) => a?.advisorId;
const getAdvisorLabel = (a) => `${a?.firstName} ${a?.lastName}`?.trim();
const fetchRrAdvisors = () => {
const fetchRrAdvisors = (refresh = false) => {
if (!wsssocket) return;
setAdvLoading(true);
@@ -78,8 +78,8 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
wsssocket.once("rr-get-advisors:result", onResult);
// Emit with the correct event name + parse the ack shape
wsssocket.emit("rr-get-advisors", { departmentType: "B" }, (ack) => {
// Emit with refresh flag: server will bypass/rebuild cache when true
wsssocket.emit("rr-get-advisors", { departmentType: "B", refresh }, (ack) => {
if (ack?.ok) {
const list = ack.result ?? [];
setAdvisors(Array.isArray(list) ? list : []);
@@ -92,7 +92,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
};
useEffect(() => {
if (dms === "rr") fetchRrAdvisors();
if (dms === "rr") fetchRrAdvisors(false);
}, [dms, bodyshop?.id]);
const handlePayerSelect = (value, index) => {
@@ -217,7 +217,7 @@ export function DmsPostForm({ bodyshop, socket, job, logsRef }) {
{dms === "rr" && (
<Form.Item label=" " colon={false}>
<Button onClick={fetchRrAdvisors} icon={<ReloadOutlined />} loading={advLoading}>
<Button onClick={() => fetchRrAdvisors(true)} icon={<ReloadOutlined />} loading={advLoading}>
{t("general.actions.refresh")}
</Button>
</Form.Item>