Skip to content

Commit

Permalink
Merge pull request #14631 from transcom/B-20536-INT
Browse files Browse the repository at this point in the history
B-20536-INT queue assignment move history tweaks
  • Loading branch information
paulstonebraker authored Jan 24, 2025
2 parents ccdf409 + cf032ea commit 42ce655
Show file tree
Hide file tree
Showing 8 changed files with 46 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 @@ -153,4 +153,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 @@ -11,6 +11,9 @@ describe('When given a move that has been assigned', () => {
changedValues: {
sc_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
sc_assigned_id: null,
},
context: [{ assigned_office_user_last_name: 'Daniels', assigned_office_user_first_name: 'Jayden' }],
};

Expand All @@ -36,6 +39,7 @@ describe('When given a move that has been assigned', () => {
});
it('task ordering officer', () => {
historyRecord.changedValues = { too_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137' };
historyRecord.oldValues = { too_assigned_id: null };
historyRecord.context = [
{ assigned_office_user_last_name: 'Robinson', assigned_office_user_first_name: 'Brian' },
];
Expand All @@ -48,6 +52,7 @@ describe('When given a move that has been assigned', () => {
});
it('task invoicing officer', () => {
historyRecord.changedValues = { tio_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137' };
historyRecord.oldValues = { tio_assigned_id: null };
historyRecord.context = [{ assigned_office_user_last_name: 'Luvu', assigned_office_user_first_name: 'Frankie' }];

const template = getTemplate(historyRecord);
Expand Down
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
9 changes: 9 additions & 0 deletions src/utils/formatters.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,9 @@ describe('formatAssignedOfficeUserFromContext', () => {
changedValues: {
sc_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
sc_assigned_id: null,
},
context: [{ assigned_office_user_last_name: 'Daniels', assigned_office_user_first_name: 'Jayden' }],
};

Expand All @@ -370,6 +373,9 @@ describe('formatAssignedOfficeUserFromContext', () => {
changedValues: {
too_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
too_assigned_id: null,
},
context: [{ assigned_office_user_last_name: 'McLaurin', assigned_office_user_first_name: 'Terry' }],
};

Expand All @@ -385,6 +391,9 @@ describe('formatAssignedOfficeUserFromContext', () => {
changedValues: {
tio_assigned_id: 'fb625e3c-067c-49d7-8fd9-88ef040e6137',
},
oldValues: {
tio_assigned_id: null,
},
context: [{ assigned_office_user_last_name: 'Robinson', assigned_office_user_first_name: 'Brian' }],
};

Expand Down

0 comments on commit 42ce655

Please sign in to comment.