Skip to content

Commit 0208323

Browse files
authored
Merge pull request #600 from topcoder-platform/TCA-1272_remove-dice-id-requirement
TCA-1272 move diceID required modal behind feature flag -> dev
2 parents 243cfe9 + 6e49713 commit 0208323

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

src-ts/tools/learn/certification-details/enroll-cta-btn/EnrollCtaBtn.tsx

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { FC, useCallback, useContext } from 'react'
1+
import { Dispatch, FC, SetStateAction, useCallback, useContext, useState } from 'react'
22
import { NavigateFunction, useNavigate } from 'react-router-dom'
33

44
import { Button, profileContext, ProfileContextData } from '../../../../lib'
55
import { getAuthenticateAndEnrollRoute, getTCACertificationEnrollPath } from '../../learn.routes'
6+
import { LearnConfig } from '../../learn-config'
7+
import { DiceModal } from '../../course-details/course-curriculum/dice-modal'
68

79
interface EnrollCtaBtnProps {
810
certification: string
@@ -11,9 +13,15 @@ interface EnrollCtaBtnProps {
1113
const EnrollCtaBtn: FC<EnrollCtaBtnProps> = (props: EnrollCtaBtnProps) => {
1214
const navigate: NavigateFunction = useNavigate()
1315
const { initialized: profileReady, profile }: ProfileContextData = useContext(profileContext)
16+
const [isDiceModalOpen, setIsDiceModalOpen]: [boolean, Dispatch<SetStateAction<boolean>>]
17+
= useState<boolean>(false)
1418

1519
const isLoggedIn: boolean = profileReady && !!profile
1620

21+
function onDiceModalClose(): void {
22+
setIsDiceModalOpen(false)
23+
}
24+
1725
/**
1826
* Handle user click on start course/resume/login button
1927
*/
@@ -29,8 +37,8 @@ const EnrollCtaBtn: FC<EnrollCtaBtnProps> = (props: EnrollCtaBtnProps) => {
2937

3038
// if the user is wipro and s/he hasn't set up DICE,
3139
// let the user know
32-
if (profile?.isWipro && !profile.diceEnabled) {
33-
// setIsDiceModalOpen(true)
40+
if (LearnConfig.REQUIRE_DICE_ID && profile?.isWipro && !profile.diceEnabled) {
41+
setIsDiceModalOpen(true)
3442
return
3543
}
3644

@@ -45,6 +53,11 @@ const EnrollCtaBtn: FC<EnrollCtaBtnProps> = (props: EnrollCtaBtnProps) => {
4553
label={isLoggedIn ? 'Enroll Now' : 'Log in to enroll'}
4654
onClick={handleEnrollClick}
4755
/>
56+
57+
<DiceModal
58+
isOpen={isDiceModalOpen}
59+
onClose={onDiceModalClose}
60+
/>
4861
</>
4962
)
5063
}

src-ts/tools/learn/course-details/course-curriculum/CourseCurriculum.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
getLessonPathFromCurrentLesson,
2222
LEARN_PATHS,
2323
} from '../../learn.routes'
24+
import { LearnConfig } from '../../learn-config'
2425

2526
import { CurriculumSummary } from './curriculum-summary'
2627
import { TcAcademyPolicyModal } from './tc-academy-policy-modal'
@@ -98,7 +99,11 @@ const CourseCurriculum: FC<CourseCurriculumProps> = (props: CourseCurriculumProp
9899

99100
// if the user is wipro and s/he hasn't set up DICE,
100101
// let the user know
101-
if (props.profile?.isWipro && !props.profile.diceEnabled) {
102+
if (
103+
LearnConfig.REQUIRE_DICE_ID
104+
&& props.profile?.isWipro
105+
&& !props.profile.diceEnabled
106+
) {
102107
setIsDiceModalOpen(true)
103108
return
104109
}

src-ts/tools/learn/free-code-camp/FreeCodeCamp.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import {
5252
getLessonPathFromModule,
5353
getTCACertificationPath,
5454
} from '../learn.routes'
55+
import { LearnConfig } from '../learn-config'
5556

5657
import { FccFrame } from './fcc-frame'
5758
import { FccSidebar } from './fcc-sidebar'
@@ -534,7 +535,7 @@ const FreeCodeCamp: FC<{}> = () => {
534535
// and if the user has accepted the academic honesty policy,
535536
// the user is permitted to take the course, so there's nothing to do.
536537
if (isLoggedIn
537-
&& (!profile?.isWipro || !!profile?.diceEnabled)
538+
&& (!LearnConfig.REQUIRE_DICE_ID || !profile?.isWipro || !!profile?.diceEnabled)
538539
&& !!certificateProgress?.academicHonestyPolicyAcceptedAt) {
539540
return
540541
}

src-ts/tools/learn/learn-config/learn-config.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export interface LearnConfigModel {
77
value: string,
88
}
99
CLIENT: string
10+
REQUIRE_DICE_ID: boolean | undefined
1011
}

src-ts/tools/learn/learn-config/learn.default.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ export const LearnConfigDefault: LearnConfigModel = {
1111
value: 'certificate-container',
1212
},
1313
CLIENT: 'https://fcc.topcoder-dev.com:4431',
14+
REQUIRE_DICE_ID: `${process.env.REACT_APP_TCA_REQUIRE_DICE_ID}` === 'true',
1415
}

0 commit comments

Comments
 (0)