Fix Menu Desa Admin & User

This commit is contained in:
2025-09-30 17:13:06 +08:00
parent 295d6f7d63
commit c2f1ab8179
27 changed files with 897 additions and 593 deletions

View File

@@ -1,9 +1,7 @@
import prisma from "@/lib/prisma";
export default async function findUniqueAjukanPermohonan(request: Request) {
const url = new URL(request.url);
const pathSegments = url.pathname.split("/");
const id = pathSegments[pathSegments.length - 1];
export default async function findUniqueAjukanPermohonan({ params }: { params: { id: string } }) {
const { id } = params;
if (!id) {
return Response.json(

View File

@@ -1,8 +1,8 @@
import prisma from "@/lib/prisma";
import { Context } from "elysia";
export default async function findByMonthYear(context: Context) {
const { month, year } = context.params as { month: string; year: string };
export default async function findByMonthYear({ params }: { params: { month: string; year: number } }) {
const { month, year } = params;
if (!month || !year) {
return {

View File

@@ -23,7 +23,9 @@ async function img({
// Validasi ekstensi file
if (![".jpg", ".jpeg", ".png"].includes(ext)) {
console.warn(`Ekstensi file tidak didukung: ${ext}`);
return new Response(await fs.readFile(noImage), {
const buffer = await fs.readFile(noImage);
const uint8Array = new Uint8Array(buffer);
return new Response(new Blob([uint8Array], { type: 'image/jpeg' }), {
headers: { "Content-Type": "image/jpeg" },
});
}
@@ -43,7 +45,8 @@ async function img({
.resize(size || metadata.width) // Gunakan size jika diberikan, jika tidak gunakan width asli
.toBuffer();
return new Response(resizedImageBuffer, {
const uint8Array = new Uint8Array(resizedImageBuffer);
return new Response(new Blob([uint8Array], { type: 'image/jpeg' }), {
headers: {
"Cache-Control": "public, max-age=3600, stale-while-revalidate=600",
"Content-Type": "image/jpeg",
@@ -52,7 +55,9 @@ async function img({
} catch (error) {
console.error(`Gagal memproses file: ${name}`, error);
// Jika file tidak ditemukan atau gagal diproses, kembalikan default image
return new Response(await fs.readFile(noImage), {
const buffer = await fs.readFile(noImage);
const uint8Array = new Uint8Array(buffer);
return new Response(new Blob([uint8Array], { type: 'image/jpeg' }), {
headers: { "Content-Type": "image/jpeg" },
});
}

View File

@@ -1,9 +1,7 @@
import prisma from "@/lib/prisma";
export default async function pengaduanMasyarakatFindUnique(request: Request) {
const url = new URL(request.url);
const pathSegments = url.pathname.split("/");
const id = pathSegments[pathSegments.length - 1];
export default async function pengaduanMasyarakatFindUnique({ params }: { params: { id: string } }) {
const { id } = params;
if (!id) {
return Response.json({