From b3c169a2d40c58b6b8a371f55414efa1bc6fa9a5 Mon Sep 17 00:00:00 2001 From: nico Date: Tue, 18 Nov 2025 17:23:38 +0800 Subject: [PATCH] Fix create admin & progress bar persentase --- .../(dashboard)/_state/landing-page/apbdes.ts | 2 +- .../landing-page/apbdes/[id]/edit/page.tsx | 26 +++++++++---------- .../landing-page/apbdes/create/page.tsx | 6 ++--- .../_lib/landing_page/apbdes/create.ts | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts b/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts index dcf07589..df9cde1d 100644 --- a/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts +++ b/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts @@ -53,7 +53,7 @@ function normalizeItem(item: Partial>): z.infer selisih, persentase, level: item.level || 1, - tipe: item.tipe || "pendapatan", + tipe: item.tipe, // biarkan null jika memang null }; } diff --git a/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx b/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx index 63455fae..a7914073 100644 --- a/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx +++ b/src/app/admin/(dashboard)/landing-page/apbdes/[id]/edit/page.tsx @@ -115,21 +115,21 @@ function EditAPBDes() { if (!kode || !uraian) { return toast.warn('Kode dan uraian wajib diisi'); } - const finalTipe = level === 1 ? 'pendapatan' : tipe; // Berikan default - const selisih = realisasi - anggaran; - const persentase = anggaran > 0 ? (realisasi / anggaran) * 100 : 0; + const finalTipe = level === 1 ? null : tipe; + const selisih = realisasi - anggaran; + const persentase = anggaran > 0 ? (realisasi / anggaran) * 100 : 0; - apbdesState.edit.addItem({ - kode, - uraian, - anggaran, - realisasi, - selisih, - persentase, - level, - tipe: finalTipe, // ✅ Tidak akan undefined - }); + apbdesState.edit.addItem({ + kode, + uraian, + anggaran, + realisasi, + selisih, + persentase, + level, + tipe: finalTipe, // ✅ Tidak akan undefined + }); setNewItem({ diff --git a/src/app/admin/(dashboard)/landing-page/apbdes/create/page.tsx b/src/app/admin/(dashboard)/landing-page/apbdes/create/page.tsx index 85b61242..f91d6a37 100644 --- a/src/app/admin/(dashboard)/landing-page/apbdes/create/page.tsx +++ b/src/app/admin/(dashboard)/landing-page/apbdes/create/page.tsx @@ -123,8 +123,7 @@ function CreateAPBDes() { return toast.warn("Kode dan uraian wajib diisi"); } - const finalTipe = level === 1 ? 'pendapatan' : tipe; // Berikan default - + const finalTipe = level === 1 ? null : tipe; const selisih = realisasi - anggaran; const persentase = anggaran > 0 ? (realisasi / anggaran) * 100 : 0; @@ -363,8 +362,9 @@ function CreateAPBDes() { { value: 'pendapatan', label: 'Pendapatan' }, { value: 'belanja', label: 'Belanja' }, ]} - value={newItem.tipe} + value={newItem.level === 1 ? null : newItem.tipe} onChange={(val) => setNewItem({ ...newItem, tipe: val as any })} + disabled={newItem.level === 1} />