fix(kependudukan): remove jenisKelamin field and align MigrasiPenduduk with database schema

- Remove jenisKelamin field from API, state, and UI components
- Fix MigrasiPenduduk API to use null instead of undefined for optional fields
- Update create/edit forms to properly handle asal/tujuan fields based on jenis
- Fix DatePickerInput type handling with valueFormat prop
- Update list page to display asal or tujuan conditionally
- Add proper select statements in API responses
- Fix TypeScript type errors in migrasi-penduduk module

Closes: Schema mismatch causing errors when inputting migrasi penduduk data

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
2026-04-13 15:53:58 +08:00
parent 62a9a49502
commit 04001c905b
7 changed files with 46 additions and 75 deletions

View File

@@ -19,8 +19,8 @@ export default async function migrasiPendudukCreate(context: Context) {
jenis: body.jenis as 'MASUK' | 'KELUAR',
nama: body.nama,
tanggal: new Date(body.tanggal),
asal: isMasuk ? body.asalTujuan : undefined,
tujuan: !isMasuk ? body.asalTujuan : undefined,
asal: isMasuk ? body.asalTujuan : null,
tujuan: !isMasuk ? body.asalTujuan : null,
alasan: body.alasan,
},
select: {
@@ -28,6 +28,8 @@ export default async function migrasiPendudukCreate(context: Context) {
jenis: true,
nama: true,
tanggal: true,
asal: true,
tujuan: true,
alasan: true,
}
});

View File

@@ -21,7 +21,6 @@ const MigrasiPenduduk = new Elysia({
tanggal: t.String(),
asalTujuan: t.String(),
alasan: t.Optional(t.String()),
jenisKelamin: t.Optional(t.String()),
}),
})
.put("/:id", migrasiPendudukUpdate, {
@@ -34,7 +33,6 @@ const MigrasiPenduduk = new Elysia({
tanggal: t.String(),
asalTujuan: t.String(),
alasan: t.Optional(t.String()),
jenisKelamin: t.Optional(t.String()),
}),
})
.delete("/del/:id", migrasiPendudukDelete, {

View File

@@ -38,10 +38,19 @@ export default async function migrasiPendudukUpdate(context: Context) {
jenis: jenis as 'MASUK' | 'KELUAR',
nama,
tanggal: new Date(tanggal),
asal: jenis === 'MASUK' ? asalTujuan : undefined,
tujuan: jenis === 'KELUAR' ? asalTujuan : undefined,
asal: jenis === 'MASUK' ? asalTujuan : null,
tujuan: jenis === 'KELUAR' ? asalTujuan : null,
alasan,
},
select: {
id: true,
jenis: true,
nama: true,
tanggal: true,
asal: true,
tujuan: true,
alasan: true,
},
})
return {