fix ( event )

deskripsi:
- fix API: detail, check-peserta, peserta
This commit is contained in:
2025-01-20 17:53:09 +08:00
parent 2feb461c5b
commit bda5825887
4 changed files with 131 additions and 9 deletions

View File

@@ -37,5 +37,26 @@ export const apiGetEventCekPeserta = async ({
);
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

@@ -39,6 +39,7 @@ export default function Event_DetailMain({
});
if (respone) {
console.log(respone.data)
setIsJoinSuccess(respone.data);
}
} catch (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>
</>