Fix event
Deskripsi: - Fix user server menjadi API di beranda
This commit is contained in:
15
src/app/api/event/check-peserta/route.ts
Normal file
15
src/app/api/event/check-peserta/route.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { event_funCheckPesertaByUserId } from "@/app_modules/event/fun";
|
||||
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");
|
||||
|
||||
const res = await event_funCheckPesertaByUserId({
|
||||
eventId: eventId as string,
|
||||
userId: userId as string,
|
||||
});
|
||||
|
||||
return NextResponse.json(res, { status: 200 });
|
||||
}
|
||||
16
src/app/api/event/list-peserta/route.ts
Normal file
16
src/app/api/event/list-peserta/route.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { event_newGetListPesertaById } from "@/app_modules/event/fun";
|
||||
import { toNumber } from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(req: Request) {
|
||||
const { searchParams } = new URL(req.url);
|
||||
const eventId = searchParams.get("eventId");
|
||||
const page = searchParams.get("page");
|
||||
|
||||
const res = await event_newGetListPesertaById({
|
||||
eventId: eventId as string,
|
||||
page: toNumber(page),
|
||||
});
|
||||
|
||||
return NextResponse.json(res, { status: 200 });
|
||||
}
|
||||
@@ -11,8 +11,7 @@ export default async function Page({ params }: { params: { id: string } }) {
|
||||
return (
|
||||
<>
|
||||
<Event_DetailKontribusi
|
||||
dataEvent={dataEvent as any}
|
||||
listKontributor={listKontributor as any}
|
||||
eventId={eventId}
|
||||
totalPeserta={totalPeserta}
|
||||
/>
|
||||
</>
|
||||
|
||||
@@ -1,27 +1,18 @@
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import { newFunGetUserId } from "@/app/lib/new_fun_user_id";
|
||||
import { Event_DetailMain } from "@/app_modules/event";
|
||||
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||
import { Event_CekUserJoinById } from "@/app_modules/event/fun/get/cek_user_join_by_id";
|
||||
import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
const userLoginId : any= await funGetUserIdByToken();
|
||||
|
||||
const dataEvent = await event_getOneById(eventId);
|
||||
const listPeserta = await Event_getListPesertaById(eventId);
|
||||
const isJoin = await Event_CekUserJoinById(eventId, userLoginId);
|
||||
const userLoginId = await newFunGetUserId();
|
||||
const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Event_DetailMain
|
||||
dataEvent={dataEvent as any}
|
||||
listPeserta={listPeserta as any}
|
||||
userLoginId={userLoginId as string}
|
||||
isJoin={isJoin}
|
||||
totalPeserta={totalPeserta as any}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -6,15 +6,14 @@ import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
const dataEvent = await event_getOneById(eventId);
|
||||
const listPeserta = await Event_getListPesertaById(eventId);
|
||||
const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
|
||||
return (
|
||||
<Event_DetailPublish
|
||||
dataEvent={dataEvent as any}
|
||||
listPeserta={listPeserta}
|
||||
totalPeserta={totalPeserta}
|
||||
eventId={eventId}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,21 +1,15 @@
|
||||
|
||||
import { Event_DetailRiwayat } from "@/app_modules/event";
|
||||
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
|
||||
import { Event_getListPesertaById } from "@/app_modules/event/fun/get/get_list_peserta_by_id";
|
||||
import { event_getOneById } from "@/app_modules/event/fun/get/get_one_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let eventId = params.id;
|
||||
const dataEvent = await event_getOneById(eventId);
|
||||
const listPeserta = await Event_getListPesertaById(eventId);
|
||||
const totalPeserta = await Event_countTotalPesertaById(eventId);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Event_DetailRiwayat
|
||||
dataEvent={dataEvent as any}
|
||||
listPeserta={listPeserta as any}
|
||||
totalPeserta={totalPeserta as any}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { newFunGetUserId } from "@/app/lib/new_fun_user_id";
|
||||
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
|
||||
import Ui_Konfirmasi from "@/app_modules/event/_ui/konfirmasi";
|
||||
import { event_funCheckPesertaByUserId } from "@/app_modules/event/fun";
|
||||
@@ -11,33 +12,11 @@ export default async function Page({
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const eventId = (await params).id;
|
||||
|
||||
|
||||
// const userLoginId = await funGetUserIdByToken();
|
||||
|
||||
// const checkPeserta = await event_funCheckPesertaByUserId({
|
||||
// eventId: eventId,
|
||||
// userId: userLoginId as string,
|
||||
// });
|
||||
|
||||
// if (dataEvent == null) return redirect("/dev/event/main/beranda");
|
||||
|
||||
// if (moment(dataEvent?.tanggal).diff(moment(), "minutes") > 0)
|
||||
// return redirect("/dev/event/main/beranda");
|
||||
|
||||
// if (dataEvent?.isArsip)
|
||||
// return redirect(`/dev/event/detail/riwayat/${dataEvent.id}`);
|
||||
|
||||
// if (checkPeserta == false)
|
||||
// return redirect(`/dev/event/detail/main/${eventId}`);
|
||||
|
||||
// if (checkKehadiran) {
|
||||
// return redirect(`/dev/event/main/beranda`);
|
||||
// }
|
||||
const userLoginId = await newFunGetUserId();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Ui_Konfirmasi userLoginId={"" as string} eventId={eventId} />
|
||||
<Ui_Konfirmasi userLoginId={userLoginId as string} eventId={eventId} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,4 +4,7 @@ export const API_RouteEvent = {
|
||||
`/api/event/get-one-by-id?eventId=${eventId}`,
|
||||
check_kehadiran: ({ eventId, userId }: { eventId: string; userId: string }) =>
|
||||
`/api/event/check-kehadiran?eventId=${eventId}&userId=${userId}`,
|
||||
check_peserta: ({ eventId, userId }: { eventId: string; userId: string }) =>
|
||||
`/api/event/check-peserta?eventId=${eventId}&userId=${userId}`,
|
||||
list_peserta: ({ eventId, page }: { eventId: string, page: number }) => `/api/event/list-peserta?eventId=${eventId}&page=${page}`,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user