Skip to content

Commit

Permalink
Restructure route to not use uid
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbar01234 committed Apr 9, 2024
1 parent 820221b commit 7e01f10
Show file tree
Hide file tree
Showing 46 changed files with 229 additions and 292 deletions.
52 changes: 0 additions & 52 deletions src/app/private/[uid]/admin/layout.tsx

This file was deleted.

54 changes: 0 additions & 54 deletions src/app/private/[uid]/chapter-leader/layout.tsx

This file was deleted.

37 changes: 0 additions & 37 deletions src/app/private/[uid]/layout.tsx

This file was deleted.

42 changes: 0 additions & 42 deletions src/app/private/[uid]/user/layout.tsx

This file was deleted.

File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import DisplayChapterInfo from "@components/DisplayChapterInfo";

interface ChapterPageParams {
params: {
uid: string;
chapterId: string;
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import { CardGrid } from "@components/container";

interface Params {
params: {
uid: string;
userId: string;
chapterId: string;
};
}

const UserPage = async ({ params }: Params) => {
const { userId, chapterId, uid } = params;
const { userId, chapterId } = params;

const user = await prisma.user.findUniqueOrThrow({
where: { id: userId, ChapterID: chapterId },
Expand Down Expand Up @@ -42,7 +41,7 @@ const UserPage = async ({ params }: Params) => {
<UserTile
key={senior.id}
senior={senior}
link={`/private/${uid}/admin/home/chapters/${chapterId}/users/${userId}/seniors/${senior.id}`}
link={`/private/admin/home/chapters/${chapterId}/users/${userId}/seniors/${senior.id}`}
/>
))}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ interface Params {
const SeniorPage = async ({ params }: Params) => {
const { userId, chapterId, seniorId } = params;

// TODO(nickbar01234) - Associate each senior to a chapter
const senior = await prisma.senior.findUniqueOrThrow({
where: {
id: seniorId,
Expand Down Expand Up @@ -44,7 +43,6 @@ const SeniorPage = async ({ params }: Params) => {
{ display: `${senior.firstname} ${senior.lastname}`, url: seniorId },
]}
/>

<CardGrid
title={
<>
Expand Down
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions src/app/private/admin/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ISideBar } from "@components/Sidebar";
import { CollapsibleSidebarContainer } from "@components/container";
import {
faEnvelope,
faHome,
faHouseLock,
faUser,
} from "@fortawesome/free-solid-svg-icons";

interface IAdminLayout {
children: React.ReactNode;
}

const AdminLayout = ({ children }: IAdminLayout) => {
const buttons: ISideBar["buttons"] = [
{
name: "Home",
link: `/private/admin/home`,
icon: faHome,
},
{
name: "Pending",
link: `/private/admin/pending-chapters`,
icon: faHouseLock,
},
{
name: "E-list",
link: `/private/admin/elist`,
icon: faEnvelope,
},
{
name: "Profile",
link: `/private/admin/edit-profile`,
icon: faUser,
},
];

return (
<CollapsibleSidebarContainer buttons={buttons}>
{children}
</CollapsibleSidebarContainer>
);
};

export default AdminLayout;
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import DisplayChapterInfo from "@components/DisplayChapterInfo";
import { prisma } from "@server/db/client";
import { getServerSessionOrRedirect } from "@server/utils";

interface UserHomePageParams {
params: {
Expand All @@ -8,14 +9,10 @@ interface UserHomePageParams {
}

const UserHomePage = async ({ params }: UserHomePageParams) => {
const user = await prisma.user.findFirstOrThrow({
where: {
id: params.uid,
},
});
const session = await getServerSessionOrRedirect();
const chapter = await prisma.chapter.findFirstOrThrow({
where: {
id: user.ChapterID ?? "",
id: session.user?.ChapterID ?? "",
},
include: {
students: {
Expand Down
41 changes: 41 additions & 0 deletions src/app/private/chapter-leader/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ISideBar } from "@components/Sidebar";
import { CollapsibleSidebarContainer } from "@components/container";
import { faHome, faUser, faUserGroup } from "@fortawesome/free-solid-svg-icons";

interface IUserLayout {
children: React.ReactNode;
}

const UserLayout = ({ children }: IUserLayout) => {
const buttons: ISideBar["buttons"] = [
{
name: "Home",
link: `/private/chapter-leader/home`,
icon: faHome,
},
{
name: "Members",
link: `/private/chapter-leader/users`,
icon: faUserGroup,
},
// @TODO(nickbar01234) - Fix icon
{
name: "Seniors",
link: `/private/chapter-leader/seniors`,
icon: faUserGroup,
},
{
name: "Profile",
link: `/private/chapter-leader/edit-profile`,
icon: faUser,
},
];

return (
<CollapsibleSidebarContainer buttons={buttons}>
{children}
</CollapsibleSidebarContainer>
);
};

export default UserLayout;
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@ import React from "react";
import { prisma } from "@server/db/client";
import { SeniorView } from "@components/SeniorView";
import { compareSenior } from "@utils";
import { getServerSessionOrRedirect } from "@server/utils";

const UserSeniorsPage = async ({ params }: { params: { uid: string } }) => {
const userUid = params.uid;
const user = await prisma.user.findUnique({
where: {
id: userUid,
},
});
if (!user) {
return <div>User not found</div>;
}

const UserSeniorsPage = async () => {
const session = await getServerSessionOrRedirect();
// Fetch the seniors too
const chapter = await prisma.chapter.findFirst({
where: {
id: user.ChapterID ?? undefined,
id: session.user?.ChapterID ?? undefined,
},
include: {
seniors: {},
Expand Down
Loading

0 comments on commit 7e01f10

Please sign in to comment.