API Dashboard Admin

This commit is contained in:
2025-01-30 14:40:16 +08:00
parent 22fa1e8bcd
commit d539678c1b
10 changed files with 292 additions and 35 deletions

View File

@@ -0,0 +1,29 @@
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
const data = await prisma.investasi.count({
where: {
active: true
},
})
return NextResponse.json({
message: "Data Investasi",
data: data,
},
{ status: 200 }
)
} catch (error) {
backendLogger.error("Error Get Count Investasi Main Dashboard")
return NextResponse.json({
message: "Error Get Count Investasi Main Dashboard",
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}

View File

@@ -0,0 +1,31 @@
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function GET(request: Request) {
try {
const data = await prisma.portofolio.count({
where: {
active: true
}
});
return NextResponse.json({
success: true,
message: "Data portofolio",
data: data
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error Get Count Portofolio Main Dashboard")
return NextResponse.json({
success: false,
message: "Error Get Count Portofolio Main Dashboard",
data: null
},
{ status: 500 }
);
} finally {
await prisma.$disconnect();
}
}

View File

@@ -0,0 +1,42 @@
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function GET(request: Request) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json(
{ success: false, message: "Method not allowed" },
{ status: 405 }
);
}
try {
const data = await prisma.user.count({
where: {
active: true
},
})
return NextResponse.json({
success: true,
message: "Data user",
data: data
},
{ status: 200 }
)
} catch (error) {
backendLogger.error("Error Get Count User Main Dashboard")
return NextResponse.json({
success: false,
message: "Gagal mendapatkan data",
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}

View File

@@ -33,7 +33,6 @@ export async function GET(
});
await prisma.$disconnect();
return NextResponse.json({
success: true,
message: "Berhasil mendapatkan data",
@@ -41,7 +40,6 @@ export async function GET(
});
} catch (error) {
await prisma.$disconnect();
return NextResponse.json(
{ success: false, message: "Gagal mendapatkan data" },
{ status: 500 }

View File

@@ -3,12 +3,12 @@ import { AdminMainDashboard_CountPOrtofolio } from "@/app_modules/admin/main_das
import { AdminMainDashboard_CountUser } from "@/app_modules/admin/main_dashboard/fun/count/fun_count_user";
export default async function Page() {
const countUser = await AdminMainDashboard_CountUser();
const countPorto = await AdminMainDashboard_CountPOrtofolio();
// const countUser = await AdminMainDashboard_CountUser();
// const countPorto = await AdminMainDashboard_CountPOrtofolio();
// await new Promise((a, b) => {
// setTimeout(a, 4000);
// });
return <AdminMain countUser={countUser} countPorto={countPorto} />;
return <AdminMain/>;
}