fix(public-apbdes): fix realisasi display on public APBDes page
- Fix types.ts transformAPBDesData to map totalRealisasi → realisasi - Backend returns totalRealisasi, frontend expects realisasi - Add fallback to use item.realisasi if totalRealisasi not available - Fix grafikRealisasi.tsx to use realisasi field - Update Summary component to use i.realisasi || i.totalRealisasi - Update total calculation to use realisasi field - Fix apbDesaTable.tsx to use realisasi field - Update total calculation to use item.realisasi - Fix apbDesaProgress.tsx to use realisasi field - Update calcTotal to use item.realisasi with fallback Root cause: Backend Prisma schema uses 'totalRealisasi' field, but public page components were expecting 'realisasi' field. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@@ -78,7 +78,8 @@ function APBDesProgress({ apbdesData }: APBDesProgressProps) {
|
||||
// Hitung total per kategori
|
||||
const calcTotal = (items: { anggaran: number; realisasi: number }[]) => {
|
||||
const anggaran = items.reduce((sum, item) => sum + item.anggaran, 0);
|
||||
const realisasi = items.reduce((sum, item) => sum + item.realisasi, 0);
|
||||
// Use realisasi field (already mapped from totalRealisasi in transformAPBDesData)
|
||||
const realisasi = items.reduce((sum, item) => sum + (item.realisasi || 0), 0);
|
||||
const persen = anggaran > 0 ? (realisasi / anggaran) * 100 : 0;
|
||||
return { anggaran, realisasi, persen };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user