Skip to content

Commit

Permalink
merge from main
Browse files Browse the repository at this point in the history
  • Loading branch information
paulstonebraker committed Jan 21, 2025
2 parents 0bb2b26 + 221d441 commit 36814f3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 12 deletions.
3 changes: 3 additions & 0 deletions src/constants/MoveHistory/Database/FieldMappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,7 @@ export default {
assigned_sc: 'Counselor assigned',
assigned_too: 'Task ordering officer assigned',
assigned_tio: 'Task invoicing officer assigned',
re_assigned_sc: 'Counselor reassigned',
re_assigned_too: 'Task ordering officer reassigned',
re_assigned_tio: 'Task invoicing officer reassigned',
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export default {
eventName: o.updatePaymentRequestStatus,
tableName: t.moves,
getEventNameDisplay: () => 'Updated move',
getDetails: ({ changedValues }) => {
if (changedValues?.tio_assigned_id !== undefined) return <> Task Invoicing Officer Unassigned </>;
return <> - </>;
},
getDetails: ({ changedValues }) => (
<>
<div>Payment Requests Addressed</div>
{changedValues?.tio_assigned_id !== undefined ? <div>Task Invoicing Officer Unassigned</div> : null}
</>
),
};
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ describe('When given a completed services counseling for a move', () => {
expect(screen.getByText('Updated move')).toBeInTheDocument();
});

it('defaults to blank entry if TIO ID is not present in changedValues', () => {
it('displays default when TIO ID is not present', () => {
const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('-')).toBeInTheDocument();
expect(screen.getByText('Payment Requests Addressed')).toBeInTheDocument();
});

it('displays correct details when a TIO is unassigned', () => {
Expand All @@ -36,6 +36,7 @@ describe('When given a completed services counseling for a move', () => {
const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Payment Requests Addressed')).toBeInTheDocument();
expect(screen.getByText('Task Invoicing Officer Unassigned')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ export default {
return (
<>
<LabeledDetails historyRecord={historyRecord} />
{historyRecord.changedValues.too_assigned_id !== undefined ? <>Task Ordering Officer Unassigned</> : null}
{historyRecord?.changedValues?.too_assigned_id !== undefined ? (
<>
<div>Service Items Addressed</div>
<div>Task Ordering Officer Unassigned</div>
</>
) : null}
</>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe('when given a update service item status, update move history record',
const template = getTemplate(historyRecord);

render(template.getDetails(historyRecord));
expect(screen.getByText('Service Items Addressed')).toBeInTheDocument();
expect(screen.getByText('Task Ordering Officer Unassigned')).toBeInTheDocument();
});
});
18 changes: 13 additions & 5 deletions src/utils/formatters.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,16 +602,24 @@ export const constructSCOrderOconusFields = (values) => {
};

export const formatAssignedOfficeUserFromContext = (historyRecord) => {
const { changedValues, context } = historyRecord;
const { changedValues, context, oldValues } = historyRecord;
const newValues = {};
if (!context) return newValues;

const name = `${context[0].assigned_office_user_last_name}, ${context[0].assigned_office_user_first_name}`;

if (changedValues.sc_assigned_id) newValues.assigned_sc = name;
if (changedValues.too_assigned_id) newValues.assigned_too = name;
if (changedValues.tio_assigned_id) newValues.assigned_tio = name;

if (changedValues?.sc_assigned_id) {
if (oldValues.sc_assigned_id === null) newValues.assigned_sc = name;
if (oldValues.sc_assigned_id !== null) newValues.re_assigned_sc = name;
}
if (changedValues?.too_assigned_id) {
if (oldValues.too_assigned_id === null) newValues.assigned_too = name;
if (oldValues.too_assigned_id !== null) newValues.re_assigned_too = name;
}
if (changedValues?.tio_assigned_id) {
if (oldValues.tio_assigned_id === null) newValues.assigned_tio = name;
if (oldValues.tio_assigned_id !== null) newValues.re_assigned_tio = name;
}
return newValues;
};
/**
Expand Down

0 comments on commit 36814f3

Please sign in to comment.