Skip to content

Commit b15aa3d

Browse files
arbrandesclaude
andcommitted
fix: remove redundant manual refetch on unenroll
The useUnenrollFromCourse mutation already calls invalidateQueries on success, which triggers a refetch automatically. The manual refetch() call in closeAndRefresh caused the API to be called twice. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7c82d40 commit b15aa3d

2 files changed

Lines changed: 1 addition & 19 deletions

File tree

src/containers/UnenrollConfirmModal/hooks/index.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22

33
import { StrictDict } from '@src/utils';
44

5-
import { useInitializeLearnerHome } from '@src/data/hooks';
65
import { useUnenrollReasons } from './reasons';
76
import * as module from '.';
87

@@ -20,7 +19,6 @@ export const useUnenrollData = ({ closeModal, cardId }) => {
2019
const [isConfirmed, setIsConfirmed] = module.state.confirmed(false);
2120
const confirm = () => setIsConfirmed(true);
2221
const reason = useUnenrollReasons({ cardId });
23-
const { refetch: refreshList } = useInitializeLearnerHome();
2422

2523
let modalState;
2624
if (isConfirmed) {
@@ -35,17 +33,13 @@ export const useUnenrollData = ({ closeModal, cardId }) => {
3533
setIsConfirmed(false);
3634
reason.handleClear();
3735
};
38-
const closeAndRefresh = () => {
39-
refreshList();
40-
close();
41-
};
4236

4337
return {
4438
isConfirmed,
4539
confirm,
4640
reason,
4741
close,
48-
closeAndRefresh,
42+
closeAndRefresh: close,
4943
modalState,
5044
};
5145
};

src/containers/UnenrollConfirmModal/hooks/index.test.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
import { MockUseState } from '@src/testUtils';
22

3-
import { useInitializeLearnerHome } from '@src/data/hooks';
4-
53
import * as reasons from './reasons';
64
import * as hooks from '.';
75

86
jest.mock('./reasons', () => ({
97
useUnenrollReasons: jest.fn(),
108
}));
119

12-
jest.mock('@src/data/hooks', () => ({
13-
useInitializeLearnerHome: jest.fn(),
14-
}));
15-
1610
const state = new MockUseState(hooks);
1711
const testValue = 'test-value';
18-
const mockRefreshList = jest.fn();
19-
useInitializeLearnerHome.mockReturnValue({ refetch: mockRefreshList });
2012
let out;
2113

2214
const mockReason = {
@@ -73,10 +65,6 @@ describe('UnenrollConfirmModal hooks', () => {
7365
expect(state.setState.confirmed).toHaveBeenCalledWith(false);
7466
expect(mockReason.handleClear).toHaveBeenCalled();
7567
});
76-
it('calls initializeApp api method', () => {
77-
out.closeAndRefresh();
78-
expect(mockRefreshList).toHaveBeenCalled();
79-
});
8068
});
8169
describe('modalState', () => {
8270
it('returns modalStates.finished if confirmed and submitted', () => {

0 commit comments

Comments
 (0)