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:
@@ -1,16 +1,35 @@
|
||||
import ApiFetch from "@/lib/api-fetch";
|
||||
import { proxy } from "valtio";
|
||||
|
||||
interface DashboardSummary {
|
||||
tahun: number;
|
||||
summary: {
|
||||
totalPenduduk: number;
|
||||
totalKK: number;
|
||||
totalKelahiran: number;
|
||||
totalKemiskinan: number;
|
||||
};
|
||||
dinamika: {
|
||||
kelahiran: number;
|
||||
kematian: number;
|
||||
pindahMasuk: number;
|
||||
pindahKeluar: number;
|
||||
};
|
||||
agama: unknown[];
|
||||
umur: unknown[];
|
||||
banjar: unknown[];
|
||||
}
|
||||
|
||||
const kependudukanDashboard = proxy({
|
||||
summary: {
|
||||
data: null as any,
|
||||
data: null as DashboardSummary | null,
|
||||
loading: false,
|
||||
async load() {
|
||||
kependudukanDashboard.summary.loading = true;
|
||||
try {
|
||||
const res = await ApiFetch.api.kependudukan.dashboard.summary.get();
|
||||
if (res.status === 200 && res.data?.success) {
|
||||
kependudukanDashboard.summary.data = res.data.data;
|
||||
kependudukanDashboard.summary.data = res.data.data as unknown as DashboardSummary;
|
||||
} else {
|
||||
kependudukanDashboard.summary.data = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user