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

MPDX-8263 Suggested Contact Show #1092

Merged
merged 1 commit into from
Sep 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Components = ({
ContactStatus: {
data: {
contact: {
status: contactStatusQueryMock || StatusEnum.NeverContacted,
status: contactStatusQueryMock || null,
},
},
},
Expand Down Expand Up @@ -105,7 +105,7 @@ describe('SuggestedContactStatus', () => {
});

it('renders suggested status when single contact and checks contact status with gql call', async () => {
const { getByText, findByText } = render(
const { getByText } = render(
<Components
suggestedContactStatus={StatusEnum.ContactForAppointment}
contactIds={['contact-1']}
Expand All @@ -122,10 +122,9 @@ describe('SuggestedContactStatus', () => {
},
});
});

expect(
await findByText("Change the contact's status to:"),
).toBeInTheDocument();
await waitFor(() => {
expect(getByText("Change the contact's status to:")).toBeInTheDocument();
});

expect(getByText('Initiate for Appointment')).toBeInTheDocument();
});
Expand All @@ -150,4 +149,22 @@ describe('SuggestedContactStatus', () => {
expect(getByText('Initiate for Appointment')).toBeInTheDocument();
});
});

it('renders suggested status when the contact has no status', async () => {
const { getByText } = render(
<Components
suggestedContactStatus={StatusEnum.ContactForAppointment}
contactIds={['contact-1']}
contactStatus={null}
contactStatusQueryMock={null}
/>,
);

await waitFor(() => {
expect(getByText("Change the contact's status to:")).toBeInTheDocument();
});
await waitFor(() =>
expect(getByText('Initiate for Appointment')).toBeInTheDocument(),
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,21 @@ export const SuggestedContactStatus: React.FC<SuggestedContactStatusProps> = ({
contactStatus || data?.contact.status;

const shouldRenderContactSuggestion: boolean = useMemo(() => {
if (!currentContactStatus) {
return false;
}
// Hide suggestedStatus if the suggested status is the current status
if (suggestedContactStatus === currentContactStatus) {
return false;
}
const disabledStatuses: StatusEnum[] = getContactStatusesByPhase(
PhaseEnum.PartnerCare,
contactStatuses,
).map((s) => s.id);
return !disabledStatuses.includes(currentContactStatus);

if (currentContactStatus) {
const disabledStatuses: StatusEnum[] = getContactStatusesByPhase(
PhaseEnum.PartnerCare,
contactStatuses,
).map((s) => s.id);
// Hide suggestedStatus if the suggested status is a partner care status, otherwise, show it
return !disabledStatuses.includes(currentContactStatus);
}
// Show suggestedStatus if the contact has no status
return true;
}, [contactStatuses, currentContactStatus]);

return suggestedContactStatus && shouldRenderContactSuggestion ? (
Expand Down
Loading