Skip to content

Commit 4802ce5

Browse files
refactor: code cleanup
1 parent ad28fc8 commit 4802ce5

File tree

7 files changed

+27
-12
lines changed

7 files changed

+27
-12
lines changed

public/locales/bg/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"course.scoreboard.button": "Load more",
207207
"learning-module.material.open.lesson": "Open Lesson",
208208
"learning-module.material.open.article": "Open Article",
209-
"learning-module.course.other.appearances": "Cambiar се появява в",
209+
"learning-module.course.other.appearances": "Също се появява в:",
210210
"partnering.card.text": "To arrange a meeting, just drop us a line.",
211211
"communities.navigation.all": "All communities",
212212
"testimonials.community.title": "Join our community",

public/locales/en/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
"course.scoreboard.button": "Load more",
211211
"learning-module.material.open.lesson": "Open Lesson",
212212
"learning-module.material.open.article": "Open Article",
213-
"learning-module.course.other.appearances": "Also appears in",
213+
"learning-module.course.other.appearances": "Also appears in:",
214214
"partnering.card.text": "To arrange a meeting, just drop us a line.",
215215
"communities.navigation.all": "All communities",
216216
"testimonials.community.title": "Join our community",

public/locales/es/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
"course.scoreboard.button": "Cargar más",
209209
"learning-module.material.open.lesson": "Abrir lección",
210210
"learning-module.material.open.article": "Abrir artículo",
211-
"learning-module.course.other.appearances": "También aparece en",
211+
"learning-module.course.other.appearances": "También aparece en:",
212212
"partnering.card.text": "Para concertar un encuentro, diríjase a nosotros.",
213213
"communities.navigation.all": "Todas las comunidades",
214214
"testimonials.community.title": "Únase a nuestra comunidad",

public/locales/hr/common.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@
206206
"course.scoreboard.button": "Load more",
207207
"learning-module.material.open.lesson": "Open Lesson",
208208
"learning-module.material.open.article": "Otvori članak",
209-
"learning-module.course.other.appearances": "Također se pojavljuje u",
209+
"learning-module.course.other.appearances": "Također se pojavljuje u:",
210210
"partnering.card.text": "To arrange a meeting, just drop us a line.",
211211
"communities.navigation.all": "All communities",
212212
"testimonials.community.title": "Join our community",

src/components/cards/LearningModule.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from "react";
1+
import { Fragment, useEffect, useState } from "react";
22
import ArrowButton from "@/components/ui/button/Arrow";
33
import Link from "next/link";
44
import { useTranslation } from "next-i18next";
@@ -28,9 +28,9 @@ export function LearningModuleCard({ data }: { data: LearningModule }): JSX.Elem
2828
if (!challenge?.level) return
2929
if (challenge.level === 0 || challenge.level === 1) return setLevel("course.challenge.level-0");
3030
return setLevel("course.challenge.level-2");
31-
}, [challenge.level]);
31+
}, [challenge?.level]);
3232

33-
const courses = data?.courses.map(course => course.name)
33+
const courses = data?.courses.map(course => ({ name: course.name, slug: course.slug }))
3434

3535
return (
3636
<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
5050
<div className="text-sm font-normal text-gray-700 max-w-xxs">{data.description}</div>
5151
</div>
5252

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+
<></>}
5469

5570
<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}`}>
5772
<ArrowButton communityStyles={true} variant="outline-primary">
5873
Start now
5974
</ArrowButton>

src/components/sections/challenges/Learning.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React from "react";
21
import Accordion from "@/components/ui/accordion/Accordion";
32
import Section from "@/components/sections/communities/_partials/Section";
4-
import LearningCard from "@/components/cards/challenge/_partials/Learning"; import { LearningModuleCard } from "@/components/cards/LearningModule";
3+
import LearningCard from "@/components/cards/challenge/_partials/Learning";
4+
import { LearningModuleCard } from "@/components/cards/LearningModule";
55
import { Course, LearningModule } from "@/types/course";
66
import { Community } from "@/types/community";
77
import { useTranslation } from "next-i18next";
@@ -37,7 +37,6 @@ export default function Learning({ courses, learningModules, community }: { cour
3737
<LearningModuleCard
3838
key={`related-learning-card-${learning.id}`}
3939
data={learning}
40-
// path={`/communities/${community.slug}/challenges/${challenge?.id}/learning-modules/${learning.id}`}
4140
/>
4241
))}
4342
</div>

src/components/ui/Duration.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const DurationCard = ({ value, type = "gray" }: { value: number, type?: s
1010
if (!value) {
1111
return 0;
1212
}
13+
if (Number(value) !== value) return value
1314
return DateManager.humanize(value, router.locale as string);
1415
};
1516
}, [router.locale]);

0 commit comments

Comments
 (0)