API Mobile Event

Add:
- api/mobile/event/[id]/check-participants : untuk cek keikut sertaan peserta

Fix:
- api/mobile/event/route : tambah get berdasarkan kategory
- mobile/event/[id]/participants/route: clear code

### No Issue
This commit is contained in:
2025-09-15 17:22:37 +08:00
parent c89ad88d2d
commit 836d12bf2e
3 changed files with 234 additions and 65 deletions

View File

@@ -0,0 +1,48 @@
import { NextResponse } from "next/server";
import prisma from "@/lib/prisma";
export {GET}
async function GET(request: Request, { params }: { params: { id: string } }) {
try {
const { id } = params;
const { searchParams } = new URL(request.url);
const userId = searchParams.get("userId");
let fixData
const checkParticipant = await prisma.event_Peserta.findFirst({
where: {
userId: userId as any,
eventId: id,
},
});
if (checkParticipant !== null) {
fixData = true;
} else {
fixData = false;
}
return NextResponse.json(
{
success: true,
message: "Success get participants",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: false,
message: "Error get participants",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}