diff --git a/src/components/learner-credit-management/members-tab/GroupMembersCsvDownloadTableAction.jsx b/src/components/learner-credit-management/members-tab/GroupMembersCsvDownloadTableAction.jsx
index 9d4ea6ce1b..87cf598e65 100644
--- a/src/components/learner-credit-management/members-tab/GroupMembersCsvDownloadTableAction.jsx
+++ b/src/components/learner-credit-management/members-tab/GroupMembersCsvDownloadTableAction.jsx
@@ -11,6 +11,8 @@ import { useBudgetId, useSubsidyAccessPolicy } from '../data';
const GroupMembersCsvDownloadTableAction = ({
tableInstance,
}) => {
+ const selectedEmails = Object.keys(tableInstance.state.selectedRowIds);
+ const selectedEmailCount = selectedEmails.length;
const [alertModalOpen, setAlertModalOpen] = useState(false);
const [alertModalExc, setAlertModalException] = useState('');
const { subsidyAccessPolicyId } = useBudgetId();
@@ -53,6 +55,7 @@ const GroupMembersCsvDownloadTableAction = ({
EnterpriseAccessApiService.fetchSubsidyHydratedGroupMembersData(
subsidyAccessPolicyId,
options,
+ selectedEmails,
).then(response => {
// download CSV
const blob = new Blob([response.data], {
@@ -96,7 +99,7 @@ const GroupMembersCsvDownloadTableAction = ({
className="border rounded-0 border-dark-500"
disabled={tableInstance.itemCount === 0}
>
- Download all ({tableInstance.itemCount})
+ Download {selectedEmailCount > 0 ? `(${selectedEmailCount})` : `all (${tableInstance.itemCount})`}
>
);
@@ -118,6 +121,7 @@ GroupMembersCsvDownloadTableAction.propTypes = {
id: PropTypes.string,
desc: PropTypes.bool,
})),
+ selectedRowIds: PropTypes.shape(),
}),
}),
};
diff --git a/src/components/learner-credit-management/members-tab/LearnerCreditGroupMembersTable.jsx b/src/components/learner-credit-management/members-tab/LearnerCreditGroupMembersTable.jsx
index 79827c58d8..eab091f509 100644
--- a/src/components/learner-credit-management/members-tab/LearnerCreditGroupMembersTable.jsx
+++ b/src/components/learner-credit-management/members-tab/LearnerCreditGroupMembersTable.jsx
@@ -123,6 +123,7 @@ const LearnerCreditGroupMembersTable = ({
setRefresh={setRefresh}
groupUuid={groupUuid}
/>,
+ ,
]}
additionalColumns={[
{
diff --git a/src/components/learner-credit-management/members-tab/tests/MembersTab.test.jsx b/src/components/learner-credit-management/members-tab/tests/MembersTab.test.jsx
index d03f3ea909..65d0418775 100644
--- a/src/components/learner-credit-management/members-tab/tests/MembersTab.test.jsx
+++ b/src/components/learner-credit-management/members-tab/tests/MembersTab.test.jsx
@@ -713,11 +713,16 @@ describe('', () => {
renderWithRouter();
userEvent.type(screen.getByText('Search by member details'), 'foobar');
userEvent.click(screen.getByTestId('members-table-enrollments-column-header'));
+
const removeToggle = screen.getByTestId('show-removed-toggle');
userEvent.click(removeToggle);
- const downloadButton = screen.getByText('Download all (1)');
+ const toggleAllRowsSelected = screen.getByTitle('Toggle All Current Page Rows Selected');
+ userEvent.click(toggleAllRowsSelected);
+
+ const downloadButton = screen.getByText('Download (1)');
expect(downloadButton).toBeInTheDocument();
+
userEvent.click(downloadButton);
expect(EnterpriseAccessApiService.fetchSubsidyHydratedGroupMembersData).toHaveBeenCalledWith(
mockAssignableSubsidyAccessPolicy.uuid,
@@ -730,6 +735,7 @@ describe('', () => {
show_removed: true,
is_reversed: true,
},
+ ['foobar@test.com'],
);
});
});
diff --git a/src/data/services/EnterpriseAccessApiService.js b/src/data/services/EnterpriseAccessApiService.js
index fe58d1078e..ff3c9d5ea5 100644
--- a/src/data/services/EnterpriseAccessApiService.js
+++ b/src/data/services/EnterpriseAccessApiService.js
@@ -254,8 +254,11 @@ class EnterpriseAccessApiService {
return EnterpriseAccessApiService.apiClient().post(url, payload);
}
- static fetchSubsidyHydratedGroupMembersData(subsidyAccessPolicyUUID, options) {
+ static fetchSubsidyHydratedGroupMembersData(subsidyAccessPolicyUUID, options, selectedEmails) {
const queryParams = new URLSearchParams(options);
+ if (selectedEmails) {
+ selectedEmails.forEach((email) => queryParams.append('learners', email));
+ }
const subsidyHydratedGroupLearnersEndpoint = `${EnterpriseAccessApiService.baseUrl}/subsidy-access-policies/${subsidyAccessPolicyUUID}/group-members?${queryParams.toString()}`;
return EnterpriseAccessApiService.apiClient().get(subsidyHydratedGroupLearnersEndpoint);
}