Update Versi 1.5.27 #32
@@ -1,11 +1,83 @@
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(req: Request,
|
||||
export async function GET(request: Request,
|
||||
{ params }: { params: { id: string } }) {
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get('search');
|
||||
const page = searchParams.get('page');
|
||||
const takeData = 10;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
|
||||
try {
|
||||
|
||||
let fixData;
|
||||
const { id } = params;
|
||||
const eventId = id
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.event_Peserta.findMany({
|
||||
|
||||
where: {
|
||||
eventId: eventId,
|
||||
User: {
|
||||
username: {
|
||||
contains: search ? search : "",
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
select: {
|
||||
isPresent: true,
|
||||
User: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const data = await prisma.event_Peserta.findMany({
|
||||
skip: skipData,
|
||||
take: takeData,
|
||||
where: {
|
||||
eventId: eventId,
|
||||
User: {
|
||||
username: {
|
||||
contains: search ? search : "",
|
||||
}
|
||||
}
|
||||
},
|
||||
select: {
|
||||
isPresent: true,
|
||||
User: {
|
||||
include: {
|
||||
Profile: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.event_Peserta.count({
|
||||
where: {
|
||||
eventId: eventId,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
nPage: _.ceil(nCount / takeData),
|
||||
};
|
||||
}
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success get data event detail",
|
||||
data: fixData,
|
||||
},
|
||||
{ status: 200 }
|
||||
)
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data event detail >>", error);
|
||||
return NextResponse.json({
|
||||
|
||||
103
src/app/api/admin/forum/[id]/report-komentar/route.ts
Normal file
103
src/app/api/admin/forum/[id]/report-komentar/route.ts
Normal file
@@ -0,0 +1,103 @@
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get('search');
|
||||
const page = searchParams.get('page');
|
||||
const takeData = 10;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
try {
|
||||
let fixData;
|
||||
const { id } = params;
|
||||
const komentarId = id
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.forum_ReportKomentar.findMany({
|
||||
|
||||
orderBy: {
|
||||
createdAt: "desc"
|
||||
},
|
||||
where: {
|
||||
forum_KomentarId: komentarId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
deskripsi: true,
|
||||
ForumMaster_KategoriReport: true,
|
||||
User: {
|
||||
select: {
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const data = await prisma.forum_ReportKomentar.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc"
|
||||
},
|
||||
where: {
|
||||
forum_KomentarId: komentarId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
isActive: true,
|
||||
createdAt: true,
|
||||
deskripsi: true,
|
||||
ForumMaster_KategoriReport: true,
|
||||
User: {
|
||||
select: {
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.forum_ReportKomentar.count({
|
||||
where: {
|
||||
forum_KomentarId: komentarId,
|
||||
}
|
||||
})
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
nPage: _.ceil(nCount / takeData)
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success get detail data report komentar",
|
||||
data: fixData
|
||||
},
|
||||
{ status: 200 }
|
||||
)
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get detail data report komentar >>", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get detail data report komentar",
|
||||
reason: (error as Error).message
|
||||
}, { status: 500 })
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,112 +4,115 @@ import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request,
|
||||
{ params }: { params: { id: string } }) {
|
||||
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get('search');
|
||||
const page = searchParams.get('page');
|
||||
const takeData = 10;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
{ params }: { params: { id: string } }) {
|
||||
|
||||
try {
|
||||
let fixData;
|
||||
const { id } = params;
|
||||
const postingId = id
|
||||
const { searchParams } = new URL(request.url);
|
||||
const search = searchParams.get('search');
|
||||
const page = searchParams.get('page');
|
||||
const takeData = 10;
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.forum_ReportPosting.findMany({
|
||||
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
},
|
||||
try {
|
||||
let fixData;
|
||||
const { id } = params;
|
||||
const postingId = id
|
||||
|
||||
if (!page) {
|
||||
fixData = await prisma.forum_ReportPosting.findMany({
|
||||
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
|
||||
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
createdAt: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
createdAt: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ForumMaster_KategoriReport: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const data = await prisma.forum_ReportPosting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ForumMaster_KategoriReport: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
},
|
||||
},
|
||||
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const data = await prisma.forum_ReportPosting.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
forum_PostingId: postingId,
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
createdAt: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
id: true,
|
||||
deskripsi: true,
|
||||
createdAt: true,
|
||||
User: {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
Profile: {
|
||||
select: {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ForumMaster_KategoriReport: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
},
|
||||
},
|
||||
name: true,
|
||||
},
|
||||
});
|
||||
const nCount = await prisma.forum_ReportPosting.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
nCount: _.ceil(nCount / takeData)
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
ForumMaster_KategoriReport: {
|
||||
select: {
|
||||
id: true,
|
||||
title: true,
|
||||
deskripsi: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const nCount = await prisma.forum_ReportPosting.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
}
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success get data forum posting",
|
||||
data: fixData
|
||||
},
|
||||
{ status: 200 }
|
||||
)
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data forum posting >>", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get data forum posting",
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
nPage: _.ceil(nCount / takeData)
|
||||
}
|
||||
}
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Success get data forum report posting",
|
||||
data: fixData
|
||||
},
|
||||
{ status: 200 }
|
||||
)
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get data forum report posting >>", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get data forum report posting",
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
import { AdminEvent_UiDetailPeserta } from "@/app_modules/admin/event/_ui";
|
||||
import { adminEvent_getListPesertaById } from "@/app_modules/admin/event/fun/get/get_list_peserta_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
const eventId = params.id;
|
||||
const dataPeserta = await adminEvent_getListPesertaById({ eventId, page: 1 });
|
||||
export default async function Page(){
|
||||
|
||||
return (
|
||||
<>
|
||||
<AdminEvent_UiDetailPeserta dataPeserta={dataPeserta} eventId={eventId} />
|
||||
<AdminEvent_UiDetailPeserta />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@ export {
|
||||
apiGetAdminEventByStatus as apiGetDataEventByStatus,
|
||||
apiGetAdminEventRiwayat,
|
||||
apiGetAdminEventTipeAcara,
|
||||
apiGetAdminDetailEventById
|
||||
apiGetAdminDetailEventById,
|
||||
apiGetAdminDetailEventPesertaById
|
||||
};
|
||||
|
||||
const apiGetAdminEventStatusCountDashboard = async ({
|
||||
@@ -150,3 +151,31 @@ const apiGetAdminDetailEventById = async ({ id }: { id: string }) => {
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
const apiGetAdminDetailEventPesertaById = async ({
|
||||
page,
|
||||
search,
|
||||
id
|
||||
}: {
|
||||
page: string;
|
||||
search: string;
|
||||
id: string
|
||||
}) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
|
||||
const response = await fetch(`/api/admin/event/${id}/peserta${isPage}${isSearch}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
})
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
@@ -6,21 +6,13 @@ import { AdminEvent_ViewDetailPeserta } from "../_view";
|
||||
import { MODEL_EVENT_PESERTA } from "@/app_modules/event/_lib/interface";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
|
||||
export function AdminEvent_UiDetailPeserta({
|
||||
dataPeserta,
|
||||
eventId,
|
||||
}: {
|
||||
dataPeserta: any;
|
||||
eventId: string
|
||||
}) {
|
||||
export function AdminEvent_UiDetailPeserta() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<AdminGlobal_ComponentBackButton />
|
||||
<ComponentAdminGlobal_TitlePage name="Detail Peserta" />
|
||||
<AdminEvent_ViewDetailPeserta
|
||||
dataPeserta={dataPeserta as any}
|
||||
eventId={eventId}
|
||||
/>
|
||||
</Stack>
|
||||
</>
|
||||
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
ScrollArea,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
TextInput,
|
||||
Title,
|
||||
} from "@mantine/core";
|
||||
import { useState } from "react";
|
||||
@@ -17,32 +19,68 @@ import { adminEvent_getListPesertaById } from "../fun";
|
||||
import _ from "lodash";
|
||||
import ComponentAdminGlobal_IsEmptyData from "../../_admin_global/is_empty_data";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetAdminDetailEventPesertaById } from "../_lib/api_fecth_admin_event";
|
||||
import { useParams } from "next/navigation";
|
||||
import { IconSearch } from "@tabler/icons-react";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export function AdminEvent_ViewDetailPeserta({
|
||||
dataPeserta,
|
||||
eventId,
|
||||
}: {
|
||||
dataPeserta: any;
|
||||
eventId: string;
|
||||
}) {
|
||||
const [data, setData] = useState<MODEL_EVENT_PESERTA[]>(dataPeserta.data);
|
||||
const [isNPage, setNPage] = useState(dataPeserta.nPage);
|
||||
export function AdminEvent_ViewDetailPeserta() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const [data, setData] = useState<MODEL_EVENT_PESERTA[] | null>(null);
|
||||
const [isNPage, setNPage] = useState<number>(1);
|
||||
const [isActivePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
|
||||
useShallowEffect(() => {
|
||||
loadInitialData();
|
||||
}, [isActivePage, isSearch])
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminEvent_getListPesertaById({
|
||||
eventId: eventId,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminDetailEventPesertaById({
|
||||
id: params.id,
|
||||
page: `${isActivePage}`,
|
||||
search: isSearch,
|
||||
})
|
||||
|
||||
if (response?.success && response?.data.data) {
|
||||
setData(response.data.data)
|
||||
setNPage(response.data.nPage || 1)
|
||||
} else {
|
||||
console.error("Invalid data format recieved:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Invalid data format recieved:", error);
|
||||
setData([]);
|
||||
}
|
||||
}
|
||||
|
||||
const tableRow = _.isEmpty(data)
|
||||
? []
|
||||
: data.map((e, i) => (
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
}
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
}
|
||||
|
||||
const renderTableBody = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color={"gray"}>Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return data?.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{e?.User?.username}</Center>
|
||||
@@ -67,65 +105,81 @@ export function AdminEvent_ViewDetailPeserta({
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<Paper bg={AdminColor.softBlue}
|
||||
p={"xs"}
|
||||
style={{ borderRadius: "6px" }}>
|
||||
<Title c={AdminColor.white} order={4}>Daftar Peserta</Title>
|
||||
</Paper>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"75vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Name</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Nomor</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Email</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Konfirmasi Kehadiran</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableRow}</tbody>
|
||||
</Table>
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData
|
||||
text="Tidak ada peserta"
|
||||
marginTop={100}
|
||||
/>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={isActivePage}
|
||||
total={isNPage}
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Daftar Peserta"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
disabled={!data}
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Masukan username"
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
}
|
||||
/>
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
): (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"75vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={"100%"}
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Name</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Nomor</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Email</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AdminColor.white}>Konfirmasi Kehadiran</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData
|
||||
text="Tidak ada peserta"
|
||||
marginTop={100}
|
||||
/>
|
||||
) : (
|
||||
""
|
||||
)}
|
||||
</ScrollArea>
|
||||
|
||||
<Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={isActivePage}
|
||||
total={isNPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center>
|
||||
</Paper>
|
||||
)}
|
||||
|
||||
</Stack>
|
||||
{/* <pre>{JSON.stringify(dataPeserta, null, 2)}</pre> */}
|
||||
</>
|
||||
|
||||
@@ -53,7 +53,7 @@ function AdminEvent_DetailPublish() {
|
||||
<AdminEvent_ViewDetailData />
|
||||
) : null}
|
||||
{selectPage == "2" ? (
|
||||
<AdminEvent_ViewDetailPeserta dataPeserta={{}} eventId={""}/>
|
||||
<AdminEvent_ViewDetailPeserta />
|
||||
) : null}
|
||||
{selectPage == "3" ? (
|
||||
<AdminEvent_DetailDataSponsor />
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
export {
|
||||
apiGetAdminForumPublishCountDasboard,
|
||||
apiGetAdminCountForumReportPosting ,
|
||||
apiGetAdminCountForumReportPosting,
|
||||
apiGetAdminCountForumReportKomentar,
|
||||
apiGetAdminForumReportPosting,
|
||||
apiGetAdminForumReportKomentar,
|
||||
apiGetAdminForumPublish
|
||||
apiGetAdminForumPublish,
|
||||
apiGetAdminHasilReportPosting
|
||||
}
|
||||
|
||||
const apiGetAdminForumPublishCountDasboard = async () => {
|
||||
@@ -38,7 +39,7 @@ const apiGetAdminCountForumReportPosting = async () => {
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
@@ -58,7 +59,7 @@ const apiGetAdminCountForumReportKomentar = async () => {
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminForumReportPosting = async ({page} : { page?: string}) => {
|
||||
const apiGetAdminForumReportPosting = async ({ page }: { page?: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
@@ -75,10 +76,10 @@ const apiGetAdminForumReportPosting = async ({page} : { page?: string}) => {
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminForumReportKomentar = async({ page } : { page?: string}) => {
|
||||
const apiGetAdminForumReportKomentar = async ({ page }: { page?: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const response = await fetch(`/api/admin/forum/komentar${isPage}`, {
|
||||
method: "GET",
|
||||
@@ -92,12 +93,13 @@ const apiGetAdminForumReportKomentar = async({ page } : { page?: string}) => {
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminForumPublish = async ({ page }: { page?: string }) => {
|
||||
const apiGetAdminForumPublish = async (
|
||||
{ page }: { page?: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const response = await fetch(`/api/admin/forum/publish${isPage}`, {
|
||||
const response = await fetch(`/api/admin/forum/publish/${isPage}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -106,15 +108,26 @@ const apiGetAdminForumPublish = async ({ page }: { page?: string }) => {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
|
||||
const apiGetAdminHasilReportPosting = async ({id} : {id: string}) => {
|
||||
const apiGetAdminHasilReportPosting = async ({ page, id }: { page?: string, id: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const response = await fetch(`/api/admin/forum/${id}/report_posting${isPage}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
}
|
||||
})
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
|
||||
}
|
||||
@@ -34,10 +34,8 @@ const middlewareConfig: MiddlewareConfig = {
|
||||
|
||||
// ADMIN API
|
||||
// >> buat dibawah sini <<
|
||||
// "/api/admin/collaboration/*",
|
||||
// "/api/admin/investasi/*",
|
||||
// "/api/admin/event/*",
|
||||
// "/api/admin/forum/*",
|
||||
|
||||
|
||||
|
||||
// Akses awal
|
||||
"/api/get-cookie",
|
||||
|
||||
Reference in New Issue
Block a user