From 6bcd20897de020bacf4b7f38a5020233947eba6e Mon Sep 17 00:00:00 2001 From: Brandon Egger Date: Mon, 22 May 2023 23:08:56 -0500 Subject: [PATCH] control bar shows conditionally based on if user is signed in --- src/components/admin/ControlBar.tsx | 18 ++++++++++++------ src/pages/resources/[id]/edit.tsx | 13 +++++++++++++ src/pages/resources/[id]/index.tsx | 4 +++- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/components/admin/ControlBar.tsx b/src/components/admin/ControlBar.tsx index 3d4c66a..46818d9 100644 --- a/src/components/admin/ControlBar.tsx +++ b/src/components/admin/ControlBar.tsx @@ -1,3 +1,5 @@ +import { useSession } from "next-auth/react"; + const AdminBarLayout = ({ actions, children, @@ -5,14 +7,18 @@ const AdminBarLayout = ({ actions: JSX.Element | JSX.Element[]; children: JSX.Element | JSX.Element[]; }) => { + const { data } = useSession(); + return (
-
-

- Admin Mode -

-
{actions}
-
+ {data?.user ? ( +
+

+ Admin Mode +

+
{actions}
+
+ ) : undefined} {children}
); diff --git a/src/pages/resources/[id]/edit.tsx b/src/pages/resources/[id]/edit.tsx index e69de29..a985821 100644 --- a/src/pages/resources/[id]/edit.tsx +++ b/src/pages/resources/[id]/edit.tsx @@ -0,0 +1,13 @@ +import Footer from "~/components/Footer"; +import Header from "~/components/Header"; + +const EditResourcePage = () => { + return ( + <> +
+