Fix UI Menu Landing Page, Submenu Profile & Desa Anti Korupsi

This commit is contained in:
2025-08-01 15:21:01 +08:00
parent 024d5517fa
commit 54312e9486
24 changed files with 875 additions and 252 deletions

View File

@@ -17,7 +17,7 @@ async function desaAntiKorupsiFindMany(context: Context) {
},
skip,
take: limit,
orderBy: { createdAt: 'desc' }, // opsional, kalau mau urut berdasarkan waktu
orderBy: { name: 'asc' }, // opsional, kalau mau urut berdasarkan waktu
}),
prisma.desaAntiKorupsi.count({
where: { isActive: true }

View File

@@ -11,7 +11,7 @@ const DesaAntiKorupsi = new Elysia({
})
// ✅ Find all
.get("/find-many", desaAntiKorupsiFindMany)
.get("/findMany", desaAntiKorupsiFindMany)
// ✅ Find by ID
.get("/:id", desaAntiKorupsiFindUnique)

View File

@@ -1,15 +1,40 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
// /api/berita/findManyPaginated.ts
import prisma from "@/lib/prisma";
import { Context } from "elysia";
export default async function kategoriDesaAntiKorupsiFindMany() {
const data = await prisma.kategoriDesaAntiKorupsi.findMany();
return {
success: true,
data: data.map((item: any) => {
return {
id: item.id,
name: item.name,
}
}),
async function kategoriDesaAntiKorupsiFindMany(context: Context) {
const page = Number(context.query.page) || 1;
const limit = Number(context.query.limit) || 10;
const skip = (page - 1) * limit;
try {
const [data, total] = await Promise.all([
prisma.kategoriDesaAntiKorupsi.findMany({
where: { isActive: true },
skip,
take: limit,
orderBy: { name: 'asc' }, // opsional, kalau mau urut berdasarkan waktu
}),
prisma.kategoriDesaAntiKorupsi.count({
where: { isActive: true }
})
]);
return {
success: true,
message: "Success fetch kategori desa anti korupsi with pagination",
data,
page,
totalPages: Math.ceil(total / limit),
total,
};
}
} catch (e) {
console.error("Find many paginated error:", e);
return {
success: false,
message: "Failed fetch kategori desa anti korupsi with pagination",
};
}
}
export default kategoriDesaAntiKorupsiFindMany;

View File

@@ -9,7 +9,7 @@ const KategoriDesaAntiKorupsi = new Elysia({
prefix: "/kategoridak",
tags: ["Landing Page/Desa Anti Korupsi"],
})
.get("/find-many", kategoriDesaAntiKorupsiFindMany)
.get("/findMany", kategoriDesaAntiKorupsiFindMany)
.get("/:id", async (context) => {
const response = await kategoriDesaAntiKorupsiFindUnique(context);
return response;

View File

@@ -16,7 +16,7 @@ async function mediaSosialFindMany(context: Context) {
},
skip,
take: limit,
orderBy: { createdAt: "desc" }, // opsional, kalau mau urut berdasarkan waktu
orderBy: { name: "asc" }, // opsional, kalau mau urut berdasarkan waktu
}),
prisma.mediaSosial.count({
where: { isActive: true },

View File

@@ -11,7 +11,7 @@ const MediaSosial = new Elysia({
})
// ✅ Find all
.get("/find-many", MediaSosialFindMany)
.get("/findMany", MediaSosialFindMany)
// ✅ Find by ID
.get("/:id", MediaSosialFindUnique)

View File

@@ -1,4 +1,4 @@
// /api/berita/findManyPaginated.ts
// // /api/berita/findManyPaginated.ts
import prisma from "@/lib/prisma";
import { Context } from "elysia";
@@ -16,7 +16,7 @@ async function programInovasiFindMany(context: Context) {
},
skip,
take: limit,
orderBy: { createdAt: "desc" }, // opsional, kalau mau urut berdasarkan waktu
orderBy: { name: "asc" }, // opsional, kalau mau urut berdasarkan waktu
}),
prisma.programInovasi.count({
where: { isActive: true },
@@ -41,3 +41,4 @@ async function programInovasiFindMany(context: Context) {
}
export default programInovasiFindMany;

View File

@@ -11,7 +11,7 @@ const ProgramInovasi = new Elysia({
})
// ✅ Find all
.get("/find-many", ProgramInovasiFindMany)
.get("/findMany", ProgramInovasiFindMany)
// ✅ Find by ID
.get("/:id", ProgramInovasiFindUnique)