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

feat: updates group page to render more than 10 groups #1382

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/components/PeopleManagement/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const PeopleManagementPage = ({ enterpriseId }) => {

useEffect(() => {
if (data !== undefined) {
setGroups(data.results);
setGroups(data);
}
}, [data]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe('<PeopleManagementPage >', () => {
expect(screen.getByText("Once a group is created, you can track members' progress.")).toBeInTheDocument();
});
it('renders the PeopleManagementPage group card grid', () => {
useAllEnterpriseGroups.mockReturnValue({ data: { results: mockGroupsResponse } });
useAllEnterpriseGroups.mockReturnValue({ data: mockGroupsResponse });
const store = getMockStore(initialStoreState);
render(
<IntlProvider locale="en">
Expand All @@ -131,7 +131,7 @@ describe('<PeopleManagementPage >', () => {
expect(screen.getByText('4 members')).toBeInTheDocument();
});
it('renders the PeopleManagementPage group card grid with collapsible', async () => {
useAllEnterpriseGroups.mockReturnValue({ data: { results: mockMultipleGroupsResponse } });
useAllEnterpriseGroups.mockReturnValue({ data: mockMultipleGroupsResponse });
const store = getMockStore(initialStoreState);
render(
<IntlProvider locale="en">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useQuery } from '@tanstack/react-query';
import { camelCaseObject } from '@edx/frontend-platform/utils';

import { learnerCreditManagementQueryKeys } from '../constants';
import LmsApiService from '../../../../data/services/LmsApiService';
import { fetchPaginatedData } from '../../../../data/services/apiServiceUtils';

/**
* Retrieves all enterprise groups associated with the organization
Expand All @@ -11,14 +11,8 @@
* @returns The enterprise group object
*/
const getAllEnterpriseGroups = async ({ enterpriseId }) => {
const params = new URLSearchParams({
enterprise_uuids: enterpriseId,
group_type: 'flex',
page: 1,
});
const response = await LmsApiService.fetchAllEnterpriseGroups(params);
const enterpriseGroups = camelCaseObject(response.data);
return enterpriseGroups;
const { results } = await fetchPaginatedData(`${LmsApiService.enterpriseGroupListUrl}?enterprise_uuids${enterpriseId}?group_type=flex`);
return results;

Check warning on line 15 in src/components/learner-credit-management/data/hooks/useAllEnterpriseGroups.js

View check run for this annotation

Codecov / codecov/patch

src/components/learner-credit-management/data/hooks/useAllEnterpriseGroups.js#L14-L15

Added lines #L14 - L15 were not covered by tests
};

const useAllEnterpriseGroups = (enterpriseId, { queryOptions } = {}) => useQuery({
Expand Down
5 changes: 0 additions & 5 deletions src/data/services/LmsApiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,11 +449,6 @@ class LmsApiService {
return response;
};

static fetchAllEnterpriseGroups = async (options) => {
const groupsEndpoint = `${LmsApiService.enterpriseGroupListUrl}?${options.toString()}`;
return LmsApiService.apiClient().get(groupsEndpoint);
};

static fetchEnterpriseGroup = async (groupUuid) => {
const groupEndpoint = `${LmsApiService.enterpriseGroupListUrl}${groupUuid}/`;
return LmsApiService.apiClient().get(groupEndpoint);
Expand Down
Loading