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 mentee and mentor card #170 #195

Open
wants to merge 35 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c0e86c1
placed the elements
AnsarMahir Sep 1, 2024
bdd8c7f
Fix: Update mentor profile UI #171
AnsarMahir Sep 1, 2024
fb69afe
Fix:Update Mentor Profile UI
AnsarMahir Sep 1, 2024
010a49b
Chip design implemented
AnsarMahir Sep 6, 2024
6f2df3d
colors swapped with condition
AnsarMahir Sep 6, 2024
5a68efa
same row in mobile
AnsarMahir Sep 6, 2024
ebe0fa3
conditional rendering of slot&slots
AnsarMahir Sep 6, 2024
477665a
Merge remote-tracking branch 'upstream/main'
AnsarMahir Sep 8, 2024
0e5214a
Merge remote-tracking branch 'upstream/main'
AnsarMahir Sep 9, 2024
d3aea87
node version updated to 18 in e2e
AnsarMahir Sep 9, 2024
f627679
reverted changes to package json and lock
AnsarMahir Sep 14, 2024
23c87d9
Update package.json
AnsarMahir Sep 14, 2024
34da7ad
variables used
AnsarMahir Sep 14, 2024
2ec5888
Merge branch 'main' of https://github.com/AnsarMahir/scholarx-frontend
AnsarMahir Sep 14, 2024
a29d7bd
fixed css
AnsarMahir Sep 14, 2024
1fce7a0
removed comments
AnsarMahir Sep 14, 2024
b635310
matched with latest version
AnsarMahir Sep 15, 2024
70d5d09
matched with latest updates
AnsarMahir Sep 15, 2024
fa2f82d
lint issue fixed
AnsarMahir Sep 15, 2024
ed63123
Merge remote-tracking branch 'upstream/main'
AnsarMahir Sep 19, 2024
011adc7
upper part fixed (image)
AnsarMahir Sep 21, 2024
697f514
Mentee card finalized
AnsarMahir Sep 26, 2024
3583f6f
mentee card finished
AnsarMahir Sep 29, 2024
606eb00
Merge remote-tracking branch 'upstream/main'
AnsarMahir Sep 29, 2024
dc66eca
lint fix
AnsarMahir Sep 29, 2024
4980b4b
fixed lint
AnsarMahir Sep 29, 2024
2def59b
Merge branch 'main' into main
AnsarMahir Sep 29, 2024
4794fb9
finalized mentee and mentor card
AnsarMahir Oct 5, 2024
b771c66
Merge branch 'main' of https://github.com/AnsarMahir/scholarx-frontend
AnsarMahir Oct 5, 2024
9ff7f62
done for mentor card
AnsarMahir Oct 20, 2024
f14aa63
Merge remote-tracking branch 'upstream/development'
AnsarMahir Oct 22, 2024
465e392
SVG refactored
AnsarMahir Oct 22, 2024
91ff164
es lint fixes
AnsarMahir Oct 23, 2024
75d2210
Merge branch 'development'
AnsarMahir Nov 9, 2024
9c28ba4
few design changes
AnsarMahir Nov 9, 2024
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
24 changes: 18 additions & 6 deletions src/components/MenteeCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,39 @@ const MenteeCard: React.FC<MenteeCardProps> = ({
}) => {
return (
<Link
className="border border-gray-200 p-4 rounded-md shadow-sm w-52 flex flex-col h-full"
className="border-2 border-light-gray p-2.5 pb-[12px] rounded-md shadow-sm max-w-full flex flex-col h-full"
to={
showPublicProfile
? `/mentees/${mentee.uuid}`
: `/mentor/my-mentees/${mentee.uuid}`
}
>
<div className="mx-auto mb-4">
<div className="mx-auto mb-2">
<ProfilePic
src={mentee.profile?.image_url}
alt="Mentee Avatar"
size="6rem"
size="11.6875rem"
width="16.25rem"
circular={false}
/>
</div>
<div className="text-center">
<div className="text-left p-0.5">
<h5 className="text-lg font-bold">
{mentee.application.firstName} {mentee.application.lastName}
</h5>
{mentee.application.isUndergrad ? (
<p className="text-xs text-gray-500">
{mentee.application.university}
<p className="text-sm text-gray-500 flex items-center">
<svg
AnsarMahir marked this conversation as resolved.
Show resolved Hide resolved
className="w-4 h-4 text-gray-500 dark:text-white mr-2"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 20 20"
>
<path d="M19.728 10.686c-2.38 2.256-6.153 3.381-9.875 3.381-3.722 0-7.4-1.126-9.571-3.371L0 10.437V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-7.6l-.272.286Z"></path>
<path d="m.135 7.847 1.542 1.417c3.6 3.712 12.747 3.7 16.635.01L19.605 7.9A.98.98 0 0 1 20 7.652V6a2 2 0 0 0-2-2h-3V3a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H2a2 2 0 0 0-2 2v1.765c.047.024.092.051.135.082ZM10 10.25a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5ZM7 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1H7V3Z"></path>
</svg>
<span> {mentee.application.university} </span>
AnsarMahir marked this conversation as resolved.
Show resolved Hide resolved
</p>
) : (
<>
Expand Down
72 changes: 61 additions & 11 deletions src/components/MentorCard/MentorCard.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,37 @@ import React from 'react';
import { type Mentor } from '../../types.ts';
import { Link } from 'react-router-dom';
import ProfilePic from '../ProfilePic/index.tsx';
import { ApplicationStatus } from '../../enums';

interface MentorCardProps {
mentor: Mentor;
}

const MentorCard: React.FC<MentorCardProps> = ({ mentor }) => {
const approvedMenteesCount = mentor?.mentees
? mentor.mentees.filter(
(mentee) => mentee.state === ApplicationStatus.APPROVED
).length
: 0;

const availableSlots = mentor?.application?.noOfMentees
? Math.max(0, mentor.application.noOfMentees - approvedMenteesCount)
: 0;

const totalApplications = mentor?.mentees?.length ?? 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Total application count is also there in the mentor application.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issue is that , I tried already to simplify the logic as below

const appliedMenteesCount = mentor?.application?.appliedMenteesCount ?? 0;
  const availableMenteeSlots = mentor?.application?.availableMenteeSlots ?? 0;

but it pop up an error,
"Property 'appliedMenteesCount' does not exist on type '{ firstName: string; lastName: string; email: string; contactNo: string; country: string; position: string; expertise: string; bio: string; isPastMentor: boolean; reasonToMentor: string; profilePic: string; ... 10 more ...; canCommit?: boolean | undefined; }'."

Tried to fix that error by adding

 appliedMenteesCount?: number; 
  availableMenteeSlots?: number;

to the mentor interface, but did not work out. :(. That's why just left it as it is


return (
<Link
className="border border-gray-200 p-4 rounded-md shadow-md w-52 flex flex-col h-full relative"
to={`/mentors/${mentor.uuid}`}
className="p-2.5 rounded-md shadow-md max-w-full flex flex-col h-full relative outline outline-2 outline-bd-gray"
to={`/mentors/${mentor.uuid}`}
>
<div className="mx-auto mb-4">
<div className="flex flex-col items-center">
<ProfilePic
src={mentor.profile.image_url}
src={mentor.profile?.image_url}
alt="Mentee Avatar"
size="6rem"
size="11.6875rem"
width="17.5rem"
circular={false}
availability={mentor.availability}
/>
</div>
Expand All @@ -26,15 +41,50 @@ const MentorCard: React.FC<MentorCardProps> = ({ mentor }) => {
<span className="text-xs font-semibold">Unavailable</span>
</div>
)}
<div className="text-center">
<h5 className="text-lg font-semibold text-slate-600 text-wrap">
{mentor.application.firstName} {mentor.application.lastName}
<div className="text-left p-0.5 flex-1">
<h5 className="text-lg font-bold text-black-600 text-wrap">
{mentor.application?.firstName} {mentor.application?.lastName}
</h5>
<p className="text-sm">{mentor.application.position}</p>
<p className="text-xs text-gray-500">
{mentor.application.institution}
<p className="text-sm text-gray-500 flex items-center p-0">
<svg
AnsarMahir marked this conversation as resolved.
Show resolved Hide resolved
className="w-4 h-4 text-gray-500 dark:text-white mr-2 align-middle"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 20 20"
>
<path d="M19.728 10.686c-2.38 2.256-6.153 3.381-9.875 3.381-3.722 0-7.4-1.126-9.571-3.371L0 10.437V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-7.6l-.272.286Z"></path>
<path d="m.135 7.847 1.542 1.417c3.6 3.712 12.747 3.7 16.635.01L19.605 7.9A.98.98 0 0 1 20 7.652V6a2 2 0 0 0-2-2h-3V3a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v1H2a2 2 0 0 0-2 2v1.765c.047.024.092.051.135.082ZM10 10.25a1.25 1.25 0 1 1 0-2.5 1.25 1.25 0 0 1 0 2.5ZM7 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1H7V3Z"></path>
</svg>
<span className='align-middle'>
{' '}
AnsarMahir marked this conversation as resolved.
Show resolved Hide resolved
{mentor.application?.position} | {mentor.application?.institution}
</span>
</p>
</div>
<hr className="my-4 border-gray-300" />

<div className="flex justify-between text-left">
<div className="text-[10px]">
<p className="text-gray-500">Available Mentee Slots</p>
<p className="text-xs font-bold">
{mentor?.application?.noOfMentees && mentor.mentees
? availableSlots
: 0}
</p>
</div>
<div className="text-[10px]">
<p className="text-gray-500">Applications Received</p>
<p className="text-xs font-bold">
{mentor?.mentees &&
mentor.mentees.some(
(mentee) => mentee.state === ApplicationStatus.APPROVED
)
? totalApplications
: 0}
</p>
</div>
</div>
</Link>
);
};
Expand Down
28 changes: 18 additions & 10 deletions src/components/ProfilePic/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ const ProfilePic: React.FC<{
src: string | undefined;
alt: string;
size: string;
width?: string;
availability?: boolean;
}> = ({ src, alt, size, availability = true }) => {
circular?: boolean;
}> = ({ src, alt, size, width, availability = true, circular = true }) => {
const [isLoading, setIsLoading] = useState(true);
const [isError, setIsError] = useState(false);

Expand All @@ -19,32 +21,38 @@ const ProfilePic: React.FC<{
setIsLoading(false);
};

const appliedWidth = width ?? size;

return (
<div
className="relative inline-block"
style={{ height: size, width: size }}
style={{ height: size, width: appliedWidth }}
>
{isLoading && !isError && (
<div
className="absolute inset-0 bg-gray-200 rounded-full animate-skeleton bg-gradient-to-r from-gray-200 via-gray-300 to-gray-200 bg-[length:200%_100%]"
style={{ height: size, width: size }}
className={`absolute inset-0 bg-gray-200 animate-skeleton bg-gradient-to-r from-gray-200 via-gray-300 to-gray-200 bg-[length:200%_100%] ${
circular ? 'rounded-full' : 'rounded-custom-5'
}`}
style={{ height: size, width: appliedWidth }}
/>
)}
{isError ? (
<div
className="inline-block bg-gray-200 rounded-full ring-2 ring-white flex items-center justify-center"
style={{ height: size, width: size }}
className={`inline-block bg-gray-200 ring-2 ring-white flex items-center justify-center ${
circular ? 'rounded-full' : 'rounded-custom-5'
}`}
style={{ height: size, width: appliedWidth }}
>
<UserIcon />
</div>
) : (
<img
src={src}
alt={alt}
className={`inline-block rounded-full ring-2 ring-white object-cover ${
!availability ? 'opacity-60' : ''
}`}
style={{ height: size, width: size }}
className={`inline-block ring-2 ring-white object-cover ${
circular ? 'rounded-full' : 'rounded-custom-5'
} ${!availability ? 'opacity-60' : ''} max-w-full`}
style={{ height: size, width: appliedWidth }}
referrerPolicy="no-referrer"
onLoad={handleImageLoad}
onError={handleImageError}
Expand Down
2 changes: 2 additions & 0 deletions src/pages/MentorProfile/MentorProfile.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ const MentorProfile: React.FC = () => {
? Math.max(0, mentor.application.noOfMentees - approvedMenteesCount)
: 0;

console.log(mentor);

AnsarMahir marked this conversation as resolved.
Show resolved Hide resolved
return (
<>
<nav aria-label="Breadcrumb">
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Mentors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const Mentors = () => {
</div>

{sortedMentors.length > 0 ? (
<div className="flex-grow grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-5 xl:grid-cols-6 gap-8 items-start">
<div className="flex-grow grid grid-cols-[repeat(auto-fit,_minmax(16rem,_1fr))] gap-4 items-start">
{sortedMentors.map((mentor) => (
<MentorCard key={mentor.uuid} mentor={mentor} />
))}
Expand Down
4 changes: 4 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const theme = {
colors: {
'primary-blue': '#1677FF',
'darkmod-blue': '#3D317C',
'bd-gray': '#D1D5DB',
},
animation: {
'skeleton': 'skeleton-loading 1.5s infinite',
Expand All @@ -15,6 +16,9 @@ export const theme = {
'100%': { backgroundPosition: '-100% 0' },
},
},
borderRadius: {
'custom-5': '5px',
},
},
};
export const plugins = [];