Skip to content

Commit

Permalink
fix: refresh group list after adding group (#1349)
Browse files Browse the repository at this point in the history
fix: Invalidate groups query after new members are invited
  • Loading branch information
marlonkeating authored Nov 22, 2024
1 parent 5d259ea commit 3bb7650
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/PeopleManagement/CreateGroupModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useCallback, useState, useEffect } from 'react';
import { logError } from '@edx/frontend-platform/logging';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { useQueryClient } from '@tanstack/react-query';
import { useIntl } from '@edx/frontend-platform/i18n';
import { snakeCaseObject } from '@edx/frontend-platform/utils';
import {
Expand All @@ -10,6 +11,7 @@ import {
import LmsApiService from '../../data/services/LmsApiService';
import SystemErrorAlertModal from '../learner-credit-management/cards/assignment-allocation-status-modals/SystemErrorAlertModal';
import CreateGroupModalContent from './CreateGroupModalContent';
import { learnerCreditManagementQueryKeys } from '../learner-credit-management/data';

const CreateGroupModal = ({
isModalOpen,
Expand All @@ -27,6 +29,7 @@ const CreateGroupModal = ({
closeModal();
setCreateButtonState('default');
};
const queryClient = useQueryClient();

const handleCreateGroup = async () => {
setCreateButtonState('pending');
Expand All @@ -49,6 +52,9 @@ const CreateGroupModal = ({
learnerEmails,
});
await LmsApiService.inviteEnterpriseLearnersToGroup(groupCreationResponse.data.uuid, requestBody);
queryClient.invalidateQueries({
queryKey: learnerCreditManagementQueryKeys.group(enterpriseUUID),
});
setCreateButtonState('complete');
handleCloseCreateGroupModal();
} catch (err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const subsEnterpriseSubsidiesContextValue = {
isLoading: false,
};

jest.mock('@tanstack/react-query', () => ({
...jest.requireActual('@tanstack/react-query'),
useQueryClient: jest.fn(),
}));

jest.mock('../../learner-credit-management/data', () => ({
...jest.requireActual('../../learner-credit-management/data'),
useAllEnterpriseGroups: jest.fn(),
Expand Down

0 comments on commit 3bb7650

Please sign in to comment.