Mobile API: Event

Add:
- src/app/api/mobile/admin/event/[id]/participants/
- src/app/api/mobile/admin/master/type-of-event/
This commit is contained in:
nabillah
2025-10-24 16:37:40 +08:00
parent 70849ba2a9
commit 577ee38220
4 changed files with 183 additions and 34 deletions

View File

@@ -0,0 +1,53 @@
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 data = await prisma.event_Peserta.findMany({
where: {
eventId: id,
},
select: {
eventId: true,
userId: true,
isPresent: true,
User: {
select: {
id: true,
username: true,
nomor: true,
Profile: {
select: {
id: true,
name: true,
imageId: true,
},
},
},
},
},
});
return NextResponse.json(
{
success: true,
message: "Success get participants",
data: data,
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: false,
message: "Error get participants",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}