From f732a98ee4a1a3c0867cdae57131c8c97c5a9be9 Mon Sep 17 00:00:00 2001 From: mirajismail <43501560+mirajismail@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:45:41 -0400 Subject: [PATCH] [CIT-34] Allow organizers to edit events they've created (#43) * finished org edit * Trigger build --------- Co-authored-by: Ishaan --- .../(organizers)/organizer/dashboard/[id]/page.tsx | 13 +++++++++++++ citrus/components/EventCard.tsx | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 citrus/app/(organizers)/organizer/dashboard/[id]/page.tsx diff --git a/citrus/app/(organizers)/organizer/dashboard/[id]/page.tsx b/citrus/app/(organizers)/organizer/dashboard/[id]/page.tsx new file mode 100644 index 0000000..1c1965b --- /dev/null +++ b/citrus/app/(organizers)/organizer/dashboard/[id]/page.tsx @@ -0,0 +1,13 @@ +import EditEvent from "@/components/EditEvent"; +import { getServerSession } from "next-auth"; +import { authOptions } from "@/app/api/auth/[...nextauth]/route"; + +export default async function Page( {params}: { params: {id: string }}) { + const session = await getServerSession(authOptions); + const res = await fetch(process.env.BASE_API_URL + 'api/experiences/' + params.id); + const experience = await res.json(); + if (experience.org_id !== session?.user?.name) { + return

You are not authorized to edit this event.

+ } + return +} \ No newline at end of file diff --git a/citrus/components/EventCard.tsx b/citrus/components/EventCard.tsx index 4509916..1748ab8 100644 --- a/citrus/components/EventCard.tsx +++ b/citrus/components/EventCard.tsx @@ -15,7 +15,7 @@ function deleteOnClick(eventID: string) { } function ManagementTools({ eventID, isUser }: { eventID: string, isUser: boolean }) { - const manageLink = (isUser) ? "/edit/" + eventID : "/organizer/dashboard" + eventID; + const manageLink = (isUser) ? "/edit/" + eventID : "/organizer/dashboard/" + eventID; return (