Add API Dashboard ADMIN Doasi, Job, dan Voting

This commit is contained in:
2025-01-31 17:48:35 +08:00
parent 7e7856c32a
commit d2a1f85ec0
15 changed files with 443 additions and 53 deletions

View File

@@ -26,9 +26,6 @@ export async function GET(request: Request, { params }: {
DonasiMaster_Status: {
name: fixStatus
},
DonasiMaster_Ketegori: {
name: fixStatus
}
}
});
return NextResponse.json({

View File

@@ -0,0 +1,39 @@
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();
}
}

View File

@@ -0,0 +1,50 @@
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: { status: string }
}) {
const method = request.method;
if (method !== "GET") {
return NextResponse.json({
success: false,
message: "Method not allowed",
},
{ status: 405 }
)
}
const { status } = params;
try {
let fixData;
const fixStatus = _.startCase(status);
fixData = await prisma.job.count({
where: {
MasterStatus: {
name: fixStatus,
},
isArsip: false,
}
});
return NextResponse.json({
success: true,
message: "Success get data job-vacancy dashboard",
data: fixData
},
{ status: 200 }
);
} catch (error) {
backendLogger.error("Error get data job-vacancy dashboard", error);
return NextResponse.json({
success: false,
message: "Error get data job-vacancy dashboard",
reason: (error as Error).message,
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}

View File

@@ -0,0 +1,44 @@
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 {
let fixData;
fixData = await prisma.job.count({
where: {
MasterStatus: {
name: "Publish"
},
isArsip: true
}
})
return NextResponse.json({
success: true,
message: "Success get data job-vacancy dashboard",
data: fixData
},
{ status: 200 }
)
} catch (error) {
backendLogger.error("Error get data job-vacancy dashboard", error);
return NextResponse.json({
success: false,
message: "Error get data job-vacancy dashboard",
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}

View File

@@ -0,0 +1,51 @@
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);
fixData = await prisma.voting.count({
where: {
Voting_Status: {
name: fixStatus
},
isArsip: false
},
})
return NextResponse.json({
success: true,
message: "Success get data voting dashboard",
data: fixData
},
{ status: 200 }
)
} catch (error) {
backendLogger.error("Error get data voting dashboard >>", error);
return NextResponse.json({
success: false,
message: "Error get data voting dashboard",
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}

View File

@@ -0,0 +1,44 @@
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 {
let fixData;
fixData = await prisma.voting.count({
where: {
Voting_Status: {
name: "Publish",
},
isArsip: true,
}
})
return NextResponse.json({
success: true,
message: 'Success get data voting dashboard',
data: fixData
},
{ status: 200 }
)
} catch (error) {
backendLogger.error('Error get data voting dashboard >>', error);
NextResponse.json({
success: false,
message: 'Error get data voting dashboard',
reason: (error as Error).message
},
{ status: 500 }
)
} finally {
await prisma.$disconnect();
}
}