diff --git a/src/APIFunctions/SCEvents.js b/src/APIFunctions/SCEvents.js index 2d4ffafff..a8a83e556 100644 --- a/src/APIFunctions/SCEvents.js +++ b/src/APIFunctions/SCEvents.js @@ -1,7 +1,6 @@ import { ApiResponse } from './ApiResponses'; const SCEVENTS_API_URL = 'http://localhost:8002'; - export async function getAllSCEvents() { const status = new ApiResponse(); try { @@ -55,3 +54,25 @@ export async function createSCEvent(eventBody) { } return status; } + +export async function updateSCEvent(id, userId, eventUpdates) { + const status = new ApiResponse(); + try { + const res = await fetch(`${SCEVENTS_API_URL}/events/${id}?user_id=${userId}`, { + method: 'PATCH', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify(eventUpdates), + }); + const body = await res.json(); + status.responseData = body; + if (!res.ok) { + status.error = true; + } + } catch (err) { + status.error = true; + status.responseData = err; + } + return status; +} diff --git a/src/Pages/Events/CreateEventPage.js b/src/Pages/Events/CreateEventPage.js index 6c65efe80..a76d04fb6 100644 --- a/src/Pages/Events/CreateEventPage.js +++ b/src/Pages/Events/CreateEventPage.js @@ -238,8 +238,8 @@ export default function CreateEventPage() { return (
+ Only officers and administrators can edit events. +
+ + Back to events + ++ You are not an admin of this event. +
+ + Back to events + +Event id: {id}
+