|
| 1 | +import React from "react"; |
| 2 | +import ArrowButton from "@/components/ui/button/Arrow"; |
| 3 | +import Link from "next/link"; |
| 4 | +import { useTranslation } from "next-i18next"; |
| 5 | +import { useSelector } from "react-redux"; |
| 6 | +import { IRootState } from "@/store"; |
| 7 | +import Badges from "@/components/badges"; |
| 8 | +import DurationBadge from "@/components/badges/DurationBadge"; |
| 9 | + |
| 10 | +interface CourseMaterialProps { |
| 11 | + title: string; |
| 12 | + description: string; |
| 13 | + link: string; |
| 14 | + level: number; |
| 15 | + learningModulesCount: number; |
| 16 | + duration: number; |
| 17 | +} |
| 18 | + |
| 19 | +/** |
| 20 | + * CourseMaterial component. |
| 21 | + * |
| 22 | + * @param {CourseMaterial} { title, description, link, level, learningModulesCount, duration }. |
| 23 | + * @returns {JSX.Element} |
| 24 | + */ |
| 25 | +export default function CourseMaterial({ title, description, link, level, learningModulesCount, duration }: CourseMaterialProps): JSX.Element { |
| 26 | + const { t } = useTranslation(); |
| 27 | + const colors = useSelector((state: IRootState) => state.ui.colors); |
| 28 | + |
| 29 | + return ( |
| 30 | + <div className="flex flex-col gap-3 relative p-6 divide-y sm:divide-y-0 sm:divide-x divide-gray-200 rounded-3xl group text-gray-700 sm:p-8 border-solid border border-gray-200"> |
| 31 | + <div className="flex flex-col w-full"> |
| 32 | + <div className="flex items-center justify-between mb-6 flex-wrap gap-2"> |
| 33 | + <div className="flex gap-2 items-center"> |
| 34 | + <div className="h-5.5 w-5.5 rounded-sm clip-hexagon" style={{ backgroundColor: colors?.primary }} /> |
| 35 | + <span className="capitalize font-semibold text-[#4B5563] text-sm">COURSE</span> |
| 36 | + </div> |
| 37 | + <div className="flex items-center gap-2"> |
| 38 | + <Badges courseLevel={level} className="!mb-0" /> |
| 39 | + <DurationBadge value={duration} type="bordered" /> |
| 40 | + </div> |
| 41 | + </div> |
| 42 | + <div className="flex flex-col gap-6"> |
| 43 | + <div className="text-lg font-medium leading-normal text-gray-900">{title}</div> |
| 44 | + <div className="text-sm font-normal text-gray-700 max-w-xxs">{description}</div> |
| 45 | + {learningModulesCount && ( |
| 46 | + <p className="text-sm pb-6 font-medium text-gray-400 border-b-2 border-gray-200 border-dotted"> |
| 47 | + {t(learningModulesCount === 1 ? "communities.overview.challenge.course.learningModule" : "communities.overview.challenge.course.learningModules", { |
| 48 | + count: learningModulesCount, |
| 49 | + })} |
| 50 | + </p> |
| 51 | + )} |
| 52 | + </div> |
| 53 | + <div className="bottom-0 mt-6"> |
| 54 | + <Link href={link}> |
| 55 | + <ArrowButton communityStyles={true} variant="outline-primary"> |
| 56 | + {t("communities.overview.challenge.learning.start")} |
| 57 | + </ArrowButton> |
| 58 | + </Link> |
| 59 | + </div> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + ); |
| 63 | +} |
0 commit comments