Skip to content

Commit

Permalink
fix: remove broken usage of useCache from getSubsidyRequestConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Sep 14, 2023
1 parent 4da552c commit 22f7c2c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ dist/

# emacs
*~
.projectile

# edx
.env.private
Expand Down
29 changes: 13 additions & 16 deletions src/components/subsidy-requests/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,21 +57,18 @@ export const useSubsidyRequestConfiguration = ({
}
}, [enterpriseId]);

const loadSubsidyRequestConfiguration = useCallback(
async ({ clearCacheEntry = false } = { clearCacheEntry: false }) => {
try {
const response = await EnterpriseAccessApiService.getSubsidyRequestConfiguration(
{ enterpriseId, clearCacheEntry },
);
const customerConfiguration = camelCaseObject(response.data);
setSubsidyRequestConfiguration(customerConfiguration);
} catch (error) {
logError(error);
throw error;
}
},
[enterpriseId],
);
const loadSubsidyRequestConfiguration = useCallback(async () => {
try {
const response = await EnterpriseAccessApiService.getSubsidyRequestConfiguration(
{ enterpriseId },
);
const customerConfiguration = camelCaseObject(response.data);
setSubsidyRequestConfiguration(customerConfiguration);
} catch (error) {
logError(error);
throw error;
}
}, [enterpriseId]);

useEffect(() => {
if (!enterpriseId) {
Expand Down Expand Up @@ -111,7 +108,7 @@ export const useSubsidyRequestConfiguration = ({
enterpriseId,
options,
);
loadSubsidyRequestConfiguration({ clearCacheEntry: true });
loadSubsidyRequestConfiguration();
} catch (err) {
logError(err);
throw err;
Expand Down
4 changes: 2 additions & 2 deletions src/components/subsidy-requests/data/tests/hooks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('useSubsidyRequestConfiguration', () => {
await waitForNextUpdate();

expect(EnterpriseAccessApiService.getSubsidyRequestConfiguration).toHaveBeenCalledWith(
{ clearCacheEntry: false, enterpriseId: TEST_ENTERPRISE_UUID },
{ enterpriseId: TEST_ENTERPRISE_UUID },
);
expect(result.current.subsidyRequestConfiguration).toEqual(
camelCaseObject(TEST_CONFIGURATION_RESPONSE.data),
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('useSubsidyRequestConfiguration', () => {
});

expect(EnterpriseAccessApiService.getSubsidyRequestConfiguration).toHaveBeenCalledWith(
{ clearCacheEntry: true, enterpriseId: TEST_ENTERPRISE_UUID },
{ enterpriseId: TEST_ENTERPRISE_UUID },
);
});

Expand Down
6 changes: 2 additions & 4 deletions src/data/services/EnterpriseAccessApiService.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ class EnterpriseAccessApiService {

static apiClient = getAuthenticatedHttpClient;

static getSubsidyRequestConfiguration({ enterpriseId, clearCacheEntry = false }) {
static getSubsidyRequestConfiguration({ enterpriseId }) {
const url = `${EnterpriseAccessApiService.baseUrl}/customer-configurations/${enterpriseId}/`;
return EnterpriseAccessApiService.apiClient({
useCache: configuration.USE_API_CACHE,
}).get(url, { clearCacheEntry });
return EnterpriseAccessApiService.apiClient().get(url);
}

static createSubsidyRequestConfiguration({
Expand Down
1 change: 0 additions & 1 deletion src/data/services/tests/EnterpriseAccessApiService.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ describe('EnterpriseAccessApiService', () => {
EnterpriseAccessApiService.getSubsidyRequestConfiguration({ enterpriseId: mockEnterpriseUUID });
expect(axios.get).toBeCalledWith(
`${enterpriseAccessBaseUrl}/api/v1/customer-configurations/${mockEnterpriseUUID}/`,
{ clearCacheEntry: false },
);
});

Expand Down

0 comments on commit 22f7c2c

Please sign in to comment.