Skip to content

Commit 057737c

Browse files
fix: show related content in the menu on learning module page
1 parent 38faf0c commit 057737c

File tree

1 file changed

+21
-2
lines changed
  • src/pages/communities/[slug]/challenges/[challenge_id]/learning-modules

1 file changed

+21
-2
lines changed

src/pages/communities/[slug]/challenges/[challenge_id]/learning-modules/[id].tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import { serverSideTranslations } from "next-i18next/serverSideTranslations";
1919
import ChallengeOverviewCard from "@/components/cards/challenge/Overview";
2020
import LearningModuleSection from "@/components/sections/learning-modules";
2121
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";
2225

2326
/**
2427
* Learning module page props interfae
@@ -46,7 +49,7 @@ interface LearningModulePageProps {
4649
export default function LearningModulePage(props: LearningModulePageProps) {
4750
const { community, learningModule, challenge } = props.pageProps;
4851
const dispatch = useDispatch();
49-
52+
const { t } = useTranslation();
5053
const navigation = useNavigation();
5154

5255
useEffect(() => {
@@ -60,6 +63,11 @@ export default function LearningModulePage(props: LearningModulePageProps) {
6063
const descriptions = getMetadataDescription(learningModule?.description);
6164

6265
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]);
6371
return (
6472
<>
6573
<Head>
@@ -74,6 +82,17 @@ export default function LearningModulePage(props: LearningModulePageProps) {
7482
<div className="w-full">
7583
{challenge.rewards && <ChallengeOverviewCard challenge={challenge} community={community} />}
7684
<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+
)}
7796
</div>
7897
</div>
7998
</Wrapper>
@@ -93,7 +112,7 @@ export const getServerSideProps: GetServerSideProps = wrapper.getServerSideProps
93112

94113
const [{ data: community }, { data: challenge }, { payload: learningModule }, translations] = await Promise.all([
95114
store.dispatch(fetchCurrentCommunity({ slug: communitySlug, locale })),
96-
store.dispatch(fetchChallenge({ id: challenge_id })),
115+
store.dispatch(fetchChallenge({ id: challenge_id, relations: ["learning-modules", "rubric"] })),
97116
store.dispatch(findLearningModule(learningModule_id)),
98117
serverSideTranslations(locale as string),
99118
]);

0 commit comments

Comments
 (0)