fix ( event )

deskripsi:
- fix API detail dan pindah list peserta ke halaman beebeda
This commit is contained in:
2025-01-20 15:49:00 +08:00
parent 1f46b6bfec
commit 2feb461c5b
15 changed files with 313 additions and 168 deletions

View File

@@ -0,0 +1,50 @@
import { prisma } from "@/app/lib";
import { NextResponse } from "next/server";
export async function GET(
request: Request,
context: { params: { id: string } }
) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json(
{ success: false, message: "Method not allowed" },
{ status: 405 }
);
}
try {
let fixData;
const { id } = context.params;
fixData = await prisma.event.findUnique({
where: {
id: id,
},
include: {
Author: {
include: {
Profile: true,
},
},
EventMaster_TipeAcara: true,
EventMaster_Status: true,
},
});
await prisma.$disconnect();
return NextResponse.json({
success: true,
message: "Berhasil mendapatkan data",
data: fixData,
});
} catch (error) {
await prisma.$disconnect();
return NextResponse.json(
{ success: false, message: "Gagal mendapatkan data" },
{ status: 500 }
);
}
}

View File

@@ -1,8 +1,16 @@
import { event_funCheckKehadiran } from "@/app_modules/event/fun";
import { NextResponse } from "next/server";
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
export async function GET(request: Request) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json(
{ success: false, message: "Method not allowed" },
{ status: 405 }
);
}
const { searchParams } = new URL(request.url);
const userId = searchParams.get("userId");
const eventId = searchParams.get("eventId");

View File

@@ -1,15 +1,50 @@
import { event_funCheckPesertaByUserId } from "@/app_modules/event/fun";
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function GET(req: Request) {
const { searchParams } = new URL(req.url);
const userId = searchParams.get("userId");
const eventId = searchParams.get("eventId");
export async function GET(request: Request) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json(
{ success: false, message: "Method not allowed" },
{ status: 405 }
);
}
const res = await event_funCheckPesertaByUserId({
eventId: eventId as string,
userId: userId as string,
});
try {
let fixData;
const { searchParams } = new URL(request.url);
const userId = searchParams.get("userId");
const eventId = searchParams.get("eventId");
return NextResponse.json(res, { status: 200 });
const check = await prisma.event_Peserta.findFirst({
where: {
userId: userId,
eventId: eventId,
},
});
if (check) {
fixData = true;
} else {
fixData = false;
}
await prisma.$disconnect();
return NextResponse.json(
{ success: true, message: "Success get data", data: fixData },
{ status: 200 }
);
} catch (error) {
await prisma.$disconnect();
backendLogger.error("Error get data detail event:", error);
return NextResponse.json(
{
success: false,
message: "Gagal mendapatkan data",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}