Skip to content

Commit

Permalink
fix: don't show groups cards zero state while groups data is loading (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonkeating authored Jan 14, 2025
1 parent 825bc69 commit 598996b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/components/PeopleManagement/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { Helmet } from 'react-helmet';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
import { ActionRow, Button, useToggle } from '@openedx/paragon';
import {
ActionRow,
Button,
Skeleton,
useToggle,
} from '@openedx/paragon';
import { Add } from '@openedx/paragon/icons';

import Hero from '../Hero';
Expand All @@ -24,7 +29,7 @@ const PeopleManagementPage = ({ enterpriseId }) => {
});

const { enterpriseSubsidyTypes } = useContext(EnterpriseSubsidiesContext);
const { data } = useAllEnterpriseGroups(enterpriseId);
const { data, isLoading: isGroupsLoading } = useAllEnterpriseGroups(enterpriseId);

const hasLearnerCredit = enterpriseSubsidyTypes.includes(SUBSIDY_TYPES.budget);
const hasOtherSubsidyTypes = enterpriseSubsidyTypes.includes(SUBSIDY_TYPES.license)
Expand All @@ -40,6 +45,15 @@ const PeopleManagementPage = ({ enterpriseId }) => {
}
}, [data]);

let groupsCardSection = (<Skeleton height="20vh" />);
if (!isGroupsLoading) {
if (groups && groups.length > 0) {
groupsCardSection = (<GroupCardGrid groups={groups} />);
} else {
groupsCardSection = (<ZeroState />);
}
}

return (
<>
<Helmet title={PAGE_TITLE} />
Expand Down Expand Up @@ -85,11 +99,7 @@ const PeopleManagementPage = ({ enterpriseId }) => {
closeModal={closeModal}
/>
</ActionRow>
{groups && groups.length > 0 ? (
<GroupCardGrid groups={groups} />
) : (
<ZeroState />
)}
{groupsCardSection}
<h3 className="mt-3">
<FormattedMessage
id="adminPortal.peopleManagement.dataTable.title"
Expand Down

0 comments on commit 598996b

Please sign in to comment.