Skip to content

Commit

Permalink
Merge pull request #994 from openedx/ea/ent-7216-2
Browse files Browse the repository at this point in the history
chore: specify learner_credit subsidy type in useEnterpriseOffers
  • Loading branch information
Emily Rosario-Aquin authored Jun 1, 2023
2 parents de062e8 + d363452 commit 313171a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/EnterpriseSubsidiesContext/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useEnterpriseOffers = ({ enablePortalLearnerCreditManagementScreen,
const fetchOffers = async () => {
try {
const [enterpriseSubsidyResponse, ecommerceApiResponse] = await Promise.all([
SubsidyApiService.getSubsidyByCustomerUUID(enterpriseId),
SubsidyApiService.getSubsidyByCustomerUUID(enterpriseId, { subsidyType: 'learner_credit' }),
EcommerceApiService.fetchEnterpriseOffers({
isCurrent: true,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ describe('useEnterpriseOffers', () => {

await waitForNextUpdate();

expect(SubsidyApiService.getSubsidyByCustomerUUID).toHaveBeenCalledWith(TEST_ENTERPRISE_UUID);
expect(SubsidyApiService.getSubsidyByCustomerUUID).toHaveBeenCalledWith(
TEST_ENTERPRISE_UUID,
{ subsidyType: 'learner_credit' },
);
expect(result.current).toEqual({
offers: mockOffers,
isLoading: false,
Expand Down Expand Up @@ -157,7 +160,10 @@ describe('useEnterpriseOffers', () => {

await waitForNextUpdate();

expect(SubsidyApiService.getSubsidyByCustomerUUID).toHaveBeenCalledWith(TEST_ENTERPRISE_UUID);
expect(SubsidyApiService.getSubsidyByCustomerUUID).toHaveBeenCalledWith(
TEST_ENTERPRISE_UUID,
{ subsidyType: 'learner_credit' },
);
expect(result.current).toEqual({
offers: mockOfferData,
isLoading: false,
Expand Down
3 changes: 2 additions & 1 deletion src/data/services/EnterpriseSubsidyApiService.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getAuthenticatedHttpClient } from '@edx/frontend-platform/auth';
import { snakeCaseObject } from '@edx/frontend-platform';

import { configuration } from '../../config';

Expand All @@ -10,7 +11,7 @@ class SubsidyApiService {
static getSubsidyByCustomerUUID(uuid, options = {}) {
const queryParams = new URLSearchParams({
enterprise_customer_uuid: uuid,
...options,
...snakeCaseObject(options),
});
const url = `${SubsidyApiService.baseUrl}/subsidies/?${queryParams.toString()}`;
return SubsidyApiService.apiClient({
Expand Down

0 comments on commit 313171a

Please sign in to comment.