1
- import { useEffect , useState } from "react" ;
1
+ import { Fragment , useEffect , useState } from "react" ;
2
2
import ArrowButton from "@/components/ui/button/Arrow" ;
3
3
import Link from "next/link" ;
4
4
import { useTranslation } from "next-i18next" ;
@@ -28,9 +28,9 @@ export function LearningModuleCard({ data }: { data: LearningModule }): JSX.Elem
28
28
if ( ! challenge ?. level ) return
29
29
if ( challenge . level === 0 || challenge . level === 1 ) return setLevel ( "course.challenge.level-0" ) ;
30
30
return setLevel ( "course.challenge.level-2" ) ;
31
- } , [ challenge . level ] ) ;
31
+ } , [ challenge ? .level ] ) ;
32
32
33
- const courses = data ?. courses . map ( course => course . name )
33
+ const courses = data ?. courses . map ( course => ( { name : course . name , slug : course . slug } ) )
34
34
35
35
return (
36
36
< div className = "flex flex-col content-start w-full p-8 rounded-3xl group text-gray-700 border-solid border border-gray-200 gap-8" >
@@ -50,10 +50,25 @@ export function LearningModuleCard({ data }: { data: LearningModule }): JSX.Elem
50
50
< div className = "text-sm font-normal text-gray-700 max-w-xxs" > { data . description } </ div >
51
51
</ div >
52
52
53
- { courses . length ? < p className = "font-medium text-gray text-tertiary text-sm" > { t ( 'learning-module.course.other.appearances' ) } : { courses . map ( ( course , index ) => < Link href = { `/communities/${ community . slug } /challenges/${ challenge ?. id } /learning-modules/${ data . id } ` } key = { `other-appearance-counse-${ index } ` } className = "underline ml-1" > { course } { index !== courses . length - 1 && "," } </ Link > ) } </ p > : < > </ > }
53
+ { courses . length ?
54
+ < p className = "font-medium text-gray text-tertiary text-sm" >
55
+ { t ( 'learning-module.course.other.appearances' ) }
56
+ { courses . map ( ( course , index ) =>
57
+ < Fragment key = { `related-course-${ index } ` } >
58
+ < Link
59
+ key = { `other-appearance-course-${ index } ` }
60
+ href = { `/communities/${ community . slug } /courses/${ course ?. slug } ` }
61
+ className = "hover:underline ml-1" > { course . name }
62
+ </ Link >
63
+ { index !== courses . length - 1 && "," }
64
+ </ Fragment >
65
+ ) }
66
+ </ p >
67
+ :
68
+ < > </ > }
54
69
55
70
< div className = "w-full mb-0 justify-self-end" >
56
- < Link href = { "#" } >
71
+ < Link href = { `/communities/ ${ community . slug } /challenges/ ${ challenge ?. id } /learning-modules/ ${ data . id } ` } >
57
72
< ArrowButton communityStyles = { true } variant = "outline-primary" >
58
73
Start now
59
74
</ ArrowButton >
0 commit comments