From 11cf3f9d219bad2a4e4079c520238c3cdbc26beb Mon Sep 17 00:00:00 2001 From: Troy Sankey Date: Wed, 14 Feb 2024 18:46:50 -0800 Subject: [PATCH] fix: course about URL should use course key, not course run key. When the spent table was first implemented, it utilized the Analytics API to fetch enrollments, and that data source contained a course key field. However, when we switched over to real-time fetching of redemptions via the transaction list API for assignable budgets, we erroneously treated the `content_key` field as a course key, breaking the course about page link in the spent table. The following two PRs implment a `parent_content_key` field in the transaction list API, which we can now utilize for the real-time spent table implmentation: * https://github.com/openedx/openedx-ledger/pull/60 * https://github.com/openedx/enterprise-subsidy/pull/209 ENT-8389 --- .../SpendTableEnrollmentDetails.jsx | 2 +- .../hooks/tests/useBudgetRedemptions.test.jsx | 18 ++++++++++----- .../learner-credit-management/data/utils.js | 22 ++++++++++++++----- 3 files changed, 30 insertions(+), 12 deletions(-) diff --git a/src/components/learner-credit-management/SpendTableEnrollmentDetails.jsx b/src/components/learner-credit-management/SpendTableEnrollmentDetails.jsx index e4347ca1a8..7173ec0077 100644 --- a/src/components/learner-credit-management/SpendTableEnrollmentDetails.jsx +++ b/src/components/learner-credit-management/SpendTableEnrollmentDetails.jsx @@ -28,7 +28,7 @@ const SpendTableEnrollmentDetailsContents = ({ fulfillmentIdentifier={row.original.fulfillmentIdentifier} />
- {enableLearnerPortal ? ( + {(enableLearnerPortal && row.original.courseKey) ? ( { } const mockExpectedResultsObj = isTopDownAssignmentEnabled ? [{ - courseListPrice: 10, + courseListPrice: 15, + courseKey, courseTitle, userEmail, }] : camelCaseObject(mockOfferEnrollments); diff --git a/src/components/learner-credit-management/data/utils.js b/src/components/learner-credit-management/data/utils.js index a01631bcac..9f35a3ed05 100644 --- a/src/components/learner-credit-management/data/utils.js +++ b/src/components/learner-credit-management/data/utils.js @@ -81,13 +81,14 @@ export const transformSubsidySummary = (subsidySummary) => { }; /** - * Transforms enrollment data from analytics api to fields for display - * in learner credit allocation table. - * A uuid is added to each enrollment to be used as a key for the table. + * Transforms enrollment data from analytics api to fields for display in learner credit spent table. + * + * Notes: + * * A uuid is synthesized for each enrollment to be used as a key for the table. * * @param {array} results List of raw enrollment results from API. * - * @returns List of transformed results for display in table. + * @returns List of transformed results for display in spent table. */ export const transformUtilizationTableResults = results => results.map(result => ({ created: result.created, @@ -100,6 +101,16 @@ export const transformUtilizationTableResults = results => results.map(result => courseKey: result.courseKey, })); +/** + * Transforms redemptions data from transaction list API to fields for display in learner credit spent table. + * + * Notes: + * * This supports the "real-time" spent table implementation. + * + * @param {array} results List of raw enrollment results from API. + * + * @returns List of transformed results for display in spent table. + */ export const transformUtilizationTableSubsidyTransactionResults = results => results.map(result => ({ created: result.created, enrollmentDate: result.created, @@ -109,7 +120,8 @@ export const transformUtilizationTableSubsidyTransactionResults = results => res courseTitle: result.contentTitle, courseListPrice: result.unit === 'usd_cents' ? -1 * (result.quantity / 100) : -1 * results.quantity, uuid: result.uuid, - courseKey: result.contentKey, + // In the transaction list response, `parent_content_key` is the course key, and `content_key` is the course run key. + courseKey: result.parentContentKey, })); /**