Update Versi 1.5.27 #32

Merged
bagasbanuna merged 1009 commits from staging into main 2025-12-17 12:22:28 +08:00
624 changed files with 24396 additions and 7342 deletions
Showing only changes of commit b0243977ab - Show all commits

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 }
);
}
}

View File

@@ -0,0 +1,71 @@
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
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;
const { searchParams } = new URL(request.url);
const page = searchParams.get("page");
const takeData = 10;
const skipData = Number(page) * takeData - takeData;
fixData = await prisma.event_Peserta.findMany({
take: takeData,
skip: skipData,
orderBy: {
updatedAt: "desc",
},
where: {
eventId: id,
},
select: {
id: true,
active: true,
createdAt: true,
updatedAt: true,
userId: true,
isPresent: true,
User: {
select: {
Profile: true,
},
},
Event: true,
eventId: true,
},
});
console.log("server", fixData)
return NextResponse.json({
success: true,
message: "Success get data",
data: fixData,
});
} catch (error) {
backendLogger.error("Error get list data:", error);
return NextResponse.json(
{
success: false,
message: "Failed get data",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}

View File

@@ -5,13 +5,12 @@ 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 listKontributor = await Event_getListPesertaById(eventId);
// const dataEvent = await event_getOneById(eventId);
// const listKontributor = await Event_getListPesertaById(eventId);
const totalPeserta = await Event_countTotalPesertaById(eventId)
return (
<>
<Event_DetailKontribusi
eventId={eventId}
totalPeserta={totalPeserta}
/>
</>

View File

@@ -2,17 +2,15 @@ import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { Event_DetailMain } from "@/app_modules/event";
import { Event_countTotalPesertaById } from "@/app_modules/event/fun/count/count_total_peserta_by_id";
export default async function Page({ params }: { params: { id: string } }) {
let eventId = params.id;
export default async function Page() {
const userLoginId = await funGetUserIdByToken();
const totalPeserta = await Event_countTotalPesertaById(eventId);
// const totalPeserta = await Event_countTotalPesertaById(eventId);
return (
<>
<Event_DetailMain
userLoginId={userLoginId as string}
totalPeserta={totalPeserta as any}
eventId={eventId}
// totalPeserta={totalPeserta as any}
/>
</>
);

View File

@@ -9,7 +9,6 @@ export default async function Page({ params }: { params: { id: string } }) {
<>
<Event_DetailRiwayat
totalPeserta={totalPeserta as any}
eventId={eventId}
/>
</>
);

View File

@@ -1,17 +1,12 @@
import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import Ui_Konfirmasi from "@/app_modules/event/_ui/konfirmasi";
export default async function Page({
params,
}: {
params: Promise<{ id: string }>;
}) {
const eventId = (await params).id;
export default async function Page() {
const userLoginId = await funGetUserIdByToken();
return (
<>
<Ui_Konfirmasi userLoginId={userLoginId as string} eventId={eventId} />
<Ui_Konfirmasi userLoginId={userLoginId as string} />
</>
);
}

View File

@@ -0,0 +1,62 @@
export const apiGetEventDetailById = async ({ id }: { id: string }) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/event/${id}`, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
};
export const apiGetEventCekPeserta = async ({
userId,
eventId,
}: {
userId: string;
eventId: string;
}) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(
`/api/event/check-peserta?userId=${userId}&eventId=${eventId}`,
{
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
}
);
return await response.json().catch(() => null);
};
export const apiGetEventPesertaById = async ({
id,
page,
}: {
id: string;
page: string;
}) => {
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
if (!token) return await token.json().catch(() => null);
const response = await fetch(`/api/event/peserta/${id}?page=${page}`, {
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"Access-Control-Allow-Origin": "*",
Authorization: `Bearer ${token}`,
},
});
return await response.json().catch(() => null);
};

View File

@@ -13,7 +13,7 @@ import { Button, Center, Group, Skeleton, Stack, Text } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useAtom } from "jotai";
import moment from "moment";
import { useRouter } from "next/navigation";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import { event_funUpdateKehadiran } from "../fun";
import { Event_funJoinAndConfirmEvent } from "../fun/create/fun_join_and_confirm";
@@ -21,31 +21,41 @@ import { gs_event_hotMenu } from "../global_state";
import { MODEL_EVENT } from "../model/interface";
import { Event_funJoinEvent } from "../fun/create/fun_join_event";
import "moment/locale/id";
import { apiGetEventDetailById } from "../_lib/api_event";
import { clientLogger } from "@/util/clientLogger";
export default function Ui_Konfirmasi({
userLoginId,
eventId,
}: {
userLoginId: string;
eventId: string;
}) {
// console.log(dataEvent);
const params = useParams<{ id: string }>();
const eventId = params.id;
const router = useRouter();
const [data, setData] = useState<MODEL_EVENT | null>(null);
const [isJoin, setIsJoin] = useState<boolean | null>(null);
const [isPresent, setIsPresent] = useState<boolean | null>(null);
// Load Data
useShallowEffect(() => {
onLoadData();
}, []);
async function onLoadData() {
const data = await fetch(
API_RouteEvent.get_one_by_id({ eventId: eventId })
);
const res = await data.json();
setData(res.data);
try {
const respone = await apiGetEventDetailById({
id: eventId,
});
if (respone) {
setData(respone.data);
}
} catch (error) {
clientLogger.error("Error get data detail event", error);
}
}
// CEK PESERTA

View File

@@ -1,12 +1,12 @@
import { RouterEvent } from '@/app/lib/router_hipmi/router_event';
import { AccentColor, MainColor } from '@/app_modules/_global/color';
import { ActionIcon, Flex, Paper, Text, Loader } from '@mantine/core';
import { IconUser } from '@tabler/icons-react';
import { useParams, useRouter } from 'next/navigation';
import React, { useState } from 'react';
import { RouterEvent } from "@/app/lib/router_hipmi/router_event";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { ActionIcon, Flex, Loader, Paper, Text } from "@mantine/core";
import { IconUsersGroup } from "@tabler/icons-react";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
function Event_ComponentBoxDaftarPeserta({ eventId }: { eventId?: string }) {
const params = useParams<{ id: string }>()
const params = useParams<{ id: string }>();
const router = useRouter();
const [isLoading, setLoading] = useState(false);
return (
@@ -28,12 +28,14 @@ function Event_ComponentBoxDaftarPeserta({ eventId }: { eventId?: string }) {
}}
>
<Flex direction={"column"} align={"center"} justify={"center"}>
<Text c={MainColor.white} fz={12}>Daftar Peserta</Text>
<Text c={MainColor.white} fz={12}>
Daftar Peserta
</Text>
<ActionIcon radius={"xl"} variant="transparent" size={60}>
{isLoading ? (
<Loader color="yellow" />
) : (
<IconUser size={70} color={MainColor.white} />
<IconUsersGroup size={40} color={MainColor.white} />
)}
</ActionIcon>
</Flex>

View File

@@ -1,9 +1,9 @@
import { RouterEvent } from '@/app/lib/router_hipmi/router_event';
import { AccentColor, MainColor } from '@/app_modules/_global/color';
import { ActionIcon, Flex, Loader, Paper, Text } from '@mantine/core';
import { IconStar } from '@tabler/icons-react';
import { useParams, useRouter } from 'next/navigation';
import { useState } from 'react';
import { TfiCup } from "react-icons/tfi";
function Event_ComponentBoxDaftarSponsor() {
const router = useRouter();
@@ -28,12 +28,14 @@ function Event_ComponentBoxDaftarSponsor() {
}}
>
<Flex direction={"column"} align={"center"} justify={"center"}>
<Text c={MainColor.white} fz={12}>Daftar Sponsor</Text>
<Text c={MainColor.white} fz={12}>
Daftar Sponsor
</Text>
<ActionIcon radius={"xl"} variant="transparent" size={60}>
{isLoading ? (
<Loader color="yellow" />
) : (
<TfiCup size={70} color={MainColor.white} />
<IconStar size={40} color={MainColor.white} />
)}
</ActionIcon>
</Flex>

View File

@@ -1,26 +1,32 @@
"use client";
import { MainColor } from "@/app_modules/_global/color";
import {
ComponentGlobal_AvatarAndUsername,
ComponentGlobal_CardStyles,
} from "@/app_modules/_global/component";
import { Center, Grid, SimpleGrid, Skeleton, Stack, Text, Title } from "@mantine/core";
import { MODEL_EVENT } from "../../model/interface";
import { clientLogger } from "@/util/clientLogger";
import {
Grid,
SimpleGrid,
Stack,
Text,
Title
} from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useState } from "react";
import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
import { Event_ComponentSkeletonDetail } from "../skeleton/comp_skeleton_detail";
import moment from "moment";
import "moment/locale/id";
import { MainColor } from "@/app_modules/_global/color";
import { useParams } from "next/navigation";
import { useState } from "react";
import { apiGetEventDetailById } from "../../_lib/api_event";
import { MODEL_EVENT } from "../../model/interface";
import { Event_ComponentSkeletonDetail } from "../skeleton/comp_skeleton_detail";
import Event_ComponentBoxDaftarPeserta from "./comp_box_daftar_peserta";
import Event_ComponentBoxDaftarSponsor from "./comp_box_sponsor";
export default function ComponentEvent_DetailMainData({
eventId,
}: {
eventId: string;
}) {
export default function ComponentEvent_DetailMainData() {
const params = useParams<{ id: string }>();
const eventId = params.id as string;
const [data, setData] = useState<MODEL_EVENT | null>(null);
useShallowEffect(() => {
@@ -28,11 +34,17 @@ export default function ComponentEvent_DetailMainData({
}, []);
async function onLoadData() {
const data = await fetch(
API_RouteEvent.get_one_by_id({ eventId: eventId })
);
const res = await data.json();
setData(res.data);
try {
const respone = await apiGetEventDetailById({
id: eventId,
});
if (respone) {
setData(respone.data);
}
} catch (error) {
clientLogger.error("Error get data detail event", error);
}
}
return (
@@ -52,7 +64,9 @@ export default function ComponentEvent_DetailMainData({
</Title>
<Grid>
<Grid.Col span={4}>
<Text c={MainColor.white} fw={"bold"}>Lokasi</Text>
<Text c={MainColor.white} fw={"bold"}>
Lokasi
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>
@@ -61,19 +75,27 @@ export default function ComponentEvent_DetailMainData({
</Grid>
<Grid>
<Grid.Col span={4}>
<Text c={MainColor.white} fw={"bold"}>Tipe Acara</Text>
<Text c={MainColor.white} fw={"bold"}>
Tipe Acara
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>
<Text c={MainColor.white}>{data ? data.EventMaster_TipeAcara.name : null}</Text>
<Text c={MainColor.white}>
{data ? data.EventMaster_TipeAcara.name : null}
</Text>
</Grid.Col>
</Grid>
<Stack spacing={"xs"}>
<Text c={MainColor.white} fw={"bold"}>Tanggal & Waktu</Text>
<Text c={MainColor.white} fw={"bold"}>
Tanggal & Waktu
</Text>
<Grid>
<Grid.Col span={4}>
<Text c={MainColor.white} fw={"bold"}>Mulai</Text>
<Text c={MainColor.white} fw={"bold"}>
Mulai
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>
@@ -88,7 +110,9 @@ export default function ComponentEvent_DetailMainData({
</Grid>
<Grid>
<Grid.Col span={4}>
<Text c={MainColor.white} fw={"bold"}>Selesai</Text>
<Text c={MainColor.white} fw={"bold"}>
Selesai
</Text>
</Grid.Col>
<Grid.Col span={1}>:</Grid.Col>
<Grid.Col span={"auto"}>
@@ -104,7 +128,9 @@ export default function ComponentEvent_DetailMainData({
</Stack>
<Stack spacing={2}>
<Text c={MainColor.white} fw={"bold"}>Deskripsi</Text>
<Text c={MainColor.white} fw={"bold"}>
Deskripsi
</Text>
<Text c={MainColor.white}>{data ? data?.deskripsi : null}</Text>
</Stack>
<SimpleGrid
@@ -114,8 +140,8 @@ export default function ComponentEvent_DetailMainData({
{ maxWidth: "36rem", cols: 1, spacing: "sm" },
]}
>
<Event_ComponentBoxDaftarPeserta/>
<Event_ComponentBoxDaftarSponsor />
<Event_ComponentBoxDaftarPeserta />
<Event_ComponentBoxDaftarSponsor />
</SimpleGrid>
</Stack>
</Stack>

View File

@@ -3,18 +3,19 @@
import { Stack } from "@mantine/core";
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
import { useParams } from "next/navigation";
export default function Event_DetailKontribusi({
eventId,
totalPeserta,
}: {
eventId: string;
totalPeserta: number;
}) {
const params = useParams<{id: string}>()
const eventId = params.id
return (
<>
<Stack spacing={"lg"} mb={"md"}>
<ComponentEvent_DetailMainData eventId={eventId} />
<ComponentEvent_DetailMainData/>
<ComponentEvent_ListPeserta eventId={eventId} total={totalPeserta} />
</Stack>
</>

View File

@@ -1,55 +1,102 @@
"use client";
import { API_RouteEvent } from "@/app/lib/api_user_router/route_api_event";
import { IRealtimeData } from "@/app/lib/global_state";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/_global/notif_global/notifikasi_berhasil";
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/_global/notif_global/notifikasi_gagal";
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
import notifikasiToUser_funCreate from "@/app_modules/notifikasi/fun/create/create_notif_to_user";
import { clientLogger } from "@/util/clientLogger";
import { Button, Stack } from "@mantine/core";
import { useShallowEffect } from "@mantine/hooks";
import { useParams } from "next/navigation";
import { useState } from "react";
import { WibuRealtime } from "wibu-pkg";
import { apiGetEventCekPeserta } from "../../_lib/api_event";
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
import { Event_countTotalPesertaById } from "../../fun/count/count_total_peserta_by_id";
import { Event_funJoinEvent } from "../../fun/create/fun_join_event";
import { Event_getListPesertaById } from "../../fun/get/get_list_peserta_by_id";
import { AccentColor, MainColor } from "@/app_modules/_global/color";
import { clientLogger } from "@/util/clientLogger";
export default function Event_DetailMain({
userLoginId,
totalPeserta,
eventId,
}: {
userLoginId: string;
totalPeserta: number;
eventId: string;
}) {
const [total, setTotal] = useState(totalPeserta);
const params = useParams<{ id: string }>();
const eventId = params.id;
const [isLoading, setLoading] = useState(false);
const [isJoinSuccess, setIsJoinSuccess] = useState<boolean | null>(null);
const [isNewPeserta, setIsNewPeserta] = useState<boolean | null>(null);
// const [isNewPeserta, setIsNewPeserta] = useState<boolean | null>(null);
useShallowEffect(() => {
onCheckPeserta();
}, []);
async function onCheckPeserta() {
const res = await fetch(
API_RouteEvent.check_peserta({ eventId: eventId, userId: userLoginId })
);
const data = await res.json();
setIsJoinSuccess(data);
try {
const respone = await apiGetEventCekPeserta({
userId: userLoginId,
eventId: eventId,
});
if (respone) {
console.log(respone.data)
setIsJoinSuccess(respone.data);
}
} catch (error) {
clientLogger.error("Error check peserta", error);
}
}
// [ON JOIN BUTTON]
async function onJoin() {
const body = {
userId: userLoginId,
eventId: eventId,
};
try {
setLoading(true);
const res = await Event_funJoinEvent(body as any);
if (res.status === 200) {
if (userLoginId !== res.data?.Event?.authorId) {
const dataNotifikasi: IRealtimeData = {
appId: res?.data?.Event?.id as any,
status: "Peserta Event" as any,
userId: res.data?.Event?.authorId as any,
pesan: res.data?.Event?.title as any,
kategoriApp: "EVENT",
title: "Peserta baru event anda !",
};
const createNotifikasi = await notifikasiToUser_funCreate({
data: dataNotifikasi as any,
});
if (createNotifikasi.status === 201) {
WibuRealtime.setData({
type: "notification",
pushNotificationTo: "USER",
dataMessage: dataNotifikasi,
});
}
}
setIsJoinSuccess(true);
setLoading(false);
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
} else {
setLoading(false);
ComponentGlobal_NotifikasiGagal(res.message);
}
} catch (error) {
setLoading(false);
clientLogger.error("Error join event", error);
}
}
return (
<>
<Stack spacing={"lg"} pb={"md"}>
<ComponentEvent_DetailMainData
eventId={eventId}
/>
<ComponentEvent_DetailMainData />
{isJoinSuccess == null ? (
<CustomSkeleton radius={"xl"} h={40} />
@@ -65,14 +112,7 @@ export default function Event_DetailMain({
radius={"xl"}
c={AccentColor.white}
onClick={() => {
onJoin(
userLoginId,
eventId,
setTotal,
setLoading,
setIsJoinSuccess,
setIsNewPeserta
);
onJoin();
}}
>
JOIN
@@ -88,63 +128,3 @@ export default function Event_DetailMain({
</>
);
}
async function onJoin(
userId: string,
eventId: string,
setTotal: any,
setLoading: any,
setIsJoinSuccess: (val: boolean | null) => void,
setIsNewPeserta: any
) {
const body = {
userId: userId,
eventId: eventId,
};
const userLoginId = userId;
try {
setLoading(true);
const res = await Event_funJoinEvent(body as any);
if (res.status === 200) {
const resPeserta = await Event_getListPesertaById(eventId);
setIsNewPeserta(true);
const resTotal = await Event_countTotalPesertaById(eventId);
setTotal(resTotal);
if (userLoginId !== res.data?.Event?.authorId) {
const dataNotifikasi: IRealtimeData = {
appId: res?.data?.Event?.id as any,
status: "Peserta Event" as any,
userId: res.data?.Event?.authorId as any,
pesan: res.data?.Event?.title as any,
kategoriApp: "EVENT",
title: "Peserta baru event anda !",
};
const createNotifikasi = await notifikasiToUser_funCreate({
data: dataNotifikasi as any,
});
if (createNotifikasi.status === 201) {
WibuRealtime.setData({
type: "notification",
pushNotificationTo: "USER",
dataMessage: dataNotifikasi,
});
}
}
setIsJoinSuccess(true);
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
} else {
setLoading(false);
ComponentGlobal_NotifikasiGagal(res.message);
}
} catch (error) {
setLoading(false);
clientLogger.error("Error join event", error);
}
}

View File

@@ -1,21 +1,50 @@
"use client"
"use client";
import { Stack } from '@mantine/core';
import ComponentEvent_ListPeserta from '../../component/detail/list_peserta';
import { MODEL_EVENT_PESERTA } from '../../model/interface';
import { useParams } from 'next/navigation';
import ComponentEvent_ListPesertaNew from '../../component/detail/list_peserta_new';
import { Stack } from "@mantine/core";
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
import { MODEL_EVENT_PESERTA } from "../../model/interface";
import { useParams } from "next/navigation";
import ComponentEvent_ListPesertaNew from "../../component/detail/list_peserta_new";
import { useShallowEffect } from "@mantine/hooks";
import { apiGetEventPesertaById } from "../../_lib/api_event";
import { useState } from "react";
import { clientLogger } from "@/util/clientLogger";
// function Event_DaftarPeserta({ totalPeserta, eventId, isNewPeserta }: {
// totalPeserta?: number;
// eventId?: string;
// isNewPeserta?: boolean | null;
// }) {
function Event_DaftarPeserta() {
function Event_DaftarPeserta() {
const params = useParams<{ id: string }>();
const [data, setData] = useState<MODEL_EVENT_PESERTA[] | null>(null);
const [activePage, setActivePage] = useState(1);
useShallowEffect(() => {
onLoadDataPeserta();
}, []);
async function onLoadDataPeserta() {
try {
const respone = await apiGetEventPesertaById({
id: params.id,
page: `${activePage}`,
});
if (respone) {
console.log(respone.data);
setData(respone.data);
}
} catch (error) {
clientLogger.error("Error get data peserta:", error);
}
}
return (
<>
<Stack>
<ComponentEvent_ListPesertaNew/>
<ComponentEvent_ListPesertaNew />
{/* <ComponentEvent_ListPeserta eventId={params.id} total={totalPeserta as any} isNewPeserta={isNewPeserta} /> */}
</Stack>
</>

View File

@@ -1,25 +1,25 @@
"use client";
import { Stack } from "@mantine/core";
import { useRouter } from "next/navigation";
import { useParams, useRouter } from "next/navigation";
import { useState } from "react";
import ComponentEvent_DetailMainData from "../../component/detail/detail_main";
import ComponentEvent_ListPeserta from "../../component/detail/list_peserta";
export default function Event_DetailRiwayat({
totalPeserta,
eventId,
}: {
totalPeserta: number;
eventId: string;
}) {
const params = useParams<{ id: string }>();
const eventId = params.id;
const router = useRouter();
const [total, setTotal] = useState(totalPeserta);
return (
<>
<Stack spacing={"lg"} py={"md"}>
<ComponentEvent_DetailMainData eventId={eventId} />
<ComponentEvent_DetailMainData />
<ComponentEvent_ListPeserta eventId={eventId} total={total} />
</Stack>
</>