API Dashboard Admin
This commit is contained in:
29
src/app/api/admin/investasi/dashboard/[name]/route.ts
Normal file
29
src/app/api/admin/investasi/dashboard/[name]/route.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
31
src/app/api/admin/main_dashboard/portofolio/route.ts
Normal file
31
src/app/api/admin/main_dashboard/portofolio/route.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
42
src/app/api/admin/main_dashboard/user/route.ts
Normal file
42
src/app/api/admin/main_dashboard/user/route.ts
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user