FIX UI Admin Menu PPID
This commit is contained in:
@@ -1,21 +1,18 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormCreate = Prisma.DaftarInformasiPublikGetPayload<{
|
||||
select: {
|
||||
jenisInformasi: true;
|
||||
deskripsi: true;
|
||||
tanggal: true;
|
||||
}
|
||||
}>
|
||||
type FormCreate = {
|
||||
jenisInformasi: string;
|
||||
deskripsi: string;
|
||||
tanggal: string;
|
||||
}
|
||||
export default async function daftarInformasiPublikCreate(context: Context) {
|
||||
const body = context.body as FormCreate;
|
||||
await prisma.daftarInformasiPublik.create({
|
||||
data: {
|
||||
jenisInformasi: body.jenisInformasi,
|
||||
deskripsi: body.deskripsi,
|
||||
tanggal: body.tanggal,
|
||||
tanggal: new Date(body.tanggal),
|
||||
},
|
||||
})
|
||||
return {
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
type FormEdit = {
|
||||
jenisInformasi: string;
|
||||
deskripsi: string;
|
||||
tanggal: string;
|
||||
};
|
||||
|
||||
export default async function daftarInformasiPublikEdit(context: Context) {
|
||||
const id = context.params?.id;
|
||||
|
||||
@@ -11,11 +17,7 @@ export default async function daftarInformasiPublikEdit(context: Context) {
|
||||
};
|
||||
}
|
||||
|
||||
const { jenisInformasi, deskripsi, tanggal } = context.body as {
|
||||
jenisInformasi: string;
|
||||
deskripsi: string;
|
||||
tanggal: string;
|
||||
};
|
||||
const body = context.body as FormEdit;
|
||||
|
||||
const existing = await prisma.daftarInformasiPublik.findUnique({
|
||||
where: {
|
||||
@@ -33,9 +35,9 @@ export default async function daftarInformasiPublikEdit(context: Context) {
|
||||
const updated = await prisma.daftarInformasiPublik.update({
|
||||
where: { id },
|
||||
data: {
|
||||
jenisInformasi,
|
||||
deskripsi,
|
||||
tanggal,
|
||||
jenisInformasi: body.jenisInformasi,
|
||||
deskripsi: body.deskripsi,
|
||||
tanggal: new Date(body.tanggal),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,9 +1,44 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
// Di findMany.ts
|
||||
export default async function daftarInformasiPublikFindMany(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.daftarInformasiPublik.findMany({
|
||||
where: { isActive: true },
|
||||
skip,
|
||||
take: limit,
|
||||
orderBy: { createdAt: 'desc' },
|
||||
}),
|
||||
prisma.daftarInformasiPublik.count({
|
||||
where: { isActive: true }
|
||||
})
|
||||
]);
|
||||
|
||||
const totalPages = Math.ceil(total / limit);
|
||||
|
||||
export default async function daftarInformasiPublikFindMany() {
|
||||
const res = await prisma.daftarInformasiPublik.findMany();
|
||||
return {
|
||||
data: res
|
||||
}
|
||||
}
|
||||
|
||||
success: true,
|
||||
message: "Success fetch daftar informasi publik with pagination",
|
||||
data,
|
||||
page,
|
||||
totalPages,
|
||||
total,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Find many paginated error:", e);
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed fetch daftar informasi publik 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 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