Skip to content

Commit

Permalink
Merge branch 'master' into storagefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavberi committed Dec 10, 2024
2 parents 2af5c7f + f809954 commit db8dc49
Show file tree
Hide file tree
Showing 20 changed files with 851 additions and 1,845 deletions.
2,444 changes: 719 additions & 1,725 deletions package-lock.json

Large diffs are not rendered by default.

Binary file added public/assets/slc-tech-logo-black.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/assets/slc-tech-logo-white.svg

This file was deleted.

4 changes: 2 additions & 2 deletions src/app/gallery/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const metadata = {
title: "Gallery | Life @ IIIT-H",
};

export default async function Gallery({ limit = undefined }) {
export default async function Gallery({ limit = undefined, priority = true }) {
const response = await fetch(`${FILESERVER_URL}/files/gallery/list`, {
next: { revalidate: 1200 }, // 20 minutes
});
Expand All @@ -18,7 +18,7 @@ export default async function Gallery({ limit = undefined }) {

return (
<>
<ImageMasonry images={galleryItems} limit={limit} />
<ImageMasonry images={galleryItems} limit={limit} priority={priority} />
</>
);
}
2 changes: 1 addition & 1 deletion src/app/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default function Home() {
</Button>
</Box>
</Stack>
<Gallery limit={8} />
<Gallery limit={8} priority={false} />
</Box>
</Box>
);
Expand Down
69 changes: 42 additions & 27 deletions src/app/profile/[id]/edit/page.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { redirect, notFound } from "next/navigation";

import { getClient } from "gql/client";
import { GET_USER } from "gql/queries/auth";
import { GET_MEMBERSHIPS } from "gql/queries/clubs";
import { GET_USER_PROFILE } from "gql/queries/users";

import { Container } from "@mui/material";
Expand All @@ -14,34 +16,47 @@ export const metadata = {
export default async function EditProfile({ params }) {
const { id } = params;

try {
// get target user
const { data: { userProfile, userMeta } = {} } = await getClient().query(
GET_USER_PROFILE,
{
userInput: {
uid: id,
},
// get currently logged in user
const {
data: { userMeta: currentUserMeta, userProfile: currentUserProfile } = {},
} = await getClient().query(GET_USER, { userInput: null });
const currentUser = { ...currentUserMeta, ...currentUserProfile };

// get target user
const { data: { userProfile, userMeta } = {} } = await getClient().query(
GET_USER_PROFILE,
{
userInput: {
uid: id,
},
);
const user = { ...userMeta, ...userProfile };

if (userProfile === null || userMeta === null) {
notFound();
}
// console.log(user);

// if user is a club, redirect to club edit page
if (user.role === "club") {
redirect(`/manage/clubs/${user.uid}/edit`);
}

return (
<Container>
<UserForm defaultValues={user} action="save" />
</Container>
);
} catch (error) {
},
);
const user = { ...userMeta, ...userProfile };

if (
userProfile === null ||
userMeta === null ||
(currentUser?.uid !== user?.uid && currentUser?.role !== "cc") ||
["club", "cc"].includes(user?.role)
)
redirect("/404");

// get memberships of the user
const {
data: { memberRoles },
} = await getClient().query(GET_MEMBERSHIPS, {
uid: id,
});
if (memberRoles?.length === 0) notFound();

// if user is a club, redirect to club edit page
if (user.role === "club") {
redirect(`/manage/clubs/${user.uid}/edit`);
}

return (
<Container>
<UserForm defaultValues={user} action="save" />
</Container>
);
}
46 changes: 27 additions & 19 deletions src/app/profile/[id]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import UserDetails from "components/profile/UserDetails";
import { EditUser } from "components/profile/UserActions";
import UserMemberships from "components/profile/UserMemberships";

export async function generateMetadata({ params }, parent) {
export async function generateMetadata({ params }) {
const { id } = params;

try {
Expand Down Expand Up @@ -61,7 +61,7 @@ export default async function Profile({ params }) {

// if user is a club, display the club's logo as profile picture
let club = null;
if (user.role === "club") {
if (user?.role === "club") {
const { data: { club: targetClub } = {} } = await getClient().query(
GET_CLUB,
{ clubInput: { cid: user.uid } },
Expand All @@ -71,7 +71,7 @@ export default async function Profile({ params }) {

// get memberships if user is a person
let memberships = [];
if (user.role === "public") {
if (user?.role === "public") {
const {
data: { memberRoles },
} = await getClient().query(GET_MEMBERSHIPS, {
Expand All @@ -83,17 +83,22 @@ export default async function Profile({ params }) {
(cv, m) => cv.concat(m.roles.map((r) => ({ ...r, cid: m.cid }))),
[],
);

if (memberships?.length === 0 && currentUser?.uid !== user.uid) {
notFound();
}
}

return (
<Container>
{/*
{/*
show action palette only
1. if current user is CC, or
2. if current user is viewing their own profile and is not a club
*/}
{currentUser?.role === "cc" ||
(currentUser?.uid === user.uid && user.role !== "club") ? (
{!["club", "cc"].includes(user?.role) &&
(currentUser?.role === "cc" ||
(memberships?.length !== 0 && currentUser?.uid === user?.uid)) ? (
<ActionPalette right={[EditUser]} />
) : null}
<Grid container spacing={2} mt={4}>
Expand Down Expand Up @@ -145,20 +150,23 @@ export default async function Profile({ params }) {
</Stack>
</Grid>

<Grid item container xs spacing={2} mt={5}>
<UserDetails user={user} />
</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 }}>
{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>
<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
2 changes: 1 addition & 1 deletion src/app/tech-team/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default async function TechTeam() {
padding: 2.5,
}}
>
<SLCTechLogo height={120} width={300} />
<SLCTechLogo height={120} width={500} />
</Grid>

<Typography variant="h3" mb={2}>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import useMediaQuery from "@mui/material/useMediaQuery";

import Icon from "components/Icon";
import SLCTechLogo from "components/SLCTechLogo";
import LifeLogo from "components/LifeLogo";
import LifeLogo from "components/svg/life-logo-full-color.svg";

const IIITLogo = "/assets/iiit-logo-white.png";

Expand Down Expand Up @@ -99,7 +99,7 @@ export default function Footer() {
</div>
</Box>
<Box>
<SLCTechLogo height={50} width={130} />
<SLCTechLogo height={40} width={150} />
</Box>
</Grid>
<Grid
Expand Down
9 changes: 7 additions & 2 deletions src/components/ImageMasonry.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ import { useTheme } from "@mui/material/styles";

import ImageModal from "components/ImageModal";

export default function ImageMasonry({ images, limit = undefined, cols = 4 }) {
export default function ImageMasonry({
images,
limit = undefined,
cols = 4,
priority = true,
}) {
const theme = useTheme();
const isDesktop = useMediaQuery(theme.breakpoints.up("lg"));

Expand Down Expand Up @@ -118,7 +123,7 @@ export default function ImageMasonry({ images, limit = undefined, cols = 4 }) {
onLoad={() => {
handleImageLoad();
}}
priority={true}
priority={priority}
style={{ display: "none" }}
/>
))}
Expand Down
5 changes: 3 additions & 2 deletions src/components/Layout.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "@mui/material";
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
import EmojiEventsOutlinedIcon from "@mui/icons-material/EmojiEventsOutlined";

import { bgBlur } from "utils/cssStyles";
import Logo from "components/Logo";
Expand Down Expand Up @@ -114,7 +115,7 @@ function Drawer({ drawerOpen, onCloseDrawer }) {
/>
<DrawerDropdown
title="clubs council"
icon={<Icon variant="diversity-2-outline-rounded" />}
icon={<EmojiEventsOutlinedIcon sx={{ width: 20, height: 20 }} />}
>
<DrawerItem
title="clubs"
Expand Down Expand Up @@ -286,7 +287,7 @@ function Drawer({ drawerOpen, onCloseDrawer }) {
<DrawerItem
title="SLC Tech Team"
path="/tech-team"
icon={<Icon variant="cloud-outline" />}
icon={<Icon variant="laptop-chromebook-outline-rounded" />}
/>
</List>
);
Expand Down
23 changes: 0 additions & 23 deletions src/components/LifeLogo.jsx

This file was deleted.

2 changes: 1 addition & 1 deletion src/components/Logo.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useTheme } from "@mui/material/styles";
import useMediaQuery from "@mui/material/useMediaQuery";
import LifeLogo from "components/LifeLogo";
import LifeLogo from "components/svg/life-logo-full-color.svg";

export default function Logo() {
const theme = useTheme();
Expand Down
2 changes: 1 addition & 1 deletion src/components/SLCTechLogo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Image from "next/image";

import { useTheme } from "@mui/material/styles";

const SLCTechLogoPath = "/assets/slc-tech-logo-black.svg";
const SLCTechLogoPath = "/assets/slc-tech-logo-black.png";

export default function SLCTechLogo({ height, width }) {
const theme = useTheme();
Expand Down
9 changes: 7 additions & 2 deletions src/components/members/MemberCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,20 @@ export default async function MemberCard({ uid, poc, roles }) {
user = { ...userMeta, ...userProfile1 };
}

// 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
variant="outlined"
raised={false}
sx={{ backgroundColor: "inherit", border: "none", boxShadow: 0 }}
>
<CardActionArea
// TODO: Link to public user profile
component={Link}
component={clickable ? Link : "div"}
href={`/profile/${uid}`}
disabled={userProfile === null}
sx={{
Expand Down
Loading

0 comments on commit db8dc49

Please sign in to comment.