refactor(kependudukan): improve TypeScript types and clean up code

- Add proper TypeScript interfaces for seeder files
- Rename MigrasiPendudukForm interface for consistency
- Separate asal/tujuan fields in MigrasiPenduduk API based on jenis
- Remove unnecessary eslint-disable comments
- Add local type definitions for public kependudukan pages
- Clean up unused imports (React, Flex, IconBuilding)
- Improve type safety in form handlers (handleChangeText vs handleChangeSelect)
- Add explicit type casting where needed to fix type errors

Co-authored-by: Qwen Code

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-04-13 15:00:33 +08:00
parent d84edc44f5
commit 80186bf493
28 changed files with 213 additions and 134 deletions

View File

@@ -1,38 +1,34 @@
import prisma from "@/lib/prisma";
import { Prisma } from "@prisma/client";
import { Context } from "elysia";
type FormCreate = Prisma.MigrasiPendudukGetPayload<{
select: {
jenis: true;
nama: true;
tanggal: true;
asalTujuan: true;
alasan: true;
jenisKelamin: true;
}
}>
type FormCreate = {
jenis: string;
nama: string;
tanggal: string;
asalTujuan: string;
alasan: string | null;
}
export default async function migrasiPendudukCreate(context: Context) {
const body = context.body as FormCreate;
const isMasuk = body.jenis === 'MASUK';
const created = await prisma.migrasiPenduduk.create({
data: {
jenis: body.jenis,
jenis: body.jenis as 'MASUK' | 'KELUAR',
nama: body.nama,
tanggal: new Date(body.tanggal),
asalTujuan: body.asalTujuan,
asal: isMasuk ? body.asalTujuan : undefined,
tujuan: !isMasuk ? body.asalTujuan : undefined,
alasan: body.alasan,
jenisKelamin: body.jenisKelamin,
},
select: {
id: true,
jenis: true,
nama: true,
tanggal: true,
asalTujuan: true,
alasan: true,
jenisKelamin: true,
}
});
return {