diff --git a/app/api/postedEvents/deleteEvent/route.ts b/app/api/postedEvents/deleteEvent/route.ts index f3f68ee..2463645 100644 --- a/app/api/postedEvents/deleteEvent/route.ts +++ b/app/api/postedEvents/deleteEvent/route.ts @@ -1,44 +1,44 @@ -import { NextRequest, NextResponse } from 'next/server'; -import { deleteEvent } from '../../../../database/events'; +// import { NextRequest, NextResponse } from 'next/server'; +// import { deleteEvent } from '../../../../database/events'; -type DeleteEventResponseBody = - | { message: string; event?: any } - | { message: string; error?: string }; +// type DeleteEventResponseBody = +// | { message: string; event?: any } +// | { message: string; error?: string }; -export async function DELETE( - request: NextRequest, -): Promise> { - const { searchParams } = new URL(request.url); - const eventId = searchParams.get('eventId'); - const { sessionToken } = await request.json(); +// export async function DELETE( +// request: NextRequest, +// ): Promise> { +// const { searchParams } = new URL(request.url); +// const eventId = searchParams.get('eventId'); +// const { sessionToken } = await request.json(); - if (!sessionToken || !eventId) { - return NextResponse.json( - { - message: 'Invalid request', - error: 'Session token or eventId is missing', - }, - { status: 400 }, - ); - } +// if (!sessionToken || !eventId) { +// return NextResponse.json( +// { +// message: 'Invalid request', +// error: 'Session token or eventId is missing', +// }, +// { status: 400 }, +// ); +// } - try { - const event = await deleteEvent(sessionToken, parseInt(eventId, 10)); - if (event) { - return NextResponse.json( - { message: 'Event deleted successfully', event }, - { status: 200 }, - ); - } else { - return NextResponse.json( - { message: 'Event not found or session expired' }, - { status: 404 }, - ); - } - } catch (error) { - return NextResponse.json( - { message: 'Internal server error', error: (error as Error).message }, - { status: 500 }, - ); - } -} +// try { +// const event = await deleteEvent(sessionToken, parseInt(eventId, 10)); +// if (event) { +// return NextResponse.json( +// { message: 'Event deleted successfully', event }, +// { status: 200 }, +// ); +// } else { +// return NextResponse.json( +// { message: 'Event not found or session expired' }, +// { status: 404 }, +// ); +// } +// } catch (error) { +// return NextResponse.json( +// { message: 'Internal server error', error: (error as Error).message }, +// { status: 500 }, +// ); +// } +// } diff --git a/app/imageUpload/ImageForm.tsx b/app/imageUpload/ImageForm.tsx index 9c82d7c..6b18d27 100644 --- a/app/imageUpload/ImageForm.tsx +++ b/app/imageUpload/ImageForm.tsx @@ -1,65 +1,65 @@ -'use client'; +// 'use client'; -import { useRouter } from 'next/navigation'; -import { FormEvent, useState } from 'react'; -import { ImageUploadResponsePost } from '../api/imageUpload/route'; -import ErrorMessage from '../ErrorMessage'; -import { SubmitButton } from './SubmitButton'; +// import { useRouter } from 'next/navigation'; +// import { FormEvent, useState } from 'react'; +// import { ImageUploadResponsePost } from '../api/imageUpload/route'; +// import ErrorMessage from '../ErrorMessage'; +// import { SubmitButton } from './SubmitButton'; -interface ErrorResponse { - error: string; -} +// interface ErrorResponse { +// error: string; +// } -export default function ImageForm({ - buttonTitle, - formTitle, -}: { - buttonTitle: string; - formTitle: string; -}) { - const [errorMessage, setErrorMessage] = useState(''); - const [successMessage, setSuccessMessage] = useState(''); - const router = useRouter(); +// export default function ImageForm({ +// buttonTitle, +// formTitle, +// }: { +// buttonTitle: string; +// formTitle: string; +// }) { +// const [errorMessage, setErrorMessage] = useState(''); +// const [successMessage, setSuccessMessage] = useState(''); +// const router = useRouter(); - async function handleUpload(event: FormEvent) { - event.preventDefault(); - const formData = new FormData(event.currentTarget); +// async function handleUpload(event: FormEvent) { +// event.preventDefault(); +// const formData = new FormData(event.currentTarget); - const response = await fetch('/api/imageUpload', { - method: 'POST', - body: formData, - }); +// const response = await fetch('/api/imageUpload', { +// method: 'POST', +// body: formData, +// }); - if (!response.ok) { - const errorData: ErrorResponse = await response.json(); - setErrorMessage(errorData.error); - return; - } +// if (!response.ok) { +// const errorData: ErrorResponse = await response.json(); +// setErrorMessage(errorData.error); +// return; +// } - const data: ImageUploadResponsePost | ErrorResponse = await response.json(); +// const data: ImageUploadResponsePost | ErrorResponse = await response.json(); - if ('error' in data) { - setErrorMessage(data.error); - return; - } +// if ('error' in data) { +// setErrorMessage(data.error); +// return; +// } - router.refresh(); +// router.refresh(); - setSuccessMessage('Image uploaded successfully'); - } +// setSuccessMessage('Image uploaded successfully'); +// } - return ( -
- {!!successMessage &&

{successMessage}

} - {formTitle} -
- - - - {!!errorMessage && {errorMessage}} -
- ); -} +// return ( +//
+// {!!successMessage &&

{successMessage}

} +// {formTitle} +//
+// +// +// +// {!!errorMessage && {errorMessage}} +//
+// ); +// }