- Add Distribusi Umur admin pages (list, create, edit) - Add Data Banjar admin pages (list, create, edit) - Add Migrasi Penduduk admin pages (list, create, edit) - Update state management with full CRUD operations for all modules - Add Kependudukan menu to admin sidebar (devBar, navBar, role1) - Add public pages for Distribusi Umur with age range sorting - Update Dinamika Penduduk to use real-time birth/death data - Add Biome configuration for code linting - Create API routes for all Kependudukan modules Features: - Pagination and search for all admin list pages - Responsive design (table for desktop, cards for mobile) - Delete confirmation modal - Toast notifications for user feedback - Zod validation for all forms - Age range auto-sorting in public Distribusi Umur chart Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
54 lines
1.1 KiB
TypeScript
54 lines
1.1 KiB
TypeScript
import prisma from "@/lib/prisma";
|
|
import { Context } from "elysia";
|
|
|
|
export default async function migrasiPendudukUpdate(context: Context) {
|
|
const id = context.params?.id;
|
|
|
|
if (!id) {
|
|
return {
|
|
success: false,
|
|
message: "ID tidak ditemukan",
|
|
}
|
|
}
|
|
|
|
const {jenis, nama, tanggal, asalTujuan, alasan, jenisKelamin} = context.body as {
|
|
jenis: string;
|
|
nama: string;
|
|
tanggal: string;
|
|
asalTujuan: string;
|
|
alasan?: string;
|
|
jenisKelamin?: string;
|
|
}
|
|
|
|
const existing = await prisma.migrasiPenduduk.findUnique({
|
|
where: {
|
|
id: id,
|
|
},
|
|
})
|
|
|
|
if (!existing) {
|
|
return {
|
|
success: false,
|
|
message: "Data tidak ditemukan",
|
|
}
|
|
}
|
|
|
|
const updated = await prisma.migrasiPenduduk.update({
|
|
where: { id },
|
|
data: {
|
|
jenis,
|
|
nama,
|
|
tanggal: new Date(tanggal),
|
|
asalTujuan,
|
|
alasan,
|
|
jenisKelamin,
|
|
},
|
|
})
|
|
|
|
return {
|
|
success: true,
|
|
message: "Data berhasil diupdate",
|
|
data: updated,
|
|
}
|
|
}
|