From 51ccdd7e28597bb037a57f8c0c1a6d4c88e482f5 Mon Sep 17 00:00:00 2001 From: nickbar01234 Date: Sun, 10 Mar 2024 21:36:33 -0400 Subject: [PATCH] Add resource page to remaining view --- .../[uid]/admin/home/resources/page.tsx | 2 +- .../[uid]/chapter-leader/home/layout.tsx | 16 +++--- .../chapter-leader/home/resources/page.tsx | 17 ++++++ src/app/private/[uid]/user/home/layout.tsx | 16 +++--- .../[uid]/user/home/resources/page.tsx | 17 ++++++ src/components/DisplayResources.tsx | 57 ++++++++++--------- src/components/TabButtons.tsx | 2 +- src/components/admin/DisplayChapter.tsx | 3 +- 8 files changed, 85 insertions(+), 45 deletions(-) create mode 100644 src/app/private/[uid]/chapter-leader/home/resources/page.tsx create mode 100644 src/app/private/[uid]/user/home/resources/page.tsx diff --git a/src/app/private/[uid]/admin/home/resources/page.tsx b/src/app/private/[uid]/admin/home/resources/page.tsx index c3c35d24..7fce4ede 100644 --- a/src/app/private/[uid]/admin/home/resources/page.tsx +++ b/src/app/private/[uid]/admin/home/resources/page.tsx @@ -4,7 +4,7 @@ import { prisma } from "@server/db/client"; const AdminResourcesPage = async () => { const resources = await prisma.resource.findMany(); - return ; + return ; }; export default AdminResourcesPage; diff --git a/src/app/private/[uid]/chapter-leader/home/layout.tsx b/src/app/private/[uid]/chapter-leader/home/layout.tsx index 35437555..7adea8d2 100644 --- a/src/app/private/[uid]/chapter-leader/home/layout.tsx +++ b/src/app/private/[uid]/chapter-leader/home/layout.tsx @@ -13,13 +13,15 @@ const Layout = async ({ children }: LayoutProps) => { headerIcon={faHouse} showHorizontalLine={false} > - - {children} +
+ + {children} +
); }; diff --git a/src/app/private/[uid]/chapter-leader/home/resources/page.tsx b/src/app/private/[uid]/chapter-leader/home/resources/page.tsx new file mode 100644 index 00000000..c173cd80 --- /dev/null +++ b/src/app/private/[uid]/chapter-leader/home/resources/page.tsx @@ -0,0 +1,17 @@ +import DisplayResources from "@components/DisplayResources"; +import { prisma } from "@server/db/client"; + +const ChapterLeaderResourcesPage = async () => { + const resources = await prisma.resource.findMany({ + where: { + access: { + has: "CHAPTER_LEADER", + }, + }, + }); + return ( + + ); +}; + +export default ChapterLeaderResourcesPage; diff --git a/src/app/private/[uid]/user/home/layout.tsx b/src/app/private/[uid]/user/home/layout.tsx index 244e61a5..2fad7c32 100644 --- a/src/app/private/[uid]/user/home/layout.tsx +++ b/src/app/private/[uid]/user/home/layout.tsx @@ -25,13 +25,15 @@ const Layout = async ({ children, params, joinChapter }: LayoutProps) => { headerIcon={faHouse} showHorizontalLine={false} > - - {children} +
+ + {children} +
); } else { diff --git a/src/app/private/[uid]/user/home/resources/page.tsx b/src/app/private/[uid]/user/home/resources/page.tsx new file mode 100644 index 00000000..0d8a562f --- /dev/null +++ b/src/app/private/[uid]/user/home/resources/page.tsx @@ -0,0 +1,17 @@ +import DisplayResources from "@components/DisplayResources"; +import { prisma } from "@server/db/client"; + +const UserResourcesPage = async () => { + const resources = await prisma.resource.findMany({ + where: { + access: { + isEmpty: true, + }, + }, + }); + return ( + + ); +}; + +export default UserResourcesPage; diff --git a/src/components/DisplayResources.tsx b/src/components/DisplayResources.tsx index 182e0545..f35640b7 100644 --- a/src/components/DisplayResources.tsx +++ b/src/components/DisplayResources.tsx @@ -18,6 +18,7 @@ import { createResourceSchema } from "@api/resources/route.schema"; interface IDisplayResources { resources: Resource[]; showRole: boolean; + editable: boolean; } interface ResourceState extends Resource { @@ -127,41 +128,43 @@ const DisplayResources = (props: IDisplayResources) => { }, [stateResources, setCanSubmit]); return ( -
-
- - {edit ? ( +
+ {props.editable && ( +
- ) : ( - - )} -
+ {edit ? ( + + ) : ( + + )} +
+ )} {loading ? (
) : ( -
+
{stateResources .filter((resource) => resource.state !== "DELETED") .map((eachResource) => ( diff --git a/src/components/TabButtons.tsx b/src/components/TabButtons.tsx index 77befadd..1637c40e 100644 --- a/src/components/TabButtons.tsx +++ b/src/components/TabButtons.tsx @@ -21,7 +21,7 @@ const TabButtons = ({ queries }: TabButtonsProps) => {
{queries.map(({ segment, name }, index) => { const isTabSelected = - pathName.includes(segment) || (urlSegment === null && index === 0); + pathName.endsWith(segment) || (urlSegment === null && index === 0); const base = pathName.match( new RegExp( diff --git a/src/components/admin/DisplayChapter.tsx b/src/components/admin/DisplayChapter.tsx index 02eb66ec..e4020ca3 100644 --- a/src/components/admin/DisplayChapter.tsx +++ b/src/components/admin/DisplayChapter.tsx @@ -66,8 +66,7 @@ const DisplayChapter = (props: DisplayChapterProps) => { dateCreated={chapter.dateCreated} /> Executive Board
} + title={
Executive Board
} tiles={eboardMembers.map((user) => (