From f0f818962f7eb0270e71bad1dfeb614fe02f7113 Mon Sep 17 00:00:00 2001 From: Alex Dusenbery Date: Thu, 14 Sep 2023 14:50:59 -0400 Subject: [PATCH] fix: remove broken usage of useCache from getSubsidyRequestConfiguration --- .gitignore | 1 + src/components/subsidy-requests/data/hooks.js | 29 +++++++++---------- .../subsidy-requests/data/tests/hooks.test.js | 4 +-- .../services/EnterpriseAccessApiService.js | 6 ++-- .../tests/EnterpriseAccessApiService.test.js | 1 - 5 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 2f81fc6ff0..32335845d2 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ dist/ # emacs *~ +.projectile # edx .env.private diff --git a/src/components/subsidy-requests/data/hooks.js b/src/components/subsidy-requests/data/hooks.js index d0391eb389..7eeab49392 100644 --- a/src/components/subsidy-requests/data/hooks.js +++ b/src/components/subsidy-requests/data/hooks.js @@ -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) { @@ -111,7 +108,7 @@ export const useSubsidyRequestConfiguration = ({ enterpriseId, options, ); - loadSubsidyRequestConfiguration({ clearCacheEntry: true }); + loadSubsidyRequestConfiguration(); } catch (err) { logError(err); throw err; diff --git a/src/components/subsidy-requests/data/tests/hooks.test.js b/src/components/subsidy-requests/data/tests/hooks.test.js index 435bb1e26b..448025e8e0 100644 --- a/src/components/subsidy-requests/data/tests/hooks.test.js +++ b/src/components/subsidy-requests/data/tests/hooks.test.js @@ -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), @@ -230,7 +230,7 @@ describe('useSubsidyRequestConfiguration', () => { }); expect(EnterpriseAccessApiService.getSubsidyRequestConfiguration).toHaveBeenCalledWith( - { clearCacheEntry: true, enterpriseId: TEST_ENTERPRISE_UUID }, + { enterpriseId: TEST_ENTERPRISE_UUID }, ); }); diff --git a/src/data/services/EnterpriseAccessApiService.js b/src/data/services/EnterpriseAccessApiService.js index 98edbbbefd..380428686e 100644 --- a/src/data/services/EnterpriseAccessApiService.js +++ b/src/data/services/EnterpriseAccessApiService.js @@ -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({ diff --git a/src/data/services/tests/EnterpriseAccessApiService.test.js b/src/data/services/tests/EnterpriseAccessApiService.test.js index e6e21b833c..485bf7db90 100644 --- a/src/data/services/tests/EnterpriseAccessApiService.test.js +++ b/src/data/services/tests/EnterpriseAccessApiService.test.js @@ -103,7 +103,6 @@ describe('EnterpriseAccessApiService', () => { EnterpriseAccessApiService.getSubsidyRequestConfiguration({ enterpriseId: mockEnterpriseUUID }); expect(axios.get).toBeCalledWith( `${enterpriseAccessBaseUrl}/api/v1/customer-configurations/${mockEnterpriseUUID}/`, - { clearCacheEntry: false }, ); });