Tambahan
This commit is contained in:
@@ -0,0 +1 @@
|
||||
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","originalColumn":16,"originalLine":1069,"stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at new eS (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:26724)\n at e_ (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27574)\n at i (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32507)\n at get (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32603)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1217)\n at GET (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1084)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39714)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:33303)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36)\n at run (node:async_hooks:64:22)","timestamp":"2025-02-07T07:12:35.321Z"}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"digest":"DYNAMIC_SERVER_USAGE","level":"error","message":"Error get data detail event: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error","originalColumn":16,"originalLine":1069,"stack":"Error: Dynamic server usage: Page couldn't be rendered statically because it used `request.url`. See more info here: https://nextjs.org/docs/messages/dynamic-server-error\n at new eS (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:26724)\n at e_ (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:27574)\n at i (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32507)\n at get (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:32603)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1217)\n at GET (/Users/lukman/Documents/projects/BIP/hipmi/.next/server/app/api/event/check-peserta/route.js:1:1084)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:39714)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js:14:33303)\n at <anonymous> (/Users/lukman/Documents/projects/BIP/hipmi/node_modules/next/dist/server/lib/trace/tracer.js:121:36)\n at run (node:async_hooks:64:22)","timestamp":"2025-02-07T07:12:35.321Z"}
|
||||
|
||||
66
src/app/api/admin/collaboration/dashboard/[name]/route.ts
Normal file
66
src/app/api/admin/collaboration/dashboard/[name]/route.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { prisma } from "@/app/lib";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
|
||||
export async function GET(request: Request, { params }: {
|
||||
params: { name: string }
|
||||
}) {
|
||||
const method = request.method;
|
||||
if (method !== "GET") {
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Method not allowed",
|
||||
},
|
||||
{ status: 405 }
|
||||
);
|
||||
}
|
||||
const { name } = params;
|
||||
try {
|
||||
let fixData;
|
||||
const fixStatus = _.startCase(name);
|
||||
// console.log("status >>", fixStatus)
|
||||
|
||||
if (fixStatus === "Publish") {
|
||||
fixData = await prisma.projectCollaboration.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
} else if (fixStatus === "Reject") {
|
||||
fixData = await prisma.projectCollaboration.count({
|
||||
where: {
|
||||
isReject: true,
|
||||
},
|
||||
});
|
||||
|
||||
} else if (fixStatus === "Room") {
|
||||
fixData = await prisma.projectCollaboration_RoomChat.count({
|
||||
where: {
|
||||
isActive: true,
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: `Success Get Data ${fixStatus}`,
|
||||
data: fixData,
|
||||
|
||||
},
|
||||
{ status: 200 }
|
||||
)
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get count group chat", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get data count group chat ",
|
||||
reason: (error as Error).message
|
||||
},
|
||||
{ status: 500 }
|
||||
)
|
||||
} finally {
|
||||
await prisma.$disconnect
|
||||
}
|
||||
}
|
||||
@@ -4,16 +4,13 @@ import adminColab_countIsPublish from "@/app_modules/admin/colab/fun/count/count
|
||||
import adminColab_countIsReject from "@/app_modules/admin/colab/fun/count/count_reject";
|
||||
|
||||
export default async function Page() {
|
||||
const countPublish = await adminColab_countIsPublish();
|
||||
const countRoom = await adminColab_countGroupChat();
|
||||
const countReject = await adminColab_countIsReject()
|
||||
// const countPublish = await adminColab_countIsPublish();
|
||||
// const countRoom = await adminColab_countGroupChat();
|
||||
// const countReject = await adminColab_countIsReject()
|
||||
|
||||
return (
|
||||
<>
|
||||
<AdminColab_Dashboard
|
||||
countPublish={countPublish}
|
||||
countRoom={countRoom}
|
||||
countReject={countReject}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -5,37 +5,122 @@ import { useRouter } from "next/navigation";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { IconAlertTriangle, IconMessage2, IconUpload } from "@tabler/icons-react";
|
||||
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useState } from "react";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetAdminCollaborationStatusCountDashboard } from "../lib/api_fetch_admin_collaboration";
|
||||
import global_limit from "@/app/lib/limit";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function AdminColab_Dashboard({
|
||||
countPublish,
|
||||
countRoom,
|
||||
countReject,
|
||||
}: {
|
||||
countPublish: number;
|
||||
countRoom: number;
|
||||
countReject: number;
|
||||
}) {
|
||||
export default function AdminColab_Dashboard() {
|
||||
const [countPublish, setCountPublish] = useState<number | null>(null);
|
||||
const [countRoom, setCountRoom] = useState<number | null>(null);
|
||||
const [countReject, setCountReject] = useState<number | null>(null);
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
|
||||
useShallowEffect(() => {
|
||||
handlerLoadData()
|
||||
}, []);
|
||||
|
||||
async function handlerLoadData() {
|
||||
try {
|
||||
const listLoadData = [
|
||||
global_limit(() => onLoadCountPublish()),
|
||||
global_limit(() => onLoadCountRoom()),
|
||||
global_limit(() => onLoadCountReject()),
|
||||
]
|
||||
const result = await Promise.all(listLoadData);
|
||||
} catch (error) {
|
||||
clientLogger.error("Error handler load data", error)
|
||||
}
|
||||
}
|
||||
async function onLoadCountPublish() {
|
||||
try {
|
||||
const response = await apiGetAdminCollaborationStatusCountDashboard({
|
||||
name: "Publish",
|
||||
})
|
||||
if (response) {
|
||||
setCountPublish(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get count publish", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function onLoadCountRoom() {
|
||||
try {
|
||||
const response = await apiGetAdminCollaborationStatusCountDashboard(
|
||||
{
|
||||
name: "Room",
|
||||
}
|
||||
)
|
||||
if (response) {
|
||||
setCountRoom(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get count room", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function onLoadCountReject() {
|
||||
try {
|
||||
const response = await apiGetAdminCollaborationStatusCountDashboard({
|
||||
name: "Reject",
|
||||
})
|
||||
if (response) {
|
||||
setCountReject(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get count reject", error);
|
||||
}
|
||||
}
|
||||
|
||||
const listStatus = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Publish",
|
||||
jumlah: countPublish,
|
||||
jumlah: countPublish
|
||||
== null ? (
|
||||
<CustomSkeleton height={40} width={40} />
|
||||
) : countPublish ? (
|
||||
countPublish
|
||||
) : (
|
||||
"-"
|
||||
)
|
||||
,
|
||||
color: "green",
|
||||
icon: <IconUpload size={18} color="#4CAF4F" />
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Group Chat",
|
||||
jumlah: countRoom,
|
||||
jumlah: countRoom
|
||||
== null ? (
|
||||
<CustomSkeleton height={40} width={40} />
|
||||
) : countRoom ? (
|
||||
countRoom
|
||||
) : (
|
||||
"-"
|
||||
)
|
||||
,
|
||||
color: "orange",
|
||||
icon: <IconMessage2 size={18} color="#FF9800" />
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Reject",
|
||||
jumlah: countReject,
|
||||
jumlah: countReject
|
||||
== null ? (
|
||||
<CustomSkeleton height={40} width={40} />
|
||||
) : countReject ? (
|
||||
countReject
|
||||
) : (
|
||||
"-"
|
||||
)
|
||||
,
|
||||
color: "red",
|
||||
icon: <IconAlertTriangle size={18} color="#FF4B4C" />
|
||||
},
|
||||
@@ -84,3 +169,7 @@ export default function AdminColab_Dashboard({
|
||||
</>
|
||||
);
|
||||
}
|
||||
function apiGetAdminCollaborationStatuCountDashboard(arg0: { name: string; }) {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
export {
|
||||
apiGetAdminCollaborationStatusCountDashboard,
|
||||
|
||||
}
|
||||
const apiGetAdminCollaborationStatusCountDashboard = async ({
|
||||
name
|
||||
}: {
|
||||
name: "Publish" | "Reject" | "Room";
|
||||
}) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
// console.log("Ini Token", token);
|
||||
const response = await fetch(`/api/admin/collaboration/dashboard/${name}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
}
|
||||
})
|
||||
// console.log("Ini Response", await response.json());
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
@@ -48,9 +48,7 @@ const apiGetAdminDonasiByStatus = async ({
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
console.log("Ini token", token)
|
||||
console.log("Ini Page", page)
|
||||
console.log("Ini search", search)
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
const response = await fetch(
|
||||
@@ -64,14 +62,14 @@ const apiGetAdminDonasiByStatus = async ({
|
||||
}
|
||||
}
|
||||
)
|
||||
console.log("Ini response", response)
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminDonasiKategori = async () => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
console.log("ini token", token)
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/kategori`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -73,7 +73,7 @@ function TableView() {
|
||||
try {
|
||||
const response = await apiGetAdminDonasiKategori();
|
||||
if (response) {
|
||||
console.log("ini response", response)
|
||||
|
||||
setData(response.data)
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -96,7 +96,7 @@ function TableView() {
|
||||
}
|
||||
|
||||
async function onChangeStatus() {
|
||||
// console.log(updateStatus.kategoriId, updateStatus.isActive);
|
||||
|
||||
const del = await adminDonasi_funDeleteKategori({
|
||||
kategoriId: updateStatus.kategoriId,
|
||||
isActive: updateStatus.isActive as any,
|
||||
|
||||
@@ -72,7 +72,7 @@ function TableStatus() {
|
||||
page: `${isActivePage}`,
|
||||
search: isSearch
|
||||
})
|
||||
console.log("IniData", response)
|
||||
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
|
||||
@@ -162,11 +162,11 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
console.log("review >>", response.data.data);
|
||||
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -227,7 +227,7 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
console.log("review >>", response.data.data);
|
||||
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
|
||||
@@ -28,12 +28,10 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
||||
page: string,
|
||||
search: string
|
||||
}) => {
|
||||
console.log("dgsdg")
|
||||
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
console.log("Ini token", token)
|
||||
console.log("Ini Page", page)
|
||||
console.log("Ini Search", search)
|
||||
|
||||
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
@@ -46,6 +44,6 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
})
|
||||
console.log("Ini response", response)
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
@@ -41,9 +41,9 @@ const middlewareConfig: MiddlewareConfig = {
|
||||
// "/api/admin/investasi/*",
|
||||
// "/api/admin/donasi/*",
|
||||
// "/api/admin/voting/dashboard/*",
|
||||
// "/api/admin/job/dashboard/*",
|
||||
// "/api/admin/forum/dashboard/*",
|
||||
// "/api/admin/job/*",
|
||||
// "/api/admin/forum/*",
|
||||
// "/api/admin/collaboration/*",
|
||||
|
||||
// Akses awal
|
||||
"/api/get-cookie",
|
||||
|
||||
Reference in New Issue
Block a user