Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B-20536-INT queue assignment move history tweaks #14631

Merged
merged 8 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
Loading