Fix UI Admin Menu Pendidikam, Add Menu User & Role
This commit is contained in:
@@ -10,9 +10,6 @@ async function lembagaPendidikanFindMany(context: Context) {
|
||||
const search = (context.query.search as string) || "";
|
||||
const skip = (page - 1) * limit;
|
||||
const jenjangPendidikanName = (context.query.jenjangPendidikanId as string) || "";
|
||||
|
||||
console.log('Lembaga API Query Params:', { page, limit, search, jenjangPendidikanName });
|
||||
|
||||
// Buat where clause
|
||||
const where: any = { isActive: true };
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@ async function pengajarFindMany(context: Context) {
|
||||
const search = (context.query.search as string) || "";
|
||||
const jenjangPendidikanName = (context.query.jenjangPendidikanId as string) || "";
|
||||
|
||||
console.log('Pengajar API Query Params:', { page, limit, search, jenjangPendidikanId: jenjangPendidikanName });
|
||||
|
||||
const where: any = { isActive: true };
|
||||
|
||||
// Filter berdasarkan jenjang pendidikan (jika ada)
|
||||
|
||||
@@ -10,8 +10,6 @@ async function siswaFindMany(context: Context) {
|
||||
const search = (context.query.search as string) || "";
|
||||
const jenjangPendidikanName = (context.query.jenjangPendidikanName as string) || "";
|
||||
|
||||
console.log('Siswa API Query Params:', { page, limit, search, jenjangPendidikanId: jenjangPendidikanName });
|
||||
|
||||
// Buat where clause
|
||||
const where: any = { isActive: true };
|
||||
|
||||
|
||||
@@ -1,11 +1,53 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
// /api/berita/findManyPaginated.ts
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function kategoriBukuFindMany() {
|
||||
const data = await prisma.kategoriBuku.findMany();
|
||||
async function kategoriBukuFindMany(context: Context) {
|
||||
// Ambil parameter dari query
|
||||
const page = Number(context.query.page) || 1;
|
||||
const limit = Number(context.query.limit) || 10;
|
||||
const search = (context.query.search as string) || '';
|
||||
const skip = (page - 1) * limit;
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success get all kategori buku",
|
||||
data,
|
||||
};
|
||||
// Buat where clause
|
||||
const where: any = { isActive: true };
|
||||
|
||||
// Tambahkan pencarian (jika ada)
|
||||
if (search) {
|
||||
where.OR = [
|
||||
{ name: { contains: search, mode: 'insensitive' } },
|
||||
];
|
||||
}
|
||||
|
||||
try {
|
||||
// Ambil data dan total count secara paralel
|
||||
const [data, total] = await Promise.all([
|
||||
prisma.kategoriBuku.findMany({
|
||||
where,
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
prisma.kategoriBuku.count({ where }),
|
||||
]);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Berhasil ambil kategori buku dengan pagination",
|
||||
data,
|
||||
page,
|
||||
limit,
|
||||
total,
|
||||
totalPages: Math.ceil(total / limit),
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Error di findMany paginated:", e);
|
||||
return {
|
||||
success: false,
|
||||
message: "Gagal mengambil data kategori buku",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default kategoriBukuFindMany;
|
||||
Reference in New Issue
Block a user