Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use correct listPrice data #884

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
* isPolicyRedemptionEnabled,
* redeemabilityPerContentKey,
* redeemableSubsidyAccessPolicy,
* missingSubsidyAccessPolicyReason
* missingSubsidyAccessPolicyReason,
* hasSuccessfulRedemption,
* listPrice,
* }
*/
const checkRedemptionEligibility = async ({ queryKey }) => {
Expand All @@ -548,6 +550,7 @@
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 @@
redeemableSubsidyAccessPolicy,
missingSubsidyAccessPolicyReason,
hasSuccessfulRedemption,
listPrice,
};
};

Expand All @@ -581,6 +585,9 @@
* - `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 Expand Up @@ -672,12 +679,12 @@
return camelCaseObject(fetchLicenseSubsidyResponse.data);
}
} catch (error) {
logError(error);

Check warning on line 682 in src/components/course/data/hooks.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/course/data/hooks.jsx#L682

Added line #L682 was not covered by tests
if (onSubscriptionLicenseForCourseValidationError) {
onSubscriptionLicenseForCourseValidationError(error);

Check warning on line 684 in src/components/course/data/hooks.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/course/data/hooks.jsx#L684

Added line #L684 was not covered by tests
}
}
return null;

Check warning on line 687 in src/components/course/data/hooks.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/course/data/hooks.jsx#L687

Added line #L687 was not covered by tests
};

const coursePrice = getCourseRunPrice({
Expand Down Expand Up @@ -844,5 +851,5 @@
const learnerContentAssignmentsArray = redeemableLCPolicies.flatMap(item => item?.learnerContentAssignments || []);
if (!learnerContentAssignmentsArray) { return false; }

return learnerContentAssignmentsArray.some(assignment => assignment?.contentKey === courseKey);

Check warning on line 854 in src/components/course/data/hooks.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/course/data/hooks.jsx#L854

Added line #L854 was not covered by tests
};
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
Loading