From 878277faa698f7b13fc9be0584367932beeac620 Mon Sep 17 00:00:00 2001 From: Marlon Keating Date: Fri, 15 Nov 2024 03:25:43 +0000 Subject: [PATCH] fix: refresh group list after adding group --- src/components/PeopleManagement/CreateGroupModal.jsx | 6 ++++++ .../PeopleManagement/tests/PeopleManagementPage.test.jsx | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/components/PeopleManagement/CreateGroupModal.jsx b/src/components/PeopleManagement/CreateGroupModal.jsx index 6630c65cf..b4fcffb20 100644 --- a/src/components/PeopleManagement/CreateGroupModal.jsx +++ b/src/components/PeopleManagement/CreateGroupModal.jsx @@ -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 { @@ -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, @@ -27,6 +29,7 @@ const CreateGroupModal = ({ closeModal(); setCreateButtonState('default'); }; + const queryClient = useQueryClient(); const handleCreateGroup = async () => { setCreateButtonState('pending'); @@ -38,6 +41,9 @@ const CreateGroupModal = ({ try { groupCreationResponse = await LmsApiService.createEnterpriseGroup(options); + queryClient.invalidateQueries({ + queryKey: learnerCreditManagementQueryKeys.group(enterpriseUUID), + }); } catch (err) { logError(err); setCreateButtonState('error'); diff --git a/src/components/PeopleManagement/tests/PeopleManagementPage.test.jsx b/src/components/PeopleManagement/tests/PeopleManagementPage.test.jsx index 03f15c5f2..fb69b2f23 100644 --- a/src/components/PeopleManagement/tests/PeopleManagementPage.test.jsx +++ b/src/components/PeopleManagement/tests/PeopleManagementPage.test.jsx @@ -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(),