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: conditionally text rendering while exec-ed course enrollments #882

Merged
merged 2 commits into from
Dec 4, 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
13 changes: 11 additions & 2 deletions src/components/course/routes/ExternalCourseEnrollment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
import CourseSummaryCard from '../../executive-education-2u/components/CourseSummaryCard';
import RegistrationSummaryCard from '../../executive-education-2u/components/RegistrationSummaryCard';
import UserEnrollmentForm from '../../executive-education-2u/UserEnrollmentForm';
import { useExternalEnrollmentFailureReason, useMinimalCourseMetadata } from '../data/hooks';
import { useExternalEnrollmentFailureReason, useIsCourseAssigned, useMinimalCourseMetadata } from '../data/hooks';
import ErrorPageContent from '../../executive-education-2u/components/ErrorPageContent';
import { UserSubsidyContext } from '../../enterprise-user-subsidy';
import { features } from '../../../config';

const ExternalCourseEnrollment = () => {
const config = getConfig();
Expand All @@ -22,14 +24,19 @@
state: {
activeCourseRun,
courseEntitlementProductSku,
course,
},
userSubsidyApplicableToCourse,
hasSuccessfulRedemption,
externalCourseFormSubmissionError,
} = useContext(CourseContext);
const {
redeemableLearnerCreditPolicies,
} = useContext(UserSubsidyContext);
const {
enterpriseConfig: { authOrgId },
} = useContext(AppContext);
const isCourseAssigned = useIsCourseAssigned(redeemableLearnerCreditPolicies, course?.key);

const courseMetadata = useMinimalCourseMetadata();

Expand Down Expand Up @@ -106,7 +113,9 @@
</strong>
&nbsp; Please ensure that the course details below are correct and confirm using Learner
Credit with a &quot;Confirm registration&quot; button.
Your Learner Credit funds will be redeemed at this point.
{(features.FEATURE_ENABLE_TOP_DOWN_ASSIGNMENT && isCourseAssigned)
? 'Your learning administrator already allocated funds towards this registration.'

Check warning on line 117 in src/components/course/routes/ExternalCourseEnrollment.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/course/routes/ExternalCourseEnrollment.jsx#L117

Added line #L117 was not covered by tests
: 'Your Learner Credit funds will be redeemed at this point.'}
</p>
)}
<CourseSummaryCard courseMetadata={courseMetadata} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import React from 'react';
import { React, useContext } from 'react';
import { Container } from '@edx/paragon';

import { useExternalEnrollmentFailureReason, useMinimalCourseMetadata } from '../data/hooks';
import CourseSummaryCard from '../../executive-education-2u/components/CourseSummaryCard';
import EnrollmentCompletedSummaryCard from '../../executive-education-2u/components/EnrollmentCompletedSummaryCard';
import ErrorPageContent from '../../executive-education-2u/components/ErrorPageContent';
import { CourseContext } from '../CourseContextProvider';

const ExternalCourseEnrollmentConfirmation = () => {
const courseMetadata = useMinimalCourseMetadata();
const {
state: {
course,
},
} = useContext(CourseContext);
const {
failureReason,
failureMessage,
Expand All @@ -28,7 +34,7 @@ const ExternalCourseEnrollmentConfirmation = () => {
courseMetadata={courseMetadata}
enrollmentCompleted
/>
<EnrollmentCompletedSummaryCard />
<EnrollmentCompletedSummaryCard courseKey={course?.key} />
</Container>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import UserEnrollmentForm from '../../../executive-education-2u/UserEnrollmentFo
import ExternalCourseEnrollment from '../ExternalCourseEnrollment';
import { CourseContext } from '../../CourseContextProvider';
import { DISABLED_ENROLL_REASON_TYPES, LEARNER_CREDIT_SUBSIDY_TYPE } from '../../data/constants';
import { UserSubsidyContext } from '../../../enterprise-user-subsidy';

const mockHistoryPush = jest.fn();
jest.mock('react-router-dom', () => ({
Expand Down Expand Up @@ -74,12 +75,15 @@ const baseAppContextValue = {
const ExternalCourseEnrollmentWrapper = ({
courseContextValue = baseCourseContextValue,
appContextValue = baseAppContextValue,
initialUserSubsidyState = {},
}) => (
<IntlProvider locale="en">
<AppContext.Provider value={appContextValue}>
<CourseContext.Provider value={courseContextValue}>
<ExternalCourseEnrollment />
</CourseContext.Provider>
<UserSubsidyContext.Provider value={initialUserSubsidyState}>
<CourseContext.Provider value={courseContextValue}>
<ExternalCourseEnrollment />
</CourseContext.Provider>
</UserSubsidyContext.Provider>
</AppContext.Provider>
</IntlProvider>
);
Expand Down
Loading