Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update mentor profile UI #183

Merged
merged 19 commits into from
Sep 15, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
- name: Install dependencies
run: npm ci
- name: Install Playwright Browsers
Expand Down
57 changes: 35 additions & 22 deletions src/pages/MentorProfile/MentorProfile.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@ const MentorProfile: React.FC = () => {
const { data: mentor, isLoading } = useMentor(mentorId as string);
const { revokeApplication } = useMentee();

// Calculate the number of approved mentees once
AnsarMahir marked this conversation as resolved.
Show resolved Hide resolved
const approvedMenteesCount = mentor?.mentees
? mentor.mentees.filter(
(mentee) => mentee.state === ApplicationStatus.APPROVED
).length
: 0;

// Calculate available slots
AnsarMahir marked this conversation as resolved.
Show resolved Hide resolved
const availableSlots = mentor?.application.noOfMentees
? Math.max(0, mentor.application.noOfMentees - approvedMenteesCount)
: 0;

if (isLoading) {
return (
<div className="flex items-center justify-center h-screen">
Expand Down Expand Up @@ -101,11 +113,29 @@ const MentorProfile: React.FC = () => {
<ShareIcon />
</span>
</div>
<p className="text-sm">
{mentor?.application.position},{' '}
<span className="text-gray-500">
{mentor?.application.institution}
</span>
<p className="text-md flex flex-wrap items-center">
{mentor?.application.noOfMentees && mentor.mentees ? (
<span
className={`inline-block text-sm font-medium px-3 py-1 rounded-full mt-2 sm:mt-0 mr-2 ${
availableSlots === 0
? 'bg-gray-100 text-gray-800'
: 'bg-green-100 text-green-800'
}`}
>
{availableSlots} {availableSlots <= 1 ? 'Slot' : 'Slots'}{' '}
Available
</span>
) : (
'Not mentioned'
)}
{mentor?.mentees &&
mentor?.mentees.some(
(mentee) => mentee.state === ApplicationStatus.APPROVED
) && (
<span className="inline-block bg-blue-100 text-blue-800 text-sm font-medium px-3 py-1 rounded-full mt-2 sm:mt-0">
{mentor.mentees.length} Applied
</span>
)}
</p>
</div>
</div>
Expand Down Expand Up @@ -189,30 +219,13 @@ const MentorProfile: React.FC = () => {
<h2 className="text-lg font-medium ">Bio</h2>
<p className="font-light">{mentor?.application.bio}</p>
</div>
<div className="pb-4">
<h2 className="text-lg font-medium ">Available mentee slots</h2>
<p className="font-light">
{mentor?.application.noOfMentees && mentor.mentees
? Math.max(
0,
mentor.application.noOfMentees -
mentor.mentees.filter(
(mentee) => mentee.state === ApplicationStatus.APPROVED
).length
)
: 'Not mentioned'}
</p>
</div>
{mentor?.mentees &&
mentor?.mentees.some(
(mentee) => mentee.state === ApplicationStatus.APPROVED
) && (
<div className="pb-4">
<div className="flex flex-wrap gap-2 items-baseline">
<h2 className="text-lg font-medium mb-2 ">Mentees</h2>
<p className="text-slate-400 mb-2">
&#40; {mentor.mentees.length} total applications &#41;
</p>
</div>
<div className="flex flex-wrap gap-2">
{mentor.mentees
Expand Down
Loading