From 837e412cfd8e1c9c7e8e8bb339aa404cfc263261 Mon Sep 17 00:00:00 2001 From: katrinan029 Date: Mon, 9 Sep 2024 20:18:54 +0000 Subject: [PATCH] feat: add zero state for customer view headers --- .../CustomerIntegrations.jsx | 4 +++ .../CustomerPlanContainer.jsx | 30 ++++++++++++------- .../EnterpriseCustomerUsersTable.jsx | 5 ++++ .../tests/CustomerPlanContainer.test.jsx | 22 ++++++++++++++ .../tests/CustomerViewIntegrations.test.jsx | 16 ++++++++++ .../EnterpriseCustomerUsersTable.test.jsx | 20 +++++++++++++ 6 files changed, 86 insertions(+), 11 deletions(-) diff --git a/src/Configuration/Customers/CustomerDetailView/CustomerIntegrations.jsx b/src/Configuration/Customers/CustomerDetailView/CustomerIntegrations.jsx index 90543448b..e03488c19 100644 --- a/src/Configuration/Customers/CustomerDetailView/CustomerIntegrations.jsx +++ b/src/Configuration/Customers/CustomerDetailView/CustomerIntegrations.jsx @@ -16,6 +16,10 @@ const CustomerIntegrations = ({ integrationCount++; } + if (!integrationCount) { + return null; + } + return (
{(integrationCount > 0) && ( diff --git a/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx b/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx index 2edcbb6d1..872687491 100644 --- a/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx +++ b/src/Configuration/Customers/CustomerDetailView/CustomerPlanContainer.jsx @@ -30,23 +30,31 @@ const CustomerPlanContainer = ({ slug }) => { const renderInActiveSubscriptions = inactiveSubscriptions.map(subscription => ( )); + + const hasActivePlans = activePolicies.length > 0 || renderActiveSubscriptions.length > 0; + + if (!hasActivePlans) { + return null; + } + return (
{!isLoading ? (

Associated subsidy plans ({showInactive ? countOfAllPlans : countOfActivePlans})

- { - setShowInactive(prevState => !prevState); - }} - data-testid="show-removed-toggle" - > - Show inactive - + {(countOfAllPlans !== countOfActivePlans) && ( + { + setShowInactive(prevState => !prevState); + }} + data-testid="show-removed-toggle" + > + Show inactive + + )}

{renderActivePoliciesCard} diff --git a/src/Configuration/Customers/CustomerDetailView/EnterpriseCustomerUsersTable.jsx b/src/Configuration/Customers/CustomerDetailView/EnterpriseCustomerUsersTable.jsx index e9302971c..efb587479 100644 --- a/src/Configuration/Customers/CustomerDetailView/EnterpriseCustomerUsersTable.jsx +++ b/src/Configuration/Customers/CustomerDetailView/EnterpriseCustomerUsersTable.jsx @@ -10,6 +10,11 @@ const EnterpriseCustomerUsersTable = () => { enterpriseUsersTableData, fetchEnterpriseUsersData, } = useCustomerUsersTableData(id); + + if (!enterpriseUsersTableData.itemCount) { + return null; + } + return (

Associated users ({enterpriseUsersTableData.itemCount})

diff --git a/src/Configuration/Customers/CustomerDetailView/tests/CustomerPlanContainer.test.jsx b/src/Configuration/Customers/CustomerDetailView/tests/CustomerPlanContainer.test.jsx index a55a2103b..c7f4c87ab 100644 --- a/src/Configuration/Customers/CustomerDetailView/tests/CustomerPlanContainer.test.jsx +++ b/src/Configuration/Customers/CustomerDetailView/tests/CustomerPlanContainer.test.jsx @@ -99,4 +99,26 @@ describe('CustomerPlanContainer', () => { await waitFor(() => expect(screen.getByText('Associated subsidy plans (3)')).toBeInTheDocument()); expect(screen.getByText('Inactive')).toBeInTheDocument(); }); + it('does not render CustomerPlanContainer data', async () => { + getConfig.mockImplementation(() => ({ + ADMIN_PORTAL_BASE_URL: 'http://www.testportal.com', + ENTERPRISE_ACCESS_BASE_URL: 'http:www.enterprise-access.com', + LICENSE_MANAGER_URL: 'http:www.license-manager.com', + })); + useAllAssociatedPlans.mockReturnValue({ + isLoading: false, + activePolicies: [], + activeSubscriptions: [], + countOfActivePlans: 0, + countOfAllPlans: 0, + inactiveSubscriptions: [], + inactivePolicies: [], + }); + render( + + + , + ); + expect(screen.queryByText('Associated subsidy plans (0)')).not.toBeInTheDocument(); + }); }); diff --git a/src/Configuration/Customers/CustomerDetailView/tests/CustomerViewIntegrations.test.jsx b/src/Configuration/Customers/CustomerDetailView/tests/CustomerViewIntegrations.test.jsx index 0b825655d..05d6987fa 100644 --- a/src/Configuration/Customers/CustomerDetailView/tests/CustomerViewIntegrations.test.jsx +++ b/src/Configuration/Customers/CustomerDetailView/tests/CustomerViewIntegrations.test.jsx @@ -63,4 +63,20 @@ describe('CustomerViewIntegrations', () => { expect(screen.getByText('API')).toBeInTheDocument(); }); }); + it('does not render cards', async () => { + formatDate.mockReturnValue('September 15, 2024'); + render( + + + , + ); + await waitFor(() => { + expect(screen.queryByText('Associated integrations (0)')).not.toBeInTheDocument(); + }); + }); }); diff --git a/src/Configuration/Customers/CustomerDetailView/tests/EnterpriseCustomerUsersTable.test.jsx b/src/Configuration/Customers/CustomerDetailView/tests/EnterpriseCustomerUsersTable.test.jsx index 1848313a9..d9bc38dc2 100644 --- a/src/Configuration/Customers/CustomerDetailView/tests/EnterpriseCustomerUsersTable.test.jsx +++ b/src/Configuration/Customers/CustomerDetailView/tests/EnterpriseCustomerUsersTable.test.jsx @@ -80,4 +80,24 @@ describe('EnterpriseCustomerUsersTable', () => { }); }); }); + + it('does not render user table section', () => { + const emptyResults = { + isLoading: false, + enterpriseUsersTableData: { + itemCount: 0, + pageCount: 1, + results: [], + }, + fetchEnterpriseUsersData: mockFetchEnterpriseUsersData, + }; + useCustomerUsersTableData.mockReturnValue(emptyResults); + render( + + + , + ); + expect(screen.queryByText('Search user details')).not.toBeInTheDocument(); + expect(screen.queryByText('Associated users (0)')).not.toBeInTheDocument(); + }); });