FIX UI Admin Menu PPID
This commit is contained in:
@@ -1,8 +1,43 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function grafikBerdasarkanJenisKelaminFindMany() {
|
||||
const res = await prisma.grafikBerdasarkanJenisKelamin.findMany();
|
||||
return {
|
||||
data: res
|
||||
export default async function grafikBerdasarkanJenisKelaminFindMany(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.grafikBerdasarkanJenisKelamin.findMany({
|
||||
where: { isActive: true },
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
prisma.grafikBerdasarkanJenisKelamin.count({
|
||||
where: { isActive: true }
|
||||
})
|
||||
]);
|
||||
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success fetch grafik berdasarkan jenis kelamin with pagination",
|
||||
data,
|
||||
page,
|
||||
totalPages,
|
||||
total,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Find many paginated error:", e);
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed fetch grafik berdasarkan jenis kelamin with pagination",
|
||||
data: [],
|
||||
page: 1,
|
||||
totalPages: 1,
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,43 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export async function grafikBerdasarkanUmurFindMany(){
|
||||
const res = await prisma.grafikBerdasarkanUmur.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
export default async function grafikBerdasarkanUmurFindMany(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.grafikBerdasarkanUmur.findMany({
|
||||
where: { isActive: true },
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
prisma.grafikBerdasarkanUmur.count({
|
||||
where: { isActive: true }
|
||||
})
|
||||
]);
|
||||
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success fetch grafik berdasarkan umur with pagination",
|
||||
data,
|
||||
page,
|
||||
totalPages,
|
||||
total,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Find many paginated error:", e);
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed fetch grafik berdasarkan umur with pagination",
|
||||
data: [],
|
||||
page: 1,
|
||||
totalPages: 1,
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import { grafikBerdasarkanUmurFindMany } from "./find-many";
|
||||
import { grafikBerdasarkanUmurCreate } from "./create";
|
||||
import grafikBerdasarakanUmurUpdate from "./update";
|
||||
import grafikBerdasarakanUmurFindById from "./find-by-id";
|
||||
import grafikBerdasarkanUmurDelete from "./del";
|
||||
import grafikBerdasarkanUmurFindMany from "./find-many";
|
||||
|
||||
const GrafikBerdasarkanUmur = new Elysia({
|
||||
prefix: "/grafikberdasarkanumur",
|
||||
|
||||
@@ -1,8 +1,44 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function grafikHasilKepuasanMasyarakatFindMany() {
|
||||
const res = await prisma.indeksKepuasanMasyarakat.findMany();
|
||||
return {
|
||||
data: res,
|
||||
};
|
||||
}
|
||||
// Di findMany.ts
|
||||
export default async function grafikHasilKepuasanMasyarakatFindMany(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.indeksKepuasanMasyarakat.findMany({
|
||||
where: { isActive: true },
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
prisma.indeksKepuasanMasyarakat.count({
|
||||
where: { isActive: true }
|
||||
})
|
||||
]);
|
||||
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success fetch grafik hasil kepuasan masyarakat with pagination",
|
||||
data,
|
||||
page,
|
||||
totalPages,
|
||||
total,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Find many paginated error:", e);
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed fetch grafik hasil kepuasan masyarakat with pagination",
|
||||
data: [],
|
||||
page: 1,
|
||||
totalPages: 1,
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,43 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function grafikRespondenFindMany(){
|
||||
const res = await prisma.grafikBerdasarkanResponden.findMany();
|
||||
return{
|
||||
data: res
|
||||
}
|
||||
export default async function grafikRespondenFindMany(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.grafikBerdasarkanResponden.findMany({
|
||||
where: { isActive: true },
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
prisma.grafikBerdasarkanResponden.count({
|
||||
where: { isActive: true }
|
||||
})
|
||||
]);
|
||||
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Success fetch grafik berdasarkan responden with pagination",
|
||||
data,
|
||||
page,
|
||||
totalPages,
|
||||
total,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Find many paginated error:", e);
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed fetch grafik berdasarkan responden with pagination",
|
||||
data: [],
|
||||
page: 1,
|
||||
totalPages: 1,
|
||||
total: 0,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user