From 06e8be618dbd5d5c39367acd365a38a5571fad76 Mon Sep 17 00:00:00 2001 From: pambecker Date: Fri, 20 Sep 2024 13:37:20 +0000 Subject: [PATCH] PPM H&AL work --- .../UpdateMTOShipment/patchMTOShipment.jsx | 29 +++++++++++++++++++ .../patchMTOShipment.test.jsx | 25 ++++++++++++++++ .../uploadAdditionalDocuments.jsx | 13 +++++++++ .../uploadAdditionalDocuments.test.jsx | 17 +++++++++++ .../MoveHistory/EventTemplates/index.js | 2 ++ .../MoveHistory/UIDisplay/Operations.js | 2 ++ 6 files changed, 88 insertions(+) create mode 100644 src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.jsx create mode 100644 src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.test.jsx create mode 100644 src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.jsx create mode 100644 src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.test.jsx diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.jsx b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.jsx new file mode 100644 index 00000000000..49a7a698c8a --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.jsx @@ -0,0 +1,29 @@ +import React from 'react'; + +import o from 'constants/MoveHistory/UIDisplay/Operations'; +import a from 'constants/MoveHistory/Database/Actions'; +import t from 'constants/MoveHistory/Database/Tables'; +import LabeledDetails from 'pages/Office/MoveHistory/LabeledDetails'; + +const formatChangedValues = (historyRecord) => { + let newChangedValues = { + ...historyRecord.changedValues, + }; + + if (historyRecord.context) { + newChangedValues = { + ...newChangedValues, + ...historyRecord.context[0], + }; + } + + return { ...historyRecord, changedValues: newChangedValues }; +}; + +export default { + action: a.UPDATE, + eventName: o.patchMove, + tableName: t.moves, + getEventNameDisplay: () => 'Updated move', + getDetails: (historyRecord) => , +}; diff --git a/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.test.jsx b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.test.jsx new file mode 100644 index 00000000000..37a0d4e1d72 --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment.test.jsx @@ -0,0 +1,25 @@ +import { render, screen } from '@testing-library/react'; + +import getTemplate from 'constants/MoveHistory/TemplateManager'; +import e from 'constants/MoveHistory/EventTemplates/UpdateMTOShipment/patchMTOShipment'; + +describe('when given a patch move record', () => { + const historyRecord = { + action: 'UPDATE', + eventName: 'patchMove', + tableName: 'moves', + changedValues: { closeout_office_name: 'PPPO Scott AFB - USAF' }, + }; + + it('correctly matches the patch move event', () => { + const template = getTemplate(historyRecord); + expect(template).toMatchObject(e); + }); + + it('displays the proper update order record', () => { + const template = getTemplate(historyRecord); + render(template.getDetails(historyRecord)); + expect(screen.getByText('Closeout office')).toBeInTheDocument(); + expect(screen.getByText(': PPPO Scott AFB - USAF')).toBeInTheDocument(); + }); +}); diff --git a/src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.jsx b/src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.jsx new file mode 100644 index 00000000000..b4bde01beb6 --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.jsx @@ -0,0 +1,13 @@ +import React from 'react'; + +import a from 'constants/MoveHistory/Database/Actions'; +import t from 'constants/MoveHistory/Database/Tables'; +import o from 'constants/MoveHistory/UIDisplay/Operations'; + +export default { + action: a.UPDATE, + eventName: o.uploadAdditionalDocuments, + tableName: t.moves, + getEventNameDisplay: () => 'Updated move', + getDetails: () => <>Uploaded additional document, +}; diff --git a/src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.test.jsx b/src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.test.jsx new file mode 100644 index 00000000000..0cf9a402eb7 --- /dev/null +++ b/src/constants/MoveHistory/EventTemplates/UploadAdditionalDocuments/uploadAdditionalDocuments.test.jsx @@ -0,0 +1,17 @@ +import { render, screen } from '@testing-library/react'; + +import getTemplate from 'constants/MoveHistory/TemplateManager'; + +describe('when customer uploads additional documents', () => { + const historyRecord = { + action: 'UPDATE', + eventName: 'uploadAdditionalDocuments', + tableName: 'moves', + }; + it('correctly matches the Upload additional documents event', () => { + const template = getTemplate(historyRecord); + + render(template.getDetails(historyRecord)); + expect(screen.getByText('Uploaded additional document')).toBeInTheDocument(); + }); +}); diff --git a/src/constants/MoveHistory/EventTemplates/index.js b/src/constants/MoveHistory/EventTemplates/index.js index 6898fc64f8e..ff71c3c73d8 100644 --- a/src/constants/MoveHistory/EventTemplates/index.js +++ b/src/constants/MoveHistory/EventTemplates/index.js @@ -95,3 +95,5 @@ export { default as updateAllowanceUpdateOrder } from './UpdateAllowances/update export { default as updateAllowanceUpdateMTOShipment } from './UpdateAllowances/updateAllowanceUpdateMTOShipment'; export { default as approveShipmentUpdateAllowances } from './ApproveShipment/approveShipmentUpdateAllowances'; export { default as updateOrderUpdateAllowances } from './UpdateOrders/updateOrderUpdateAllowances'; +export { default as patchMTOShipment } from './UpdateMTOShipment/patchMTOShipment'; +export { default as uploadAdditionalDocuments } from './UploadAdditionalDocuments/uploadAdditionalDocuments'; diff --git a/src/constants/MoveHistory/UIDisplay/Operations.js b/src/constants/MoveHistory/UIDisplay/Operations.js index 81f62ed79cd..707fefe9e52 100644 --- a/src/constants/MoveHistory/UIDisplay/Operations.js +++ b/src/constants/MoveHistory/UIDisplay/Operations.js @@ -58,4 +58,6 @@ export default { finishDocumentReview: 'finishDocumentReview', // ghc.yaml getMove: 'getMove', // ghc.yaml createSITExtension: 'createSITExtension', // prime.yaml + patchMove: 'patchMove', // internal.yaml + uploadAdditionalDocuments: 'uploadAdditionalDocuments', // internal.yaml };