diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/UpdateMTOShipmentAgent.module.scss b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/UpdateMTOShipmentAgent.module.scss
new file mode 100644
index 00000000000..f1d4df13283
--- /dev/null
+++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/UpdateMTOShipmentAgent.module.scss
@@ -0,0 +1,7 @@
+@import 'shared/styles/colors';
+
+.shipmentType {
+ display: block;
+ color: $base;
+ margin-bottom: 8px 0;
+}
diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx
index 72a1f7974a1..3789096e2db 100644
--- a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx
+++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.jsx
@@ -1,6 +1,9 @@
import React from 'react';
+import styles from './UpdateMTOShipmentAgent.module.scss';
+
import { formatMoveHistoryAgent } from 'utils/formatters';
+import fieldMappings from 'constants/MoveHistory/Database/FieldMappings';
import o from 'constants/MoveHistory/UIDisplay/Operations';
import a from 'constants/MoveHistory/Database/Actions';
import t from 'constants/MoveHistory/Database/Tables';
@@ -26,10 +29,34 @@ const formatChangedValues = (historyRecord) => {
return { ...historyRecord, changedValues: newChangedValues };
};
+const formatDeletedAgentRecord = (historyRecord) => {
+ const mtoShipmentLabel = getMtoShipmentLabel(historyRecord);
+ const historyLabel = `${mtoShipmentLabel.shipment_type} shipment #${mtoShipmentLabel.shipment_locator}`;
+ const agentTypeFieldName = historyRecord.oldValues.agent_type.toLowerCase();
+ const agentType = fieldMappings[agentTypeFieldName];
+ const agent = formatMoveHistoryAgent(historyRecord.oldValues)[agentTypeFieldName];
+
+ return (
+ <>
+
+ Deleted {agentType} on {historyLabel}
+
+
+ {agentType}: {agent}
+
+ >
+ );
+};
+
export default {
action: a.UPDATE,
eventName: o.updateMTOShipment,
tableName: t.mto_agents,
getEventNameDisplay: () => 'Updated shipment',
- getDetails: (historyRecord) => ,
+ getDetails: (historyRecord) => {
+ if (historyRecord.changedValues.deleted_at) {
+ return formatDeletedAgentRecord(historyRecord);
+ }
+ return ;
+ },
};
diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx
index bc2681fd996..c293dcc3c5d 100644
--- a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx
+++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/updateMTOShipmentAgent.test.jsx
@@ -41,6 +41,46 @@ describe('when given an mto shipment agents update with mto agents table history
},
context: [{ shipment_type: 'HHG', shipment_locator: 'RQ38D4-01', shipment_id_abbr: 'a1b2c' }],
},
+ DELETED_RECEIVING_AGENT: {
+ action: 'UPDATE',
+ eventName: 'updateMTOShipment',
+ tableName: 'mto_agents',
+ changedValues: {
+ deleted_at: '2025-01-21T15:39:24.890356+00:00',
+ email: null,
+ first_name: null,
+ last_name: null,
+ phone: null,
+ },
+ oldValues: {
+ agent_type: 'RECEIVING_AGENT',
+ email: 'john.smith@email.com',
+ first_name: 'John',
+ last_name: 'Smith',
+ phone: '555-765-4321',
+ },
+ context: [{ shipment_type: 'HHG', shipment_locator: 'RQ38D4-01', shipment_id_abbr: 'a1b2c' }],
+ },
+ DELETED_RELEASING_AGENT: {
+ action: 'UPDATE',
+ eventName: 'updateMTOShipment',
+ tableName: 'mto_agents',
+ changedValues: {
+ deleted_at: '2025-01-21T16:39:24.890356+00:00',
+ email: null,
+ first_name: null,
+ last_name: null,
+ phone: null,
+ },
+ oldValues: {
+ agent_type: 'RELEASING_AGENT',
+ email: 'jane.smith@email.com',
+ first_name: 'Jane',
+ last_name: 'Smith',
+ phone: '555-123-4567',
+ },
+ context: [{ shipment_type: 'NTS', shipment_locator: 'RQ38D4-01', shipment_id_abbr: 'a1b2c' }],
+ },
};
describe('when agent type is Releasing', () => {
@@ -75,7 +115,7 @@ describe('when given an mto shipment agents update with mto agents table history
expect(screen.getAllByText('HHG shipment #RQ38D4-01'));
});
- it('it displays the proper labeled details for the given releasing agent', () => {
+ it('it displays the proper labeled details for the given receiving agent', () => {
const template = getTemplate(historyRecord.RECEIVE);
render(template.getDetails(historyRecord.RECEIVE));
@@ -83,4 +123,22 @@ describe('when given an mto shipment agents update with mto agents table history
expect(screen.getByText(': Nancy Drew, 555-555-5555, nancy@email.com')).toBeInTheDocument();
});
});
+
+ describe('when agent is deleted', () => {
+ it('displays deleted receiving agent', () => {
+ const template = getTemplate(historyRecord.DELETED_RECEIVING_AGENT);
+ render(template.getDetails(historyRecord.DELETED_RECEIVING_AGENT));
+ expect(screen.getByText('Deleted Receiving agent on HHG shipment #RQ38D4-01')).toBeInTheDocument();
+ expect(screen.getByText('Receiving agent')).toBeInTheDocument();
+ expect(screen.getByText(': John Smith, 555-765-4321, john.smith@email.com')).toBeInTheDocument();
+ });
+
+ it('displays deleted releasing agent', () => {
+ const template = getTemplate(historyRecord.DELETED_RELEASING_AGENT);
+ render(template.getDetails(historyRecord.DELETED_RELEASING_AGENT));
+ expect(screen.getByText('Deleted Releasing agent on NTS shipment #RQ38D4-01')).toBeInTheDocument();
+ expect(screen.getByText('Releasing agent')).toBeInTheDocument();
+ expect(screen.getByText(': Jane Smith, 555-123-4567, jane.smith@email.com')).toBeInTheDocument();
+ });
+ });
});