Skip to content

Commit

Permalink
fix: conditionally text rendering while exec-ed course enrollments (#882
Browse files Browse the repository at this point in the history
)

* fix: conditionally text rendering while exec-ed course enrollments

* fix: failing test cases
  • Loading branch information
jajjibhai008 authored Dec 4, 2023
1 parent 0949a3d commit faf83a5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
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 { CourseContext } from '../CourseContextProvider';
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 @@ const ExternalCourseEnrollment = () => {
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 @@ const ExternalCourseEnrollment = () => {
</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.'
: '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

0 comments on commit faf83a5

Please sign in to comment.