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,6 +32,8 @@ interface Props {
3032 path ?: string ;
3133 courseCount : number ;
3234 courseType : string ;
35+ orgId ?: string ;
36+ modalContent ?: string ;
3337}
3438
3539const OptionalLink : React . FC < React . PropsWithChildren < { path ?: string ; isExternal ?: boolean } > > = ( {
@@ -52,8 +56,19 @@ const OptionalLink: React.FC<React.PropsWithChildren<{ path?: string; isExternal
5256 ) ;
5357} ;
5458
55- const LearningCard : React . FC < Props > = ( { tutorial, path, courseCount, courseType } ) => {
59+ const LearningCard : React . FC < Props > = ( {
60+ tutorial,
61+ path,
62+ courseCount,
63+ courseType,
64+ orgId,
65+ modalContent
66+ } ) => {
5667 const isCreateLearningPath = courseType === 'learning-card' ;
68+ const [ modalOpen , setModalOpen ] = useState ( false ) ;
69+
70+ const handleModalOpen = ( ) => setModalOpen ( true ) ;
71+ const handleModalClose = ( ) => setModalOpen ( false ) ;
5772 return (
5873 < CardWrapper >
5974 { tutorial . frontmatter . disabled === 'yes' ? (
@@ -80,9 +95,9 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
8095 </ CardParent >
8196 </ Card2 >
8297 ) : (
83- < OptionalLink path = { path } isExternal = { isCreateLearningPath } >
98+ < >
8499 { isCreateLearningPath ? (
85- < OwnLearningCard >
100+ < OwnLearningCard onClick = { handleModalOpen } style = { { cursor : 'pointer' } } >
86101 < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
87102 < div >
88103 < CardHead >
@@ -110,41 +125,72 @@ const LearningCard: React.FC<Props> = ({ tutorial, path, courseCount, courseType
110125 </ CardParent >
111126 </ OwnLearningCard >
112127 ) : (
113- < CardActive >
114- < CardParent style = { { borderTop : `5px solid ${ tutorial . frontmatter . themeColor } ` } } >
115- < div >
116- < CardHead >
117- < h3 >
118- { tutorial . frontmatter . title
119- ? tutorial . frontmatter . title
120- : tutorial . frontmatter . courseTitle }
121- </ h3 >
122- { tutorial . frontmatter . status ? (
123- < p >
124- < span > New</ span >
125- </ p >
126- ) : null }
127- </ CardHead >
128- < CardDesc >
129- < p className = "summary" > { tutorial . frontmatter . description } </ p >
130- </ CardDesc >
131- { ! isCreateLearningPath && (
132- < CardSubdata className = "card-subdata" >
133- < p >
134- { courseCount } { courseType }
135- { courseCount > 1 ? 's' : '' }
136- </ p >
137- </ CardSubdata >
138- ) }
139- < CardImage >
140- < img src = { tutorial . frontmatter . cardImage } />
141- </ CardImage >
142- </ div >
143- </ CardParent >
144- </ 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 >
145162 ) }
146- </ OptionalLink >
163+ </ >
147164 ) }
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 >
148194 </ CardWrapper >
149195 ) ;
150196} ;
0 commit comments