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:
@@ -11,13 +11,12 @@ export default async function migrasiPendudukUpdate(context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
const {jenis, nama, tanggal, asalTujuan, alasan, jenisKelamin} = context.body as {
|
||||
const {jenis, nama, tanggal, asalTujuan, alasan} = context.body as {
|
||||
jenis: string;
|
||||
nama: string;
|
||||
tanggal: string;
|
||||
asalTujuan: string;
|
||||
alasan?: string;
|
||||
jenisKelamin?: string;
|
||||
}
|
||||
|
||||
const existing = await prisma.migrasiPenduduk.findUnique({
|
||||
@@ -36,12 +35,12 @@ export default async function migrasiPendudukUpdate(context: Context) {
|
||||
const updated = await prisma.migrasiPenduduk.update({
|
||||
where: { id },
|
||||
data: {
|
||||
jenis,
|
||||
jenis: jenis as 'MASUK' | 'KELUAR',
|
||||
nama,
|
||||
tanggal: new Date(tanggal),
|
||||
asalTujuan,
|
||||
asal: jenis === 'MASUK' ? asalTujuan : undefined,
|
||||
tujuan: jenis === 'KELUAR' ? asalTujuan : undefined,
|
||||
alasan,
|
||||
jenisKelamin,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user