@@ -19,6 +19,9 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations";
19
19
import ChallengeOverviewCard from "@/components/cards/challenge/Overview" ;
20
20
import LearningModuleSection from "@/components/sections/learning-modules" ;
21
21
import { fetchChallenge } from "@/store/services/communities/challenges" ;
22
+ import PageNavigation from "@/components/sections/courses/PageNavigation" ;
23
+ import ChallengeCard from "@/components/cards/challenge/Challenge" ;
24
+ import { useTranslation } from "next-i18next" ;
22
25
23
26
/**
24
27
* Learning module page props interfae
@@ -46,7 +49,7 @@ interface LearningModulePageProps {
46
49
export default function LearningModulePage ( props : LearningModulePageProps ) {
47
50
const { community, learningModule, challenge } = props . pageProps ;
48
51
const dispatch = useDispatch ( ) ;
49
-
52
+ const { t } = useTranslation ( ) ;
50
53
const navigation = useNavigation ( ) ;
51
54
52
55
useEffect ( ( ) => {
@@ -60,6 +63,11 @@ export default function LearningModulePage(props: LearningModulePageProps) {
60
63
const descriptions = getMetadataDescription ( learningModule ?. description ) ;
61
64
62
65
const paths = useMemo ( ( ) => [ challenge . name , learningModule ?. title ] , [ challenge . name , learningModule ?. title ] ) ;
66
+
67
+ const isLastLearningModule = useMemo ( ( ) => {
68
+ if ( ! challenge . learningModules || ! challenge . learningModules . length ) return false ;
69
+ return learningModule . id === challenge . learningModules [ challenge . learningModules . length - 1 ] . id ;
70
+ } , [ learningModule . id , challenge . learningModules ] ) ;
63
71
return (
64
72
< >
65
73
< Head >
@@ -74,6 +82,17 @@ export default function LearningModulePage(props: LearningModulePageProps) {
74
82
< div className = "w-full" >
75
83
{ challenge . rewards && < ChallengeOverviewCard challenge = { challenge } community = { community } /> }
76
84
< LearningModuleSection learningModule = { learningModule } />
85
+ { isLastLearningModule ? (
86
+ < div >
87
+ < div className = "mt-6 mb-5" >
88
+ < h2 className = "font-medium text-.5xl text-gray-700 pb-3" > { t ( "communities.challenge.title" ) } </ h2 >
89
+ < p className = "text-lg" > { t ( "communities.overview.learning-modules-challenge-introduction" ) } </ p >
90
+ </ div >
91
+ < ChallengeCard data = { challenge } key = { challenge . id } community = { community } isCourseEnd />
92
+ </ div >
93
+ ) : (
94
+ < PageNavigation />
95
+ ) }
77
96
</ div >
78
97
</ div >
79
98
</ Wrapper >
@@ -93,7 +112,7 @@ export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps
93
112
94
113
const [ { data : community } , { data : challenge } , { payload : learningModule } , translations ] = await Promise . all ( [
95
114
store . dispatch ( fetchCurrentCommunity ( { slug : communitySlug , locale } ) ) ,
96
- store . dispatch ( fetchChallenge ( { id : challenge_id } ) ) ,
115
+ store . dispatch ( fetchChallenge ( { id : challenge_id , relations : [ "learning-modules" , "rubric" ] } ) ) ,
97
116
store . dispatch ( findLearningModule ( learningModule_id ) ) ,
98
117
serverSideTranslations ( locale as string ) ,
99
118
] ) ;
0 commit comments