Skip to content

Commit

Permalink
fix: refresh group list after adding group
Browse files Browse the repository at this point in the history
  • Loading branch information
marlonkeating committed Nov 15, 2024
1 parent 2306588 commit 878277f
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 @@ -38,6 +41,9 @@ const CreateGroupModal = ({

try {
groupCreationResponse = await LmsApiService.createEnterpriseGroup(options);
queryClient.invalidateQueries({
queryKey: learnerCreditManagementQueryKeys.group(enterpriseUUID),
});
} catch (err) {
logError(err);
setCreateButtonState('error');
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 878277f

Please sign in to comment.