feat(sosial): add schema fields + API endpoints for Sosial dashboard - bump to 0.1.45
- Add persentase field to ProgramKesehatan (for health stats bar chart) - Add BeasiswaConfig model (dana tersalurkan + tahun ajaran) - Add RingkasanKesehatanDesa model (ibu hamil, balita, alert stunting) - Add KegiatanDesa CRUD API (GET /api/desa/kegiatandesa/find-many?kategori=Budaya) - Add BeasiswaConfig API (GET/PUT /api/pendidikan/beasiswa/beasiswaconfig/...) - Add RingkasanKesehatan API (GET/PUT /api/kesehatan/ringkasankesehatan/...) - Migration: 20260430000000_add_sosial_fields Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import prisma from "@/lib/prisma";
|
||||
import { Context } from "elysia";
|
||||
|
||||
async function ringkasanKesehatanUpdate(context: Context) {
|
||||
const body = context.body as any;
|
||||
|
||||
try {
|
||||
const existing = await prisma.ringkasanKesehatanDesa.findFirst({
|
||||
where: { isActive: true },
|
||||
orderBy: { createdAt: 'desc' },
|
||||
});
|
||||
|
||||
const data = existing
|
||||
? await prisma.ringkasanKesehatanDesa.update({
|
||||
where: { id: existing.id },
|
||||
data: {
|
||||
ibuHamilAkh: Number(body.ibuHamilAkh),
|
||||
balitaTerdaftar: Number(body.balitaTerdaftar),
|
||||
alertStunting: Number(body.alertStunting),
|
||||
},
|
||||
})
|
||||
: await prisma.ringkasanKesehatanDesa.create({
|
||||
data: {
|
||||
ibuHamilAkh: Number(body.ibuHamilAkh),
|
||||
balitaTerdaftar: Number(body.balitaTerdaftar),
|
||||
alertStunting: Number(body.alertStunting),
|
||||
},
|
||||
});
|
||||
|
||||
return { success: true, message: "Ringkasan kesehatan berhasil disimpan", data };
|
||||
} catch (e) {
|
||||
console.error("Error di ringkasanKesehatanUpdate:", e);
|
||||
return { success: false, message: "Gagal menyimpan ringkasan kesehatan" };
|
||||
}
|
||||
}
|
||||
|
||||
export default ringkasanKesehatanUpdate;
|
||||
Reference in New Issue
Block a user