1- import React from 'react' ;
1+ import React , { useState } from 'react' ;
2+ import { Typography } from '../../base' ;
23import { ExternalLinkIcon } from '../../icons' ;
4+ import { Modal , ModalBody , ModalButtonPrimary , ModalButtonSecondary , ModalFooter } from '../Modal' ;
35import {
46 Card2 ,
57 CardActive ,
@@ -30,7 +32,8 @@ interface Props {
3032 path ?: string ;
3133 courseCount : number ;
3234 courseType : string ;
33- cardKey ?: string ;
35+ orgId ?: string ;
36+ modalContent ?: string ;
3437}
3538
3639const OptionalLink : React . FC < React . PropsWithChildren < { path ?: string ; isExternal ?: boolean } > > = ( {
@@ -53,9 +56,19 @@ const OptionalLink: React.FC<React.PropsWithChildren<{ path?: string; isExternal
5356 ) ;
5457} ;
5558
56- const LearningCard : React . FC < Props > = ( { tutorial, path, courseCount, courseType, cardKey } ) => {
57- const isCreateLearningPath = cardKey === 'create-learning-path' ;
59+ const LearningCard : React . FC < Props > = ( {
60+ tutorial,
61+ path,
62+ courseCount,
63+ courseType,
64+ orgId,
65+ modalContent
66+ } ) => {
67+ const isCreateLearningPath = courseType === 'learning-card' ;
68+ const [ modalOpen , setModalOpen ] = useState ( false ) ;
5869
70+ const handleModalOpen = ( ) => setModalOpen ( true ) ;
71+ const handleModalClose = ( ) => setModalOpen ( false ) ;
5972 return (
6073 < CardWrapper >
6174 { tutorial . frontmatter . disabled === 'yes' ? (
@@ -82,9 +95,9 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
8295 </ CardParent >
8396 </ Card2 >
8497 ) : (
85- < OptionalLink path = { path } isExternal = { isCreateLearningPath } >
98+ < >
8699 { isCreateLearningPath ? (
87- < OwnLearningCard >
100+ < OwnLearningCard onClick = { handleModalOpen } style = { { cursor : 'pointer' } } >
88101 < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
89102 < div >
90103 < CardHead >
@@ -112,41 +125,72 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
112125 </ CardParent >
113126 </ OwnLearningCard >
114127 ) : (
115- < CardActive >
116- < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
117- < div >
118- < CardHead >
119- < h3 >
120- { tutorial . frontmatter . title
121- ? tutorial . frontmatter . title
122- : tutorial . frontmatter . courseTitle }
123- </ h3 >
124- { tutorial . frontmatter . status ? (
125- < p >
126- < span > New</ span >
127- </ p >
128- ) : null }
129- </ CardHead >
130- < CardDesc >
131- < p className = "summary" > { tutorial . frontmatter . description } </ p >
132- </ CardDesc >
133- { ! isCreateLearningPath && (
134- < CardSubdata className = "card-subdata" >
135- < p >
136- { courseCount } { courseType }
137- { courseCount > 1 ? 's' : '' }
138- </ p >
139- </ CardSubdata >
140- ) }
141- < CardImage >
142- < img src = { tutorial . frontmatter . cardImage } />
143- </ CardImage >
144- </ div >
145- </ CardParent >
146- </ CardActive >
128+ < OptionalLink path = { path } isExternal = { isCreateLearningPath } >
129+ < CardActive >
130+ < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
131+ < div >
132+ < CardHead >
133+ < h3 >
134+ { tutorial . frontmatter . title
135+ ? tutorial . frontmatter . title
136+ : tutorial . frontmatter . courseTitle }
137+ </ h3 >
138+ { tutorial . frontmatter . status ? (
139+ < p >
140+ < span > New</ span >
141+ </ p >
142+ ) : null }
143+ </ CardHead >
144+ < CardDesc >
145+ < p className = "summary" > { tutorial . frontmatter . description } </ p >
146+ </ CardDesc >
147+ { ! isCreateLearningPath && (
148+ < CardSubdata className = "card-subdata" >
149+ < p >
150+ { courseCount } { courseType }
151+ { courseCount > 1 ? 's' : '' }
152+ </ p >
153+ </ CardSubdata >
154+ ) }
155+ < CardImage >
156+ < img src = { tutorial . frontmatter . cardImage } />
157+ </ CardImage >
158+ </ div >
159+ </ CardParent >
160+ </ CardActive >
161+ </ OptionalLink >
147162 ) }
148- </ OptionalLink >
163+ </ >
149164 ) }
165+
166+ < Modal
167+ open = { modalOpen }
168+ closeModal = { handleModalClose }
169+ title = { tutorial . frontmatter . title || tutorial . frontmatter . courseTitle }
170+ maxWidth = "sm"
171+ >
172+ < ModalBody >
173+ < Typography variant = "body1" > { modalContent } </ Typography >
174+ { orgId && (
175+ < Typography variant = "body1" color = "textSecondary" >
176+ Your Organization ID: { orgId }
177+ </ Typography >
178+ ) }
179+ </ ModalBody >
180+ < ModalFooter variant = "filled" >
181+ < ModalButtonSecondary onClick = { handleModalClose } > Close</ ModalButtonSecondary >
182+ { path && (
183+ < ModalButtonPrimary
184+ onClick = { ( ) => {
185+ window . open ( path , '_blank' ) ;
186+ handleModalClose ( ) ;
187+ } }
188+ >
189+ Visit Docs
190+ </ ModalButtonPrimary >
191+ ) }
192+ </ ModalFooter >
193+ </ Modal >
150194 </ CardWrapper >
151195 ) ;
152196} ;
0 commit comments