|
1 |
| -import Reward from "@/components/cards/course/_partials/Reward"; |
2 |
| -import Avatar from "@/components/ui/Avatar"; |
3 | 1 | import ArrowButton from "@/components/ui/button/Arrow";
|
4 |
| -import { Community } from "@/types/community"; |
5 |
| -import { Course } from "@/types/course"; |
6 |
| -import Link from "next/link"; |
7 |
| -import { ReactElement } from "react"; |
| 2 | +import { useSelector } from "react-redux"; |
| 3 | +import { IRootState } from "@/store"; import Link from "next/link"; |
| 4 | +import Badges from "@/components/badges"; |
| 5 | +import DurationBadge from "@/components/badges/DurationBadge"; |
8 | 6 | import { useTranslation } from "next-i18next";
|
9 | 7 |
|
10 |
| -/** |
11 |
| - * Course card component props |
12 |
| - * @date 3/30/2023 - 1:19:07 PM |
13 |
| - * |
14 |
| - * @interface CourseCardProps |
15 |
| - * @typedef {CourseCardProps} |
16 |
| - */ |
| 8 | + |
17 | 9 |
|
18 | 10 | interface CourseCardProps {
|
19 |
| - course: Course; |
20 |
| - community: Community; |
| 11 | + title: string; |
| 12 | + description: string; |
| 13 | + link: string; |
| 14 | + level: number; |
| 15 | + learningModulesCount: number; |
| 16 | + duration: number; |
21 | 17 | }
|
22 | 18 |
|
23 | 19 | /**
|
24 |
| - * Course card component |
25 |
| - * @date 3/30/2023 - 1:18:16 PM |
| 20 | + * CourseMaterial component. |
26 | 21 | *
|
27 |
| - * @export |
28 |
| - * @param {CourseCardProps} { |
29 |
| - course, |
30 |
| - community, |
31 |
| -} |
32 |
| - * @returns {ReactElement} |
| 22 | + * @param {CourseMaterial} { title, description, link, level, learningModulesCount, duration }. |
| 23 | + * @returns {JSX.Element} |
33 | 24 | */
|
34 |
| - |
35 |
| -export default function CourseCard({ course, community }: CourseCardProps): ReactElement { |
| 25 | +export default function CourseCard({ title, description, link, level, learningModulesCount, duration }: CourseCardProps): JSX.Element { |
36 | 26 | const { t } = useTranslation();
|
37 |
| - const path = `/communities/${community.slug}/courses/${course.slug}`; |
38 |
| - const reward = course?.challenge?.rewards?.find((entity) => entity.type === "SUBMISSION"); |
| 27 | + const colors = useSelector((state: IRootState) => state.ui.colors); |
39 | 28 |
|
40 | 29 | return (
|
41 |
| - <div className="flex flex-col sm:flex-row p-6 divide-y sm:divide-y-0 sm:divide-x divide-gray-200 bg-secondary rounded-3xl group text-gray-700 sm:p-7 mb-4 w-full border-solid border border-gray-200"> |
42 |
| - <div className="flex flex-col sm:pr-20 justify-between w-full sm:w-3/5 lg:w-2/3 pb-6 sm:pb-0"> |
43 |
| - <div className="flex flex-col"> |
44 |
| - <div className="text-lg font-medium leading-normal">{t(course.name)}</div> |
45 |
| - {course.level && ( |
46 |
| - <div className="mt-2 text-xxs px-2.5 py-0.5 bg-gray-200 text-gray-500 rounded-3xl max-w-max tracking-wider uppercase font-medium"> |
47 |
| - {t(`course.challenge.level-${course.level}`)} |
48 |
| - </div> |
| 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> |
49 | 51 | )}
|
50 |
| - <div className="text-sm mt-3 pb-2 max-w-xxs">{course.description}</div> |
51 | 52 | </div>
|
52 |
| - <div className="hidden sm:block"> |
53 |
| - <Link href={path}> |
| 53 | + <div className="bottom-0 mt-6"> |
| 54 | + <Link href={link}> |
54 | 55 | <ArrowButton communityStyles={true} variant="outline-primary">
|
55 |
| - {t("course.challenge.button")} |
| 56 | + {t("communities.overview.challenge.learning.start")} |
56 | 57 | </ArrowButton>
|
57 | 58 | </Link>
|
58 | 59 | </div>
|
59 | 60 | </div>
|
60 |
| - |
61 |
| - {reward ? ( |
62 |
| - <div className="text-base text-left sm:flex flex-start flex flex-col pt-6 sm:pt-0 space-y-4 pb-5 sm:pl-7 sm:pb-10 w-full sm:w-2/5 lg:w-1/3 tracking-wider"> |
63 |
| - <Reward reward={reward} /> |
64 |
| - <div className="font-light text-sm max-w-xs pb-2 text-gray-700"> |
65 |
| - {t(reward.stable ? "course.challenge.reward.stable.description" : "course.challenge.reward.description", { |
66 |
| - currency: "$", |
67 |
| - amount: reward.amount, |
68 |
| - token: reward.token, |
69 |
| - })} |
70 |
| - </div> |
71 |
| - </div> |
72 |
| - ) : ( |
73 |
| - <div className="text-base text-left sm:flex flex-start flex flex-col pt-6 sm:pt-0 space-y-4 pb-5 sm:pl-7 sm:pb-10 w-full sm:w-2/5 lg:w-1/3 tracking-wider"> |
74 |
| - <span className="text-xxs tracking-wider px-1 font-semibold uppercase text-gray-500">{t(`course.challenge.certificate`)}</span> |
75 |
| - <Avatar |
76 |
| - className="w-15 h-15 p-3 overflow-hidden" |
77 |
| - icon={community.icon} |
78 |
| - color={community.colors?.cover?.background || community.colors.primary} |
79 |
| - size="extra" |
80 |
| - shape="rounded-3xl" |
81 |
| - user={null} |
82 |
| - /> |
83 |
| - <div className="font-light text-sm max-w-xs pb-2 text-gray-700"> |
84 |
| - <p>{t("course.challenge.certificate.description")}</p> |
85 |
| - </div> |
86 |
| - </div> |
87 |
| - )} |
88 |
| - |
89 |
| - <div className="block sm:hidden pt-6"> |
90 |
| - <Link href={path}> |
91 |
| - <ArrowButton communityStyles={true} variant="outline-primary"> |
92 |
| - {t("course.challenge.button")} |
93 |
| - </ArrowButton> |
94 |
| - </Link> |
95 |
| - </div> |
96 | 61 | </div>
|
97 | 62 | );
|
98 | 63 | }
|
0 commit comments