From 00aba53b1e51061952c481912d8e45d36c4f2cf4 Mon Sep 17 00:00:00 2001 From: nickbar01234 Date: Wed, 6 Mar 2024 14:57:37 -0500 Subject: [PATCH 1/9] Fix sidebar initial state change senior name to first name and last name Co-authored-by: Tyler finish first draft Co-authored-by: Tyler reverted senior firstname/lastname field --- prisma/schema.prisma | 40 +++++++------- .../chapter-leader/edit-profile/layout.tsx | 20 +++++++ .../chapter-leader/edit-profile/page.tsx | 3 + .../chapter-leader/home/@joinChapter/page.tsx | 31 +++++++++++ .../[uid]/chapter-leader/home/layout.tsx | 42 ++++++++++++++ .../[uid]/chapter-leader/home/page.tsx | 55 +++++++++++++++++++ .../private/[uid]/chapter-leader/layout.tsx | 55 +++++++++++++++++++ .../members/MembersHomePage.tsx | 52 ++++++++++++++++++ .../[uid]/chapter-leader/members/layout.tsx | 20 +++++++ .../[uid]/chapter-leader/members/page.tsx | 24 ++++++++ .../pending/PendingHomePage.tsx | 34 ++++++++++++ .../[uid]/chapter-leader/pending/layout.tsx | 20 +++++++ .../[uid]/chapter-leader/pending/page.tsx | 34 ++++++++++++ src/app/private/[uid]/user/layout.tsx | 4 ++ .../[uid]/user/seniors/SeniorsHomePage.tsx | 40 ++++++++------ src/components/Sidebar.tsx | 28 ++++++++++ src/components/TileGrid/UserTile.tsx | 2 +- src/components/admin/DisplayChapter.tsx | 1 + 18 files changed, 468 insertions(+), 37 deletions(-) create mode 100644 src/app/private/[uid]/chapter-leader/edit-profile/layout.tsx create mode 100644 src/app/private/[uid]/chapter-leader/edit-profile/page.tsx create mode 100644 src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx create mode 100644 src/app/private/[uid]/chapter-leader/home/layout.tsx create mode 100644 src/app/private/[uid]/chapter-leader/home/page.tsx create mode 100644 src/app/private/[uid]/chapter-leader/layout.tsx create mode 100644 src/app/private/[uid]/chapter-leader/members/MembersHomePage.tsx create mode 100644 src/app/private/[uid]/chapter-leader/members/layout.tsx create mode 100644 src/app/private/[uid]/chapter-leader/members/page.tsx create mode 100644 src/app/private/[uid]/chapter-leader/pending/PendingHomePage.tsx create mode 100644 src/app/private/[uid]/chapter-leader/pending/layout.tsx create mode 100644 src/app/private/[uid]/chapter-leader/pending/page.tsx diff --git a/prisma/schema.prisma b/prisma/schema.prisma index c9af638e..3c1b2b75 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -46,7 +46,7 @@ model Session { } model User { - id String @id @default(auto()) @map("_id") @db.ObjectId + id String @id @default(auto()) @map("_id") @db.ObjectId // https://github.com/nextauthjs/next-auth/blob/v4/packages/next-auth/src/providers/google.ts // Fields mappable from PrismaAdapter. We can map the value return from profle() in [...nextauth]. @@ -86,7 +86,7 @@ enum Role { model Senior { id String @id @default(auto()) @map("_id") @db.ObjectId - name String + name String @default("") location String description String StudentIDs String[] @db.ObjectId @@ -98,13 +98,13 @@ model Senior { } model File { - id String @id @default(auto()) @map("_id") @db.ObjectId - date DateTime // will zero out the hours - filetype String - url String - seniorId String @db.ObjectId - senior Senior @relation(fields: [seniorId], references: [id], onDelete: Cascade) - Tags String[] + id String @id @default(auto()) @map("_id") @db.ObjectId + date DateTime // will zero out the hours + filetype String + url String + seniorId String @db.ObjectId + senior Senior @relation(fields: [seniorId], references: [id], onDelete: Cascade) + Tags String[] @@unique([seniorId, date]) } @@ -134,20 +134,20 @@ model Chapter { } model Resource { - id String @id @default(auto()) @map("_id") @db.ObjectId - access Role[] - link String - title String + id String @id @default(auto()) @map("_id") @db.ObjectId + access Role[] + link String + title String } model Email { - id String @id @default(auto()) @map("_id") @db.ObjectId - email String @unique + id String @id @default(auto()) @map("_id") @db.ObjectId + email String @unique } model UserRequest { - id String @id @default(auto()) @map("_id") @db.ObjectId - approved Approval @default(PENDING) - uid String @db.ObjectId @unique - chapterId String @db.ObjectId -} \ No newline at end of file + id String @id @default(auto()) @map("_id") @db.ObjectId + approved Approval @default(PENDING) + uid String @unique @db.ObjectId + chapterId String @db.ObjectId +} diff --git a/src/app/private/[uid]/chapter-leader/edit-profile/layout.tsx b/src/app/private/[uid]/chapter-leader/edit-profile/layout.tsx new file mode 100644 index 00000000..9946e8ba --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/edit-profile/layout.tsx @@ -0,0 +1,20 @@ +import { HeaderContainer } from "@components/container/index"; +import { faUser } from "@fortawesome/free-regular-svg-icons"; + +interface IEditProfileLayout { + children: React.ReactNode; +} + +const EditProfileLayout = ({ children }: IEditProfileLayout) => { + return ( + + {children} + + ); +}; + +export default EditProfileLayout; diff --git a/src/app/private/[uid]/chapter-leader/edit-profile/page.tsx b/src/app/private/[uid]/chapter-leader/edit-profile/page.tsx new file mode 100644 index 00000000..6dace489 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/edit-profile/page.tsx @@ -0,0 +1,3 @@ +import { EditProfileForm } from "@components/user"; + +export default EditProfileForm; diff --git a/src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx b/src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx new file mode 100644 index 00000000..6440defe --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx @@ -0,0 +1,31 @@ +import { UserJoinRequest } from "@components/user"; +import { prisma } from "@server/db/client"; + +interface UserHomePageParams { + params: { + uid: string; + }; +} + +const UserJoinChapterPage = async ({ params }: UserHomePageParams) => { + const chapters = await prisma.chapter.findMany({ + include: { + students: true, + }, + }); + const joinRequest = await prisma.userRequest.findFirst({ + where: { + uid: params.uid, + }, + }); + + return ( + + ); +}; + +export default UserJoinChapterPage; diff --git a/src/app/private/[uid]/chapter-leader/home/layout.tsx b/src/app/private/[uid]/chapter-leader/home/layout.tsx new file mode 100644 index 00000000..244e61a5 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/home/layout.tsx @@ -0,0 +1,42 @@ +import { prisma } from "@server/db/client"; +import TabButtons from "@components/TabButtons"; +import { HeaderContainer } from "@components/container/index"; +import { faHouse } from "@fortawesome/free-solid-svg-icons"; + +interface LayoutProps { + children: React.ReactNode; + joinChapter: React.ReactNode; + params: { + uid: string; + }; +} + +const Layout = async ({ children, params, joinChapter }: LayoutProps) => { + const user = await prisma.user.findFirstOrThrow({ + where: { + id: params.uid, + }, + }); + + if (user.ChapterID != null) { + return ( + + + {children} + + ); + } else { + return joinChapter; + } +}; + +export default Layout; diff --git a/src/app/private/[uid]/chapter-leader/home/page.tsx b/src/app/private/[uid]/chapter-leader/home/page.tsx new file mode 100644 index 00000000..e3f666f9 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/home/page.tsx @@ -0,0 +1,55 @@ +import { UserTile } from "@components/TileGrid"; +import DisplayChapterInfo from "@components/DisplayChapterInfo"; +import { prisma } from "@server/db/client"; +import { CardGrid } from "@components/container"; + +interface UserHomePageParams { + params: { + uid: string; + }; +} + +const UserHomePage = async ({ params }: UserHomePageParams) => { + const user = await prisma.user.findFirstOrThrow({ + where: { + id: params.uid, + }, + }); + const chapter = await prisma.chapter.findFirstOrThrow({ + where: { + id: user.ChapterID ?? "", + }, + include: { + students: true, + }, + }); + + return ( +
+
+ {chapter.chapterName} +
+ user.role == "USER").length + } + dateCreated={chapter.dateCreated} + /> + + Executive Board +
+ } + tiles={chapter.students + .filter((user) => user.role == "CHAPTER_LEADER") + .map((user) => ( + + ))} + /> + + ); +}; + +export default UserHomePage; diff --git a/src/app/private/[uid]/chapter-leader/layout.tsx b/src/app/private/[uid]/chapter-leader/layout.tsx new file mode 100644 index 00000000..56845964 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/layout.tsx @@ -0,0 +1,55 @@ +"use client"; + +import Sidebar, { ISideBar } from "@components/Sidebar"; +import { + faHome, + faUser, + faUserGroup, + faUserPlus, +} from "@fortawesome/free-solid-svg-icons"; +import React, { useContext } from "react"; +import { UserContext } from "src/context/UserProvider"; + +interface IUserLayout { + children: React.ReactNode; +} + +const UserLayout = ({ children }: IUserLayout) => { + const { user } = useContext(UserContext); + const buttons: ISideBar["buttons"] = React.useMemo( + () => [ + { + name: "Home", + link: `/private/${user.id}/chapter-leader/home`, + icon: faHome, + }, + { + name: "Members", + link: `/private/${user.id}/chapter-leader/members`, + icon: faUserGroup, + }, + { + name: "Pending", + link: `/private/${user.id}/chapter-leader/pending`, + icon: faUserPlus, + }, + { + name: "Profile", + link: `/private/${user.id}/chapter-leader/edit-profile`, + icon: faUser, + }, + ], + [user.id] + ); + + return ( +
+
+ +
+
{children}
+
+ ); +}; + +export default UserLayout; diff --git a/src/app/private/[uid]/chapter-leader/members/MembersHomePage.tsx b/src/app/private/[uid]/chapter-leader/members/MembersHomePage.tsx new file mode 100644 index 00000000..07653e89 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/members/MembersHomePage.tsx @@ -0,0 +1,52 @@ +"use client"; + +import { useState } from "react"; +import { UserTile } from "@components/TileGrid"; +import { CardGrid } from "@components/container"; +import SearchBar from "@components/SearchBar"; +import { User } from "@prisma/client"; + +type MembersHomePageProps = { + members: User[]; + user: User; +}; + +const MembersHomePage = ({ members, user }: MembersHomePageProps) => { + const [filter, setFilter] = useState(""); + + return ( + <> +

+ {`Members (${members.length})`} +

+
+ +
+ {members.length > 0 ? ( + + (member.firstName + " " + member.lastName) + .toLowerCase() + .includes(filter.toLowerCase()) + ) + .map((member, index) => { + return ( + + ); + })} + /> + ) : ( +

+ {"This chapter has no members."} +

+ )} + + ); +}; + +export default MembersHomePage; diff --git a/src/app/private/[uid]/chapter-leader/members/layout.tsx b/src/app/private/[uid]/chapter-leader/members/layout.tsx new file mode 100644 index 00000000..b52667ac --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/members/layout.tsx @@ -0,0 +1,20 @@ +import { HeaderContainer } from "@components/container"; +import { faUserGroup } from "@fortawesome/free-solid-svg-icons"; + +interface LayoutProps { + children?: React.ReactNode; +} + +const Layout = (props: LayoutProps) => { + return ( + + {props.children} + + ); +}; + +export default Layout; diff --git a/src/app/private/[uid]/chapter-leader/members/page.tsx b/src/app/private/[uid]/chapter-leader/members/page.tsx new file mode 100644 index 00000000..1165f864 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/members/page.tsx @@ -0,0 +1,24 @@ +import React from "react"; +import { prisma } from "@server/db/client"; +import MembersHomePage from "./MembersHomePage"; + +const MembersPage = async ({ params }: { params: { uid: string } }) => { + const user = await prisma.user.findFirstOrThrow({ + where: { + id: params.uid, + }, + }); + + const chapter = await prisma.chapter.findFirstOrThrow({ + where: { + id: user.ChapterID ?? "", + }, + include: { + students: true, + }, + }); + + return ; +}; + +export default MembersPage; diff --git a/src/app/private/[uid]/chapter-leader/pending/PendingHomePage.tsx b/src/app/private/[uid]/chapter-leader/pending/PendingHomePage.tsx new file mode 100644 index 00000000..29644307 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/pending/PendingHomePage.tsx @@ -0,0 +1,34 @@ +"use client"; + +import PendingCard from "@components/PendingCard"; +import { CardGrid } from "@components/container"; +import { User } from "@prisma/client"; + +type MembersHomePageProps = { + users: User[]; +}; + +const PendingHomePage = ({ users }: MembersHomePageProps) => { + return ( + <> +

+ {`Pending (${users.length})`} +

+ {users.length > 0 ? ( + { + return ( + + ); + })} + /> + ) : ( +

+ {"This chapter has no members."} +

+ )} + + ); +}; + +export default PendingHomePage; diff --git a/src/app/private/[uid]/chapter-leader/pending/layout.tsx b/src/app/private/[uid]/chapter-leader/pending/layout.tsx new file mode 100644 index 00000000..b52667ac --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/pending/layout.tsx @@ -0,0 +1,20 @@ +import { HeaderContainer } from "@components/container"; +import { faUserGroup } from "@fortawesome/free-solid-svg-icons"; + +interface LayoutProps { + children?: React.ReactNode; +} + +const Layout = (props: LayoutProps) => { + return ( + + {props.children} + + ); +}; + +export default Layout; diff --git a/src/app/private/[uid]/chapter-leader/pending/page.tsx b/src/app/private/[uid]/chapter-leader/pending/page.tsx new file mode 100644 index 00000000..92db5f09 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/pending/page.tsx @@ -0,0 +1,34 @@ +import React from "react"; +import { prisma } from "@server/db/client"; +import PendingHomePage from "./PendingHomePage"; +import { User } from "@prisma/client"; + +const PendingPage = async ({ params }: { params: { uid: string } }) => { + const user = await prisma.user.findFirstOrThrow({ + where: { + id: params.uid, + }, + }); + + const userRequests = await prisma.userRequest.findMany({ + where: { + chapterId: user.ChapterID ?? "", + }, + }); + + const users: User[] = []; + + for (let i = 0; i < userRequests.length; i++) { + const user = await prisma.user.findFirstOrThrow({ + where: { + id: userRequests[i]?.uid ?? "", + }, + }); + + users.push(user); + } + + return ; +}; + +export default PendingPage; diff --git a/src/app/private/[uid]/user/layout.tsx b/src/app/private/[uid]/user/layout.tsx index 7277efa2..4cf917fa 100644 --- a/src/app/private/[uid]/user/layout.tsx +++ b/src/app/private/[uid]/user/layout.tsx @@ -1,6 +1,10 @@ "use client"; +<<<<<<< HEAD import { CollapsableSidebarContainer } from "@components/container"; +======= +import Sidebar, { ISideBar } from "@components/Sidebar"; +>>>>>>> 9bd5bd7 (finish first draft) import { faHome, faUsers, faUser } from "@fortawesome/free-solid-svg-icons"; import React, { useContext } from "react"; import { UserContext } from "src/context/UserProvider"; diff --git a/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx b/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx index 304a89b7..2448f666 100644 --- a/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx +++ b/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx @@ -19,25 +19,33 @@ const SeniorsHomePage = ({ seniors, user }: SeniorsHomePageProps) => { return ( <> +

+ {`My Assigned Seniors (${seniors.length})`} +

- - senior.name.toLowerCase().includes(filter.toLowerCase()) - ) - .map((senior, index) => { - return ( - - ); - })} - /> + {seniors.length > 0 ? ( + + senior.name.toLowerCase().includes(filter.toLowerCase()) + ) + .map((senior, index) => { + return ( + + ); + })} + /> + ) : ( +

+ {"You haven't been assigned a Senior yet."} +

+ )} ); }; diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index b18b4cb6..6983941f 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -12,8 +12,11 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { UserContext } from "src/context/UserProvider"; import Logo from "@public/icons/logo.svg"; import Image from "next/image"; +<<<<<<< HEAD import { RoleAlias } from "@constants/RoleAlias"; import { fullName } from "@utils"; +======= +>>>>>>> 9bd5bd7 (finish first draft) interface Button { name: string; @@ -98,6 +101,7 @@ const Sidebar = (props: ISideBar) => {
<_Sidebar {...props} />
+<<<<<<< HEAD
setSidebarVisible(false)} @@ -119,6 +123,30 @@ const Sidebar = (props: ISideBar) => { <_Sidebar {...props} />
)} +======= + +
+ {/* TODO(nickbar01234) - Render university name */} + {/*
+
+ +
+ University +
+
+ Tufts University +
*/} +
+
+ {user.name ?? ""} +
+
+ {user.role[0] + user.role.toLowerCase().slice(1)} +
+ +>>>>>>> 9bd5bd7 (finish first draft)
); diff --git a/src/components/TileGrid/UserTile.tsx b/src/components/TileGrid/UserTile.tsx index 7a0a63df..f0616bc4 100644 --- a/src/components/TileGrid/UserTile.tsx +++ b/src/components/TileGrid/UserTile.tsx @@ -54,7 +54,7 @@ export function UserTile({

{student && student.name ? student.name + (student.admin ? " (Admin)" : "") - : senior && senior.name + : senior ? senior.name : null}

diff --git a/src/components/admin/DisplayChapter.tsx b/src/components/admin/DisplayChapter.tsx index 02eb66ec..d8b91205 100644 --- a/src/components/admin/DisplayChapter.tsx +++ b/src/components/admin/DisplayChapter.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react/jsx-no-duplicate-props */ "use client"; import { editRole } from "@api/user/[uid]/edit-role/route.client"; From 90e198541c95e1600aed581ea4389ea6fb2e7fcf Mon Sep 17 00:00:00 2001 From: tylerrlin Date: Wed, 6 Mar 2024 20:11:04 -0500 Subject: [PATCH 2/9] rebased and resolved merge conflicts --- src/app/private/[uid]/user/layout.tsx | 4 ---- src/components/Sidebar.tsx | 28 --------------------------- 2 files changed, 32 deletions(-) diff --git a/src/app/private/[uid]/user/layout.tsx b/src/app/private/[uid]/user/layout.tsx index 4cf917fa..7277efa2 100644 --- a/src/app/private/[uid]/user/layout.tsx +++ b/src/app/private/[uid]/user/layout.tsx @@ -1,10 +1,6 @@ "use client"; -<<<<<<< HEAD import { CollapsableSidebarContainer } from "@components/container"; -======= -import Sidebar, { ISideBar } from "@components/Sidebar"; ->>>>>>> 9bd5bd7 (finish first draft) import { faHome, faUsers, faUser } from "@fortawesome/free-solid-svg-icons"; import React, { useContext } from "react"; import { UserContext } from "src/context/UserProvider"; diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx index 6983941f..b18b4cb6 100644 --- a/src/components/Sidebar.tsx +++ b/src/components/Sidebar.tsx @@ -12,11 +12,8 @@ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { UserContext } from "src/context/UserProvider"; import Logo from "@public/icons/logo.svg"; import Image from "next/image"; -<<<<<<< HEAD import { RoleAlias } from "@constants/RoleAlias"; import { fullName } from "@utils"; -======= ->>>>>>> 9bd5bd7 (finish first draft) interface Button { name: string; @@ -101,7 +98,6 @@ const Sidebar = (props: ISideBar) => {
<_Sidebar {...props} />
-<<<<<<< HEAD
setSidebarVisible(false)} @@ -123,30 +119,6 @@ const Sidebar = (props: ISideBar) => { <_Sidebar {...props} />
)} -======= - -
- {/* TODO(nickbar01234) - Render university name */} - {/*
-
- -
- University -
-
- Tufts University -
*/} -
-
- {user.name ?? ""} -
-
- {user.role[0] + user.role.toLowerCase().slice(1)} -
- ->>>>>>> 9bd5bd7 (finish first draft)
); From 2f93e6937fb1ff810c7a0d27f4ebeedbecb4066a Mon Sep 17 00:00:00 2001 From: nickbar01234 Date: Wed, 6 Mar 2024 21:52:34 -0500 Subject: [PATCH 3/9] Revert prisma --- prisma/schema.prisma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3c1b2b75..0d6b5a5b 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -86,7 +86,7 @@ enum Role { model Senior { id String @id @default(auto()) @map("_id") @db.ObjectId - name String @default("") + name String location String description String StudentIDs String[] @db.ObjectId From efd941ac0cd7134da21ccf41266f0844d02a1d28 Mon Sep 17 00:00:00 2001 From: nickbar01234 Date: Wed, 6 Mar 2024 21:57:02 -0500 Subject: [PATCH 4/9] Add default for senior name --- prisma/schema.prisma | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 0d6b5a5b..93130938 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -86,7 +86,7 @@ enum Role { model Senior { id String @id @default(auto()) @map("_id") @db.ObjectId - name String + name String @default("") location String description String StudentIDs String[] @db.ObjectId From 62454e4207c09ab3649ec2b44c2182f67faf3d8b Mon Sep 17 00:00:00 2001 From: nickbar01234 Date: Wed, 6 Mar 2024 22:09:23 -0500 Subject: [PATCH 5/9] Update route --- src/app/private/[uid]/chapter-leader/layout.tsx | 12 +++++------- .../{members => users}/MembersHomePage.tsx | 2 +- .../chapter-leader/{members => users}/layout.tsx | 0 .../[uid]/chapter-leader/{members => users}/page.tsx | 0 4 files changed, 6 insertions(+), 8 deletions(-) rename src/app/private/[uid]/chapter-leader/{members => users}/MembersHomePage.tsx (93%) rename src/app/private/[uid]/chapter-leader/{members => users}/layout.tsx (100%) rename src/app/private/[uid]/chapter-leader/{members => users}/page.tsx (100%) diff --git a/src/app/private/[uid]/chapter-leader/layout.tsx b/src/app/private/[uid]/chapter-leader/layout.tsx index 56845964..1c70bd35 100644 --- a/src/app/private/[uid]/chapter-leader/layout.tsx +++ b/src/app/private/[uid]/chapter-leader/layout.tsx @@ -1,6 +1,7 @@ "use client"; import Sidebar, { ISideBar } from "@components/Sidebar"; +import { CollapsableSidebarContainer } from "@components/container"; import { faHome, faUser, @@ -25,7 +26,7 @@ const UserLayout = ({ children }: IUserLayout) => { }, { name: "Members", - link: `/private/${user.id}/chapter-leader/members`, + link: `/private/${user.id}/chapter-leader/users`, icon: faUserGroup, }, { @@ -43,12 +44,9 @@ const UserLayout = ({ children }: IUserLayout) => { ); return ( -
-
- -
-
{children}
-
+ + {children} + ); }; diff --git a/src/app/private/[uid]/chapter-leader/members/MembersHomePage.tsx b/src/app/private/[uid]/chapter-leader/users/MembersHomePage.tsx similarity index 93% rename from src/app/private/[uid]/chapter-leader/members/MembersHomePage.tsx rename to src/app/private/[uid]/chapter-leader/users/MembersHomePage.tsx index 07653e89..f5a68a70 100644 --- a/src/app/private/[uid]/chapter-leader/members/MembersHomePage.tsx +++ b/src/app/private/[uid]/chapter-leader/users/MembersHomePage.tsx @@ -35,7 +35,7 @@ const MembersHomePage = ({ members, user }: MembersHomePageProps) => { ); })} diff --git a/src/app/private/[uid]/chapter-leader/members/layout.tsx b/src/app/private/[uid]/chapter-leader/users/layout.tsx similarity index 100% rename from src/app/private/[uid]/chapter-leader/members/layout.tsx rename to src/app/private/[uid]/chapter-leader/users/layout.tsx diff --git a/src/app/private/[uid]/chapter-leader/members/page.tsx b/src/app/private/[uid]/chapter-leader/users/page.tsx similarity index 100% rename from src/app/private/[uid]/chapter-leader/members/page.tsx rename to src/app/private/[uid]/chapter-leader/users/page.tsx From 52d043e6653dbf83761f9e4848cc69885497900a Mon Sep 17 00:00:00 2001 From: nickbar01234 Date: Wed, 6 Mar 2024 23:46:59 -0500 Subject: [PATCH 6/9] Rename route --- .../chapter-leader/home/@joinChapter/page.tsx | 31 ------------ .../[uid]/chapter-leader/home/layout.tsx | 47 +++++++------------ 2 files changed, 16 insertions(+), 62 deletions(-) delete mode 100644 src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx diff --git a/src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx b/src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx deleted file mode 100644 index 6440defe..00000000 --- a/src/app/private/[uid]/chapter-leader/home/@joinChapter/page.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { UserJoinRequest } from "@components/user"; -import { prisma } from "@server/db/client"; - -interface UserHomePageParams { - params: { - uid: string; - }; -} - -const UserJoinChapterPage = async ({ params }: UserHomePageParams) => { - const chapters = await prisma.chapter.findMany({ - include: { - students: true, - }, - }); - const joinRequest = await prisma.userRequest.findFirst({ - where: { - uid: params.uid, - }, - }); - - return ( - - ); -}; - -export default UserJoinChapterPage; diff --git a/src/app/private/[uid]/chapter-leader/home/layout.tsx b/src/app/private/[uid]/chapter-leader/home/layout.tsx index 244e61a5..35437555 100644 --- a/src/app/private/[uid]/chapter-leader/home/layout.tsx +++ b/src/app/private/[uid]/chapter-leader/home/layout.tsx @@ -1,42 +1,27 @@ -import { prisma } from "@server/db/client"; import TabButtons from "@components/TabButtons"; import { HeaderContainer } from "@components/container/index"; import { faHouse } from "@fortawesome/free-solid-svg-icons"; interface LayoutProps { children: React.ReactNode; - joinChapter: React.ReactNode; - params: { - uid: string; - }; } -const Layout = async ({ children, params, joinChapter }: LayoutProps) => { - const user = await prisma.user.findFirstOrThrow({ - where: { - id: params.uid, - }, - }); - - if (user.ChapterID != null) { - return ( - - - {children} - - ); - } else { - return joinChapter; - } +const Layout = async ({ children }: LayoutProps) => { + return ( + + + {children} + + ); }; export default Layout; From e10353ede47a59d3c503af7e1e342ee51bf6deb8 Mon Sep 17 00:00:00 2001 From: wkim10 Date: Sun, 10 Mar 2024 13:48:27 -0400 Subject: [PATCH 7/9] address PR comments :) Co-authored-by: Tyler --- .../[uid]/chapter-leader/pending/page.tsx | 1 + .../chapter-leader/users/MembersHomePage.tsx | 52 +++++++----------- .../[uid]/user/seniors/SeniorsHomePage.tsx | 55 ++++++++----------- src/components/admin/DisplayChapter.tsx | 1 - 4 files changed, 45 insertions(+), 64 deletions(-) diff --git a/src/app/private/[uid]/chapter-leader/pending/page.tsx b/src/app/private/[uid]/chapter-leader/pending/page.tsx index 92db5f09..42a97be7 100644 --- a/src/app/private/[uid]/chapter-leader/pending/page.tsx +++ b/src/app/private/[uid]/chapter-leader/pending/page.tsx @@ -13,6 +13,7 @@ const PendingPage = async ({ params }: { params: { uid: string } }) => { const userRequests = await prisma.userRequest.findMany({ where: { chapterId: user.ChapterID ?? "", + approved: "PENDING", }, }); diff --git a/src/app/private/[uid]/chapter-leader/users/MembersHomePage.tsx b/src/app/private/[uid]/chapter-leader/users/MembersHomePage.tsx index f5a68a70..8c3d7a8e 100644 --- a/src/app/private/[uid]/chapter-leader/users/MembersHomePage.tsx +++ b/src/app/private/[uid]/chapter-leader/users/MembersHomePage.tsx @@ -1,9 +1,7 @@ "use client"; -import { useState } from "react"; import { UserTile } from "@components/TileGrid"; -import { CardGrid } from "@components/container"; -import SearchBar from "@components/SearchBar"; +import SearchableContainer from "@components/SearchableContainer"; import { User } from "@prisma/client"; type MembersHomePageProps = { @@ -12,39 +10,31 @@ type MembersHomePageProps = { }; const MembersHomePage = ({ members, user }: MembersHomePageProps) => { - const [filter, setFilter] = useState(""); + const displayMembers = (elem: User, index: number) => ( + + ); return ( <> -

+

{`Members (${members.length})`}

-
- -
- {members.length > 0 ? ( - - (member.firstName + " " + member.lastName) - .toLowerCase() - .includes(filter.toLowerCase()) - ) - .map((member, index) => { - return ( - - ); - })} - /> - ) : ( -

- {"This chapter has no members."} -

- )} + This chapter has no members. + } + search={(member: User, filter: string) => + (member.firstName + " " + member.lastName) + .toLowerCase() + .includes(filter.toLowerCase()) + } + /> ); }; diff --git a/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx b/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx index 2448f666..38a83d91 100644 --- a/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx +++ b/src/app/private/[uid]/user/seniors/SeniorsHomePage.tsx @@ -1,13 +1,8 @@ "use client"; -import { useState } from "react"; import { UserTile } from "@components/TileGrid"; -import { CardGrid } from "@components/container"; -import { TileEdit } from "@components/TileGrid/TileEdit"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import { faEllipsis, faTrashCan } from "@fortawesome/free-solid-svg-icons"; -import SearchBar from "@components/SearchBar"; import { Senior, User } from "@prisma/client"; +import SearchableContainer from "@components/SearchableContainer"; type SeniorsHomePageProps = { seniors: Senior[]; @@ -15,37 +10,33 @@ type SeniorsHomePageProps = { }; const SeniorsHomePage = ({ seniors, user }: SeniorsHomePageProps) => { - const [filter, setFilter] = useState(""); + const displaySeniors = (elem: Senior, index: number) => ( + + ); return ( <> -

+

{`My Assigned Seniors (${seniors.length})`}

-
- -
- {seniors.length > 0 ? ( - - senior.name.toLowerCase().includes(filter.toLowerCase()) - ) - .map((senior, index) => { - return ( - - ); - })} - /> - ) : ( -

- {"You haven't been assigned a Senior yet."} -

- )} + + {"You haven't been assigned a Senior yet."} + + } + search={(senior: Senior, filter: string) => + (senior.firstName + " " + senior.lastName) + .toLowerCase() + .includes(filter.toLowerCase()) + } + /> ); }; diff --git a/src/components/admin/DisplayChapter.tsx b/src/components/admin/DisplayChapter.tsx index d8b91205..02eb66ec 100644 --- a/src/components/admin/DisplayChapter.tsx +++ b/src/components/admin/DisplayChapter.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/jsx-no-duplicate-props */ "use client"; import { editRole } from "@api/user/[uid]/edit-role/route.client"; From 9fad44efe77ff688d5120de6607b903b9011096f Mon Sep 17 00:00:00 2001 From: wkim10 Date: Sun, 10 Mar 2024 17:49:21 +0000 Subject: [PATCH 8/9] Prettified Code! --- src/app/api/chapter-request/route.schema.ts | 8 +- src/app/api/chapter-request/route.ts | 2 +- src/app/api/resources/route.ts | 172 +++++++++--------- src/app/api/toy-example/route.client.ts | 1 - src/app/api/user/[uid]/edit-profile/route.ts | 2 +- .../[uid]/admin/home/chapters/page.tsx | 1 - src/app/private/[uid]/admin/home/page.tsx | 1 - .../[uid]/admin/home/resources/page.tsx | 1 - src/components/FilterDropdown.tsx | 2 +- src/components/FlowerBox.tsx | 14 +- src/components/PhotoCarousel.tsx | 68 +++---- src/components/Tag.tsx | 26 +-- src/pages/api/sendgrid/subscribe.ts | 20 +- src/pages/api/senior/[id]/students.ts | 5 +- src/pages/api/student/[id]/approve.tsx | 4 +- src/pages/api/student/[id]/index.tsx | 21 ++- src/pages/api/student/[id]/seniors.tsx | 2 +- src/pages/test-api.tsx | 6 +- 18 files changed, 180 insertions(+), 176 deletions(-) diff --git a/src/app/api/chapter-request/route.schema.ts b/src/app/api/chapter-request/route.schema.ts index 3ef1a9c6..f14a8dde 100644 --- a/src/app/api/chapter-request/route.schema.ts +++ b/src/app/api/chapter-request/route.schema.ts @@ -20,8 +20,12 @@ export const ChapterRequest = z.object({ phoneNumber: z.string().length(10, "Phone number must be 10 digits"), university: z.string().min(1, "Please provide a university"), universityAddress: z.string().min(1, "Please provide an address"), - leadershipExperience: z.string().min(1, "Please state some leadership experience"), - motivation: z.string().min(1, "Please describe your motivation in joining the legacy project"), + leadershipExperience: z + .string() + .min(1, "Please state some leadership experience"), + motivation: z + .string() + .min(1, "Please describe your motivation in joining the legacy project"), // TODO: Figure out if availabilities should have a better type availabilities: z.string().min(1, "Please provide some times"), questions: z.string(), diff --git a/src/app/api/chapter-request/route.ts b/src/app/api/chapter-request/route.ts index 50c36767..1c5174f7 100644 --- a/src/app/api/chapter-request/route.ts +++ b/src/app/api/chapter-request/route.ts @@ -69,5 +69,5 @@ export const POST = async (request: NextRequest) => { }), { status: 500 } ); - } + } }; diff --git a/src/app/api/resources/route.ts b/src/app/api/resources/route.ts index 02c2e722..76f53e3f 100644 --- a/src/app/api/resources/route.ts +++ b/src/app/api/resources/route.ts @@ -1,86 +1,86 @@ -import { NextResponse } from "next/server"; -import { - batchCreateRequestSchema, - batchDeleteRequestSchema, - batchResponseSchema, - batchUpdateRequestSchema, -} from "./route.schema"; -import { prisma } from "@server/db/client"; -import { invalidFormReponse } from "../route.schema"; -import { withSessionAndRole } from "@server/decorator"; - -export const POST = withSessionAndRole(["ADMIN"], async (request) => { - const resourceRequest = batchCreateRequestSchema.safeParse( - await request.req.json() - ); - if (!resourceRequest.success) { - return NextResponse.json(invalidFormReponse, { status: 400 }); - } else { - const body = resourceRequest.data; - const resources = await prisma.$transaction( - body.map((resource) => - prisma.resource.create({ - data: { - access: resource.access, - title: resource.title, - link: resource.link, - }, - }) - ) - ); - return NextResponse.json( - batchResponseSchema.parse({ code: "SUCCESS", data: resources }) - ); - } -}); - -export const PUT = withSessionAndRole(["ADMIN"], async (request) => { - const resourceRequest = batchUpdateRequestSchema.safeParse( - await request.req.json() - ); - if (!resourceRequest.success) { - return NextResponse.json(invalidFormReponse, { status: 400 }); - } else { - await prisma.$transaction( - resourceRequest.data.map((resource) => - prisma.resource.update({ - where: { - id: resource.id, - }, - data: { - access: resource.access, - title: resource.title, - link: resource.link, - }, - }) - ) - ); - - return NextResponse.json( - batchResponseSchema.parse({ code: "SUCCESS", data: resourceRequest.data }) - ); - } -}); - -export const DELETE = withSessionAndRole(["ADMIN"], async (request) => { - const resourceRequest = batchDeleteRequestSchema.safeParse( - await request.req.json() - ); - if (!resourceRequest.success) { - return NextResponse.json(invalidFormReponse, { status: 400 }); - } else { - const body = resourceRequest.data; - const resources = await prisma.$transaction( - body.map((id) => - prisma.resource.delete({ - where: { - id: id, - }, - }) - ) - ); - return NextResponse.json( - batchResponseSchema.parse({ code: "SUCCESS", data: resources }) - ); - } -}); +import { NextResponse } from "next/server"; +import { + batchCreateRequestSchema, + batchDeleteRequestSchema, + batchResponseSchema, + batchUpdateRequestSchema, +} from "./route.schema"; +import { prisma } from "@server/db/client"; +import { invalidFormReponse } from "../route.schema"; +import { withSessionAndRole } from "@server/decorator"; + +export const POST = withSessionAndRole(["ADMIN"], async (request) => { + const resourceRequest = batchCreateRequestSchema.safeParse( + await request.req.json() + ); + if (!resourceRequest.success) { + return NextResponse.json(invalidFormReponse, { status: 400 }); + } else { + const body = resourceRequest.data; + const resources = await prisma.$transaction( + body.map((resource) => + prisma.resource.create({ + data: { + access: resource.access, + title: resource.title, + link: resource.link, + }, + }) + ) + ); + return NextResponse.json( + batchResponseSchema.parse({ code: "SUCCESS", data: resources }) + ); + } +}); + +export const PUT = withSessionAndRole(["ADMIN"], async (request) => { + const resourceRequest = batchUpdateRequestSchema.safeParse( + await request.req.json() + ); + if (!resourceRequest.success) { + return NextResponse.json(invalidFormReponse, { status: 400 }); + } else { + await prisma.$transaction( + resourceRequest.data.map((resource) => + prisma.resource.update({ + where: { + id: resource.id, + }, + data: { + access: resource.access, + title: resource.title, + link: resource.link, + }, + }) + ) + ); + + return NextResponse.json( + batchResponseSchema.parse({ code: "SUCCESS", data: resourceRequest.data }) + ); + } +}); + +export const DELETE = withSessionAndRole(["ADMIN"], async (request) => { + const resourceRequest = batchDeleteRequestSchema.safeParse( + await request.req.json() + ); + if (!resourceRequest.success) { + return NextResponse.json(invalidFormReponse, { status: 400 }); + } else { + const body = resourceRequest.data; + const resources = await prisma.$transaction( + body.map((id) => + prisma.resource.delete({ + where: { + id: id, + }, + }) + ) + ); + return NextResponse.json( + batchResponseSchema.parse({ code: "SUCCESS", data: resources }) + ); + } +}); diff --git a/src/app/api/toy-example/route.client.ts b/src/app/api/toy-example/route.client.ts index 8e951d6f..c4cf0f98 100644 --- a/src/app/api/toy-example/route.client.ts +++ b/src/app/api/toy-example/route.client.ts @@ -1,4 +1,3 @@ - import { z } from "zod"; import { SignInRequest, SignInResponse } from "./route.schema"; diff --git a/src/app/api/user/[uid]/edit-profile/route.ts b/src/app/api/user/[uid]/edit-profile/route.ts index b7df15fa..7df49535 100644 --- a/src/app/api/user/[uid]/edit-profile/route.ts +++ b/src/app/api/user/[uid]/edit-profile/route.ts @@ -13,7 +13,7 @@ export const PATCH = withSession(async ({ session, req, params }) => { return NextResponse.json( EditProfileResponse.parse({ code: "UNAUTHORIZED", - message: "The action cannot be performed by the current user" + message: "The action cannot be performed by the current user", }), { status: 400 } ); diff --git a/src/app/private/[uid]/admin/home/chapters/page.tsx b/src/app/private/[uid]/admin/home/chapters/page.tsx index f7da73bc..95ad1703 100644 --- a/src/app/private/[uid]/admin/home/chapters/page.tsx +++ b/src/app/private/[uid]/admin/home/chapters/page.tsx @@ -8,7 +8,6 @@ const AdminChaptersPage = async () => { }, }); - return ; }; diff --git a/src/app/private/[uid]/admin/home/page.tsx b/src/app/private/[uid]/admin/home/page.tsx index b7243614..377d4180 100644 --- a/src/app/private/[uid]/admin/home/page.tsx +++ b/src/app/private/[uid]/admin/home/page.tsx @@ -8,7 +8,6 @@ const AdminHomePageWrapper = async () => { }, }); - return ; }; diff --git a/src/app/private/[uid]/admin/home/resources/page.tsx b/src/app/private/[uid]/admin/home/resources/page.tsx index f3428ca8..c3c35d24 100644 --- a/src/app/private/[uid]/admin/home/resources/page.tsx +++ b/src/app/private/[uid]/admin/home/resources/page.tsx @@ -1,7 +1,6 @@ import DisplayResources from "@components/DisplayResources"; import { prisma } from "@server/db/client"; - const AdminResourcesPage = async () => { const resources = await prisma.resource.findMany(); diff --git a/src/components/FilterDropdown.tsx b/src/components/FilterDropdown.tsx index 55c7fedd..56b658c8 100644 --- a/src/components/FilterDropdown.tsx +++ b/src/components/FilterDropdown.tsx @@ -84,7 +84,7 @@ export default function FilterDropdown({ > {filteredItems.map((item: T, index: number) => ( { onItemSelect(index, item); diff --git a/src/components/FlowerBox.tsx b/src/components/FlowerBox.tsx index e5e7dcc1..f1f96311 100644 --- a/src/components/FlowerBox.tsx +++ b/src/components/FlowerBox.tsx @@ -7,12 +7,12 @@ interface FlowerBoxProps { const FlowerBox = ({ children }: FlowerBoxProps) => { return (
- {children} + {children} - + { alt="Pink flower top left frame" /> - + { alt="Pink flower bottom left frame" /> - + { alt="Pink flower top right frame" /> - + { const [photos, setPhotos] = useState([]); const [activeIndex, setActiveIndex] = useState(0); const [show, setShow] = useState(1); const widthRef = useRef(null); - + const [elemWidth, setElemWidth] = useState(0); - + useEffect(() => { - function handleResize() { + function handleResize() { setElemWidth(widthRef.current ? widthRef.current.offsetWidth : 0); - const showVal = widthRef.current ? Math.floor(widthRef.current.offsetWidth / 250) : 1; + const showVal = widthRef.current + ? Math.floor(widthRef.current.offsetWidth / 250) + : 1; setShow(showVal || 1); } window.addEventListener("resize", handleResize); handleResize(); - return () => { window.removeEventListener("resize", handleResize) } + return () => { + window.removeEventListener("resize", handleResize); + }; }, []); const carouselHeight = elemWidth / show; @@ -40,7 +43,7 @@ const PhotoCarousel = () => { { filePath: "/gallery/Tufts Legacy-255.jpg", caption: "picture3" }, { filePath: "/gallery/Tufts Legacy-258.jpg", caption: "picture4" }, ]); - }, []); + }, []); const nextIndex = () => { setActiveIndex(activeIndex === show - 1 ? 0 : activeIndex - 1); @@ -51,8 +54,7 @@ const PhotoCarousel = () => { }; return ( -
+
{/* photo carousel */}
{
- { - photos.map( - (photo, index) => - ( -
- {photo.caption} -
- ) - )} + {photos.map((photo, index) => ( +
+ {photo.caption} +
+ ))}
(tagList.map((tag) => [tag.name, tag.color])); +export const tagMap = new Map( + tagList.map((tag) => [tag.name, tag.color]) +); const Tag = ({ name, color }: TagProps) => { return (
{name}
diff --git a/src/pages/api/sendgrid/subscribe.ts b/src/pages/api/sendgrid/subscribe.ts index b4434568..996e73a9 100644 --- a/src/pages/api/sendgrid/subscribe.ts +++ b/src/pages/api/sendgrid/subscribe.ts @@ -1,11 +1,11 @@ import type { NextApiRequest, NextApiResponse } from "next"; -import { Client } from "@sendgrid/client" +import { Client } from "@sendgrid/client"; const subscribe = async (req: NextApiRequest, res: NextApiResponse) => { try { const client = new Client(); if (!process.env.SENDGRID_API_KEY) { - throw new Error("No SendGrid API key variable in environment file.") + throw new Error("No SendGrid API key variable in environment file."); } client.setApiKey(process.env.SENDGRID_API_KEY); @@ -13,20 +13,20 @@ const subscribe = async (req: NextApiRequest, res: NextApiResponse) => { method: "PUT", url: "/v3/marketing/contacts", body: { - contacts: [{ email: req.body.to }] - } - }) + contacts: [{ email: req.body.to }], + }, + }); if (subscribeRes.statusCode != 220) { - throw new Error("Validation error in submitting new email contact.") + throw new Error("Validation error in submitting new email contact."); } - // TODO: check for no-longer-pending import contacts status? + // TODO: check for no-longer-pending import contacts status? } catch (error) { - res.status(500).json(error); + res.status(500).json(error); } res.status(200); -} +}; -export default subscribe; \ No newline at end of file +export default subscribe; diff --git a/src/pages/api/senior/[id]/students.ts b/src/pages/api/senior/[id]/students.ts index 4c8936cc..c1185c3b 100644 --- a/src/pages/api/senior/[id]/students.ts +++ b/src/pages/api/senior/[id]/students.ts @@ -3,7 +3,6 @@ import { prisma } from "@server/db/client"; import { getServerAuthSession } from "@server/common/get-server-auth-session"; import { z } from "zod"; - const students = async (req: NextApiRequest, res: NextApiResponse) => { const session = await getServerAuthSession({ req, res }); @@ -33,7 +32,7 @@ const students = async (req: NextApiRequest, res: NextApiResponse) => { admin: true, //return admin boolean field for given user id }, })) ?? { admin: false }; - + if (!admin) { res.status(500).json({ error: @@ -60,7 +59,7 @@ const students = async (req: NextApiRequest, res: NextApiResponse) => { }); return; } - + res.status(200).json({ students: result.Students }); } catch (error) { res.status(500).json({ diff --git a/src/pages/api/student/[id]/approve.tsx b/src/pages/api/student/[id]/approve.tsx index b2c5663d..3cc4f05c 100644 --- a/src/pages/api/student/[id]/approve.tsx +++ b/src/pages/api/student/[id]/approve.tsx @@ -77,7 +77,9 @@ const approve = async (req: NextApiRequest, res: NextApiResponse) => { fileId: baseFolder, fields: "id", }; - await (service as NonNullable).permissions.create(permData); + await (service as NonNullable).permissions.create( + permData + ); res.status(200).json(student); } catch (error) { diff --git a/src/pages/api/student/[id]/index.tsx b/src/pages/api/student/[id]/index.tsx index 058c9c64..16989901 100644 --- a/src/pages/api/student/[id]/index.tsx +++ b/src/pages/api/student/[id]/index.tsx @@ -83,29 +83,30 @@ const student = async (req: NextApiRequest, res: NextApiResponse) => { })) ?? { admin: false }; const studentSchema = z.object({ - SeniorIDs: z.array(z.string()) + SeniorIDs: z.array(z.string()), }); const body = studentSchema.parse(JSON.parse(req.body)); if (admin) { - const student = (await prisma.user.update({ - where : { + const student = await prisma.user.update({ + where: { id: studentId, }, data: { - ...body - } - })); + ...body, + }, + }); - res.status(200).json(student); + res.status(200).json(student); } else { res.status(500).json({ - error: "This route is protected. In order to access it, please sign in as admin." + error: + "This route is protected. In order to access it, please sign in as admin.", }); } } catch (error) { res.status(500).json({ - error: `Failed to update student: ${error}` + error: `Failed to update student: ${error}`, }); } break; @@ -143,7 +144,7 @@ const student = async (req: NextApiRequest, res: NextApiResponse) => { } } catch (error) { res.status(500).json({ - error: `Failed to delete student: ${error}` + error: `Failed to delete student: ${error}`, }); } diff --git a/src/pages/api/student/[id]/seniors.tsx b/src/pages/api/student/[id]/seniors.tsx index 723637dc..0669b4a5 100644 --- a/src/pages/api/student/[id]/seniors.tsx +++ b/src/pages/api/student/[id]/seniors.tsx @@ -14,7 +14,7 @@ const seniors = async (req: NextApiRequest, res: NextApiResponse) => { } const { id: studentId } = req.query; - + if (typeof studentId !== "string") { res.status(500).json({ error: `studentId must be a string`, diff --git a/src/pages/test-api.tsx b/src/pages/test-api.tsx index dd35ee05..aa176961 100644 --- a/src/pages/test-api.tsx +++ b/src/pages/test-api.tsx @@ -112,7 +112,7 @@ const TestApi = () => { return (
{/* FILE ROUTES */} - + /api/file/ {/* SENIOR ROUTES */} - + /api/seniors/ {/* STUDENT ROUTES */} - + /api/students/