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:
@@ -5,7 +5,8 @@ function Summary({ title, data }: any) {
|
||||
if (!data || data.length === 0) return null;
|
||||
|
||||
const totalAnggaran = data.reduce((s: number, i: any) => s + i.anggaran, 0);
|
||||
const totalRealisasi = data.reduce((s: number, i: any) => s + i.totalRealisasi, 0);
|
||||
// Use realisasi field (already mapped from totalRealisasi in transformAPBDesData)
|
||||
const totalRealisasi = data.reduce((s: number, i: any) => s + (i.realisasi || i.totalRealisasi || 0), 0);
|
||||
|
||||
const persen =
|
||||
totalAnggaran > 0 ? (totalRealisasi / totalAnggaran) * 100 : 0;
|
||||
@@ -87,7 +88,8 @@ export default function GrafikRealisasi({ apbdesData }: any) {
|
||||
|
||||
// Hitung total keseluruhan
|
||||
const totalAnggaranSemua = items.reduce((s: number, i: any) => s + i.anggaran, 0);
|
||||
const totalRealisasiSemua = items.reduce((s: number, i: any) => s + i.totalRealisasi, 0);
|
||||
// Use realisasi field (already mapped from totalRealisasi in transformAPBDesData)
|
||||
const totalRealisasiSemua = items.reduce((s: number, i: any) => s + (i.realisasi || i.totalRealisasi || 0), 0);
|
||||
const persenSemua = totalAnggaranSemua > 0 ? (totalRealisasiSemua / totalAnggaranSemua) * 100 : 0;
|
||||
|
||||
const formatRupiah = (angka: number) => {
|
||||
|
||||
Reference in New Issue
Block a user