From e90d5f4bce42b2c13b019e98fba62db44143e1d7 Mon Sep 17 00:00:00 2001 From: Caleb Alldrin Date: Tue, 24 Sep 2024 10:03:03 -0700 Subject: [PATCH] Show suggested status when contact has no status --- .../SuggestedContactStatus.test.tsx | 29 +++++++++++++++---- .../SuggestedContactStatus.tsx | 20 ++++++++----- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.test.tsx b/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.test.tsx index 9335cb70a..31e1fd2f2 100644 --- a/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.test.tsx +++ b/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.test.tsx @@ -37,7 +37,7 @@ const Components = ({ ContactStatus: { data: { contact: { - status: contactStatusQueryMock || StatusEnum.NeverContacted, + status: contactStatusQueryMock || null, }, }, }, @@ -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( { }, }); }); - - 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(); }); @@ -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( + , + ); + + await waitFor(() => { + expect(getByText("Change the contact's status to:")).toBeInTheDocument(); + }); + await waitFor(() => + expect(getByText('Initiate for Appointment')).toBeInTheDocument(), + ); + }); }); diff --git a/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.tsx b/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.tsx index 8b8011d3f..237bd7b96 100644 --- a/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.tsx +++ b/src/components/Task/Modal/Form/Inputs/SuggestedContactStatus/SuggestedContactStatus.tsx @@ -50,17 +50,21 @@ export const SuggestedContactStatus: React.FC = ({ 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 ? (