Skip to content

Commit

Permalink
Updated the showing of user details to different users
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavberi committed Dec 9, 2024
1 parent f909fa0 commit 4f963e4
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 51 deletions.
34 changes: 21 additions & 13 deletions src/app/profile/[id]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,7 @@ export default async function Profile({ params }) {
[],
);

console.log(memberships);
if (memberships?.length === 0) {
if (memberships?.length === 0 && currentUser?.uid !== user.uid) {
notFound();
}
}
Expand All @@ -98,7 +97,9 @@ export default async function Profile({ params }) {
2. if current user is viewing their own profile and is not a club
*/}
{currentUser?.role === "cc" ||
(currentUser?.uid === user.uid && user.role !== "club") ? (
(memberships?.length !== 0 &&
currentUser?.uid === user.uid &&
user.role !== "club") ? (
<ActionPalette right={[EditUser]} />
) : null}
<Grid container spacing={2} mt={4}>
Expand Down Expand Up @@ -150,16 +151,23 @@ export default async function Profile({ params }) {
</Stack>
</Grid>

<Grid item xs={12} lg={9} mt={{ xs: 2, lg: 5 }}>
{user?.batch?.toLowerCase()?.includes("2k") ? ( // hacky way to exclude faculty and staff from rendering memberships
<Stack direction="column" spacing={2}>
<Typography variant="subtitle2" textTransform="uppercase">
Memberships
</Typography>
<UserMemberships rows={memberships} />
</Stack>
) : null}
</Grid>
{/* Show user details only for students */}
{user?.batch?.toLowerCase()?.includes("2k") ? ( // hacky way to exclude faculty and staff
<>
<Grid item container xs spacing={2} mt={5}>
<UserDetails user={user} />
</Grid>

<Grid item xs={12} lg={9} mt={{ xs: 2, lg: 5 }}>
<Stack direction="column" spacing={2}>
<Typography variant="subtitle2" textTransform="uppercase">
Memberships
</Typography>
<UserMemberships rows={memberships} />
</Stack>
</Grid>
</>
) : null}
</Grid>
</Container>
);
Expand Down
4 changes: 2 additions & 2 deletions src/components/members/MemberCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default async function MemberCard({ uid, poc, roles }) {
user = { ...userMeta, ...userProfile1 };
}

// Edge case for profile redirecting 404 for faculty in supervisory-bodies section
const clickable = user.role !== "public" || user.email.includes("student") || user.email.includes("research");
// Edge case for profile redirecting 404 for faculty/staff in supervisory-bodies section
const clickable = user?.role !== "public" || user?.email.includes("student") || user?.email.includes("research");

return (
<Card
Expand Down
74 changes: 38 additions & 36 deletions src/components/profile/UserDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,49 +12,51 @@ export default async function UserDetails({ user }) {

return (
<Stack direction="column" spacing={3} mx={2}>
<Box>
<Typography variant="subtitle2" textTransform="uppercase" gutterBottom>
User ID
</Typography>
<Typography fontWeight={400} fontFamily="monospace">
{user.uid}
</Typography>
</Box>
{currentUser?.uid ? (
<Box>
<Typography
variant="subtitle2"
textTransform="uppercase"
gutterBottom
>
User ID
</Typography>
<Typography fontWeight={400} fontFamily="monospace">
{user.uid}
</Typography>
</Box>
) : null}

{user?.role !== "club" ? (
<>
{user?.batch?.toLowerCase()?.includes("2k") ? ( // hacky way to exclude faculty and staff from rendering batch and stream
<Box>
<Typography
variant="subtitle2"
textTransform="uppercase"
gutterBottom
>
Batch
</Typography>
<Typography fontWeight={400} textTransform="uppercase">
{user.batch} · {user.stream}
</Typography>
</Box>
) : null}
<Box>
<Typography
variant="subtitle2"
textTransform="uppercase"
gutterBottom
>
Batch
</Typography>
<Typography fontWeight={400} textTransform="uppercase">
{user.batch} · {user.stream}
</Typography>
</Box>

{["cc", "slo", "slc"].includes(currentUser?.role) ||
(currentUser?.uid === user?.uid && user?.role !== "club") ? (
<>
{user?.batch?.toLowerCase()?.includes("2k") ? (
<Box>
<Typography
variant="subtitle2"
textTransform="uppercase"
gutterBottom
>
Roll Number
</Typography>
<Typography fontWeight={400}>
{user.rollno || "Unknown"}
</Typography>
</Box>
) : null}
<Box>
<Typography
variant="subtitle2"
textTransform="uppercase"
gutterBottom
>
Roll Number
</Typography>
<Typography fontWeight={400}>
{user.rollno || "Unknown"}
</Typography>
</Box>
<Box>
<Typography
variant="subtitle2"
Expand Down

0 comments on commit 4f963e4

Please sign in to comment.