data auto

This commit is contained in:
2025-02-10 17:53:13 +08:00
parent 7445e8bb3a
commit 1df244402b
8 changed files with 110 additions and 112 deletions

View File

@@ -1,39 +1,25 @@
import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
import _ from "lodash";
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 {
let fixData;
fixData = await prisma.donasiMaster_Kategori.count({});
return NextResponse.json({
success: true,
message: 'Success get data donasi dashboard',
data: fixData
},
{ status: 200 }
)
} catch (error) {
backendLogger.error('Error get data donasi dashboard >>', error);
return NextResponse.json({
success: false,
message: 'Error get data donasi dashboard',
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}
export async function GET() {
try {
const fixData = await prisma.donasiMaster_Kategori.count({});
return NextResponse.json(
{
success: true,
message: "Success get data donasi dashboard",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
return NextResponse.json(
{
success: true,
message: "gagal mendapatkan data donasi dashboard",
error: (error as Error).message,
},
{ status: 500 }
);
}
}

View File

@@ -3,18 +3,9 @@ import backendLogger from "@/util/backendLogger";
import _ from "lodash";
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 }
);
}
export async function GET() {
try {
let fixData;
fixData = await prisma.eventMaster_TipeAcara.count({
const fixData = await prisma.eventMaster_TipeAcara.count({
where: {
active: true,
},
@@ -38,7 +29,5 @@ export async function GET(request: Request) {
},
{ status: 500 }
);
} finally {
await prisma.$disconnect();
}
}

View File

@@ -2,43 +2,31 @@ import { prisma } from "@/app/lib";
import backendLogger from "@/util/backendLogger";
import { NextResponse } from "next/server";
export async function GET(request: Request, { params }: {
params: { status: string }
}) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json({
success: false,
message: "Method not allowed",
},
{ status: 405 }
)
}
try {
let fixData;
fixData = await prisma.forum_Posting.count({
where: {
isActive: true,
}
})
export async function GET() {
try {
const fixData = await prisma.forum_Posting.count({
where: {
isActive: true,
},
});
return NextResponse.json({
success: true,
message: "Success get data forum dashboard",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error get data forum dashboard", error);
return NextResponse.json({
success: false,
message: "Error get data forum dashboard",
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}
return NextResponse.json(
{
success: true,
message: "Success get data forum dashboard",
data: fixData,
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error get data forum dashboard", error);
return NextResponse.json(
{
success: false,
message: "Error get data forum dashboard",
reason: (error as Error).message,
},
{ status: 500 }
);
}
}