Skip to content

Commit

Permalink
fix: use correct listPrice data
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveagent57 committed Dec 6, 2023
1 parent d77b948 commit f507bc4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/course/CoursePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ const CoursePage = () => {
],
);

const courseListPrice = subsidyAccessPolicyRedeemabilityData?.coursePrice
const courseListPrice = subsidyAccessPolicyRedeemabilityData?.listPrice
|| courseState?.activeCourseRun?.firstEnrollablePaidSeatPrice
|| getEntitlementPrice(courseState?.course?.entitlements);

Expand Down
9 changes: 8 additions & 1 deletion src/components/course/data/hooks.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,9 @@ export function useUserHasSubsidyRequestForCourse(courseKey) {
* isPolicyRedemptionEnabled,
* redeemabilityPerContentKey,
* redeemableSubsidyAccessPolicy,
* missingSubsidyAccessPolicyReason
* missingSubsidyAccessPolicyReason,
* hasSuccessfulRedemption,
* listPrice,
* }
*/
const checkRedemptionEligibility = async ({ queryKey }) => {
Expand All @@ -548,6 +550,7 @@ const checkRedemptionEligibility = async ({ queryKey }) => {
const otherSubsidyAccessPolicy = transformedResponse.find(
r => r.redeemableSubsidyAccessPolicy,
)?.redeemableSubsidyAccessPolicy;
const listPrice = redeemabilityForActiveCourseRun?.listPrice?.usd;

const hasSuccessfulRedemption = transformedResponse.some(r => r.hasSuccessfulRedemption);

Expand All @@ -562,6 +565,7 @@ const checkRedemptionEligibility = async ({ queryKey }) => {
redeemableSubsidyAccessPolicy,
missingSubsidyAccessPolicyReason,
hasSuccessfulRedemption,
listPrice,
};
};

Expand All @@ -581,6 +585,9 @@ const checkRedemptionEligibility = async ({ queryKey }) => {
* - `redeemableSubsidyAccessPolicy`: The redeemable subsidy access policy, if any.
* - `redeemabilityPerContentKey`: An array of objects containing the redeemability status for each course run key.
* - `missingSubsidyAccessPolicyReason`: The reason why the subsidy access policy is not redeemable, if any.
* - `hasSuccessfulRedemption`: Whether a successful redemption for the active course run
* already exists for the requesting user.
* - `listPrice`: The list price (as a float) to display for the course.
*/
export const useCheckSubsidyAccessPolicyRedeemability = ({
courseRunKeys = [],
Expand Down
1 change: 1 addition & 0 deletions src/components/course/data/tests/hooks.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ describe('useCheckSubsidyAccessPolicyRedeemability', () => {
redeemabilityPerContentKey: mockCanRedeemData,
redeemableSubsidyAccessPolicy: mockRedeemableSubsidyAccessPolicy,
missingSubsidyAccessPolicyReason: undefined,
listPrice: mockCanRedeemForContentKey.list_price.usd,
}));
});
});
Expand Down
4 changes: 4 additions & 0 deletions src/components/course/tests/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ export const mockCanRedeemForContentKey = {
has_redeemed: false,
redemptions: [],
reasons: [],
list_price: {
usd: 99.0,
usd_cents: 9900,
},
};
export const mockCanRedeemData = [mockCanRedeemForContentKey];
export const mockSubscriptionLicense = {
Expand Down

0 comments on commit f507bc4

Please sign in to comment.