diff --git a/frontend/src/components/InfoItem.tsx b/frontend/src/components/InfoItem.tsx index aa268c2bd6..a38f8a2336 100644 --- a/frontend/src/components/InfoItem.tsx +++ b/frontend/src/components/InfoItem.tsx @@ -44,7 +44,7 @@ export const TextInfoItem = ({ value: string }) => { return ( -
+
{label}: {value}
diff --git a/frontend/src/components/ModuleCard.tsx b/frontend/src/components/ModuleCard.tsx index 5c2b9faab1..7a11201fba 100644 --- a/frontend/src/components/ModuleCard.tsx +++ b/frontend/src/components/ModuleCard.tsx @@ -1,4 +1,5 @@ -import upperFirst from 'lodash/upperFirst' +import { capitalize } from 'lodash' +import Image from 'next/image' import Link from 'next/link' import { usePathname } from 'next/navigation' import type React from 'react' @@ -7,7 +8,6 @@ import { FaChevronDown, FaChevronUp, FaTurnUp, FaCalendar, FaHourglassHalf } fro import type { Module } from 'types/mentorship' import { formatDate } from 'utils/dateFormatter' import { TextInfoItem } from 'components/InfoItem' -import { LabelList } from 'components/LabelList' import SingleModuleCard from 'components/SingleModuleCard' import { TruncatedText } from 'components/TruncatedText' @@ -25,7 +25,6 @@ const ModuleCard = ({ modules, accessLevel, admins }: ModuleCardProps) => { } const displayedModule = showAllModule ? modules : modules.slice(0, 4) - const isAdmin = accessLevel === 'admin' const handleKeyDown = (e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { @@ -36,9 +35,9 @@ const ModuleCard = ({ modules, accessLevel, admins }: ModuleCardProps) => { return (
-
+
{displayedModule.map((module) => { - return + return })}
{modules.length > 4 && ( @@ -65,26 +64,116 @@ const ModuleCard = ({ modules, accessLevel, admins }: ModuleCardProps) => { ) } -const ModuleItem = ({ module, isAdmin }: { module: Module; isAdmin: boolean }) => { +const ModuleItem = ({ module }: { module: Module }) => { const pathname = usePathname() + + const mentors = module.mentors || [] + const mentees = module.mentees || [] + + const mentorsWithAvatars = mentors.filter((m) => m?.avatarUrl) + const menteesWithAvatars = mentees.filter((m) => m?.avatarUrl) + + const programKey = pathname?.split('/programs/')[1]?.split('/')[0] || '' + const moduleKey = module.key || module.id + + const getMenteeUrl = (login: string) => { + if (pathname?.startsWith('/my/mentorship')) { + return `/my/mentorship/programs/${programKey}/modules/${moduleKey}/mentees/${login}` + } + return `/members/${login}` + } + + const getAvatarUrlWithSize = (avatarUrl: string): string => { + try { + const url = new URL(avatarUrl) + url.searchParams.set('s', '60') + return url.toString() + } catch { + const separator = avatarUrl.includes('?') ? '&' : '?' + return `${avatarUrl}${separator}s=60` + } + } + return ( -
+
- + - {isAdmin && module.labels && module.labels.length > 0 && ( -
- + + {(mentorsWithAvatars.length > 0 || menteesWithAvatars.length > 0) && ( +
+ {mentorsWithAvatars.length > 0 && ( +
+ + Mentors + +
+ {mentorsWithAvatars.slice(0, 4).map((contributor) => ( + + {contributor.name + + ))} + {mentorsWithAvatars.length > 4 && ( + + +{mentorsWithAvatars.length - 4} + + )} +
+
+ )} + {menteesWithAvatars.length > 0 && ( +
0 ? 'border-l-1 border-gray-100 pl-4 dark:border-gray-700' : ''}`} + > + + Mentees + +
+ {menteesWithAvatars.slice(0, 4).map((contributor) => ( + + {contributor.name + + ))} + {menteesWithAvatars.length > 4 && ( + + +{menteesWithAvatars.length - 4} + + )} +
+
+ )}
)}
diff --git a/frontend/src/components/SingleModuleCard.tsx b/frontend/src/components/SingleModuleCard.tsx index 6a58f8b0ee..68c76f4358 100644 --- a/frontend/src/components/SingleModuleCard.tsx +++ b/frontend/src/components/SingleModuleCard.tsx @@ -11,6 +11,7 @@ import type { Module } from 'types/mentorship' import { formatDate } from 'utils/dateFormatter' import EntityActions from 'components/EntityActions' import Markdown from 'components/MarkdownWrapper' +import MenteeContributorsList from 'components/MenteeContributorsList' import { getSimpleDuration } from 'components/ModuleCard' import TopContributorsList from 'components/TopContributorsList' @@ -88,6 +89,24 @@ const SingleModuleCard: React.FC = ({ module, accessLevel label="Mentors" /> )} + {module.mentees?.length > 0 && + (pathname?.startsWith('/my/mentorship') ? ( + + ) : ( + + ))}
) }