Senin, 19 May 2025 :
Yang Sudah Di Kerjakan - Tampilan UI Admin di menu kesehatan Yang Akan Dikerjakan: - API Di Menu Desa - Tampilan UI Admin Di Menu Keamanan
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
export default async function profileDesaFindById(context: Context) {
|
||||
try {
|
||||
const id = context?.params?.slugs?.[0];
|
||||
|
||||
// If no ID provided, get the first profile
|
||||
if (!id) {
|
||||
const data = await prisma.profileDesa.findFirst();
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
}
|
||||
|
||||
const data = await prisma.profileDesa.findUniqueOrThrow({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Error fetching profileDesa:", error);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
message: error instanceof Error ? error.message : "Unknown error",
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
|
||||
export default async function profileDesaFindMany() {
|
||||
const res = await prisma.profileDesa.findMany({
|
||||
include: {
|
||||
ProfilPerbekel: true,
|
||||
},
|
||||
});
|
||||
return {
|
||||
data: res,
|
||||
};
|
||||
}
|
||||
@@ -1,16 +1,16 @@
|
||||
import Elysia, { t } from "elysia";
|
||||
import profileDesaFindMany from "./find-many";
|
||||
import lambangDesaUpdate from "./lambangDesa";
|
||||
import maskotDesaUpdate from "./maskotDesa";
|
||||
import profilePerbekelUpdate from "./profilePerbekel";
|
||||
import sejarahDesaUpdate from "./sejarahDesa";
|
||||
import visimisiDesaUpdate from "./visimisiDesa";
|
||||
import lambangDesaUpdate from "./lambangDesa/update";
|
||||
import maskotDesaUpdate from "./maskotDesa/update";
|
||||
import profilePerbekelUpdate from "../profilePerbekel/update";
|
||||
import sejarahDesaUpdate from "./sejarah/update";
|
||||
import visimisiDesaUpdate from "./visimisiDesa/update";
|
||||
import profileDesaFindById from "./find-by-id";
|
||||
|
||||
const ProfileDesa = new Elysia({
|
||||
prefix: "/profile",
|
||||
tags: ["Desa/Profile"]
|
||||
})
|
||||
.get("/find-many", profileDesaFindMany)
|
||||
.get("/find-by-id", profileDesaFindById)
|
||||
.post("/profilePerbekel/update", profilePerbekelUpdate, {
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
@@ -27,7 +27,7 @@ const ProfileDesa = new Elysia({
|
||||
misi: t.String(),
|
||||
})
|
||||
})
|
||||
.post("/sejarahDesa/update", sejarahDesaUpdate, {
|
||||
.post("/sejarah/update", sejarahDesaUpdate, {
|
||||
body: t.Object({
|
||||
id: t.String(),
|
||||
sejarah: t.String(),
|
||||
|
||||
Reference in New Issue
Block a user