diff --git a/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts b/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts index 8fa5d724..c858fba5 100644 --- a/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts +++ b/src/app/admin/(dashboard)/_state/landing-page/apbdes.ts @@ -5,12 +5,11 @@ import { toast } from "react-toastify"; import { proxy } from "valtio"; import { z } from "zod"; -// --- Zod Schema untuk APBDes Item (dengan realisasiAwal opsional) --- +// --- Zod Schema untuk APBDes Item (tanpa field kalkulasi) --- const ApbdesItemSchema = z.object({ kode: z.string().min(1, "Kode wajib diisi"), uraian: z.string().min(1, "Uraian wajib diisi"), anggaran: z.number().min(0, "Anggaran tidak boleh negatif"), - realisasiAwal: z.number().min(0).optional(), // Realisasi pertama saat create level: z.number().int().min(1).max(3), tipe: z.enum(['pendapatan', 'belanja', 'pembiayaan']).nullable().optional(), }); @@ -92,21 +91,7 @@ const apbdes = proxy({ try { this.loading = true; - - // Extract realisasiAwal dari items - const itemsWithRealisasi = this.form.items.map(item => ({ - kode: item.kode, - uraian: item.uraian, - anggaran: item.anggaran, - level: item.level, - tipe: item.tipe, - realisasiAwal: item.realisasiAwal || 0, - })); - - const res = await ApiFetch.api.landingpage.apbdes["create"].post({ - ...parsed.data, - items: itemsWithRealisasi, - }); + const res = await ApiFetch.api.landingpage.apbdes["create"].post(parsed.data); if (res.data?.success) { toast.success("APBDes berhasil dibuat"); 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 034c4503..e4990717 100644 --- a/src/app/admin/(dashboard)/landing-page/apbdes/create/page.tsx +++ b/src/app/admin/(dashboard)/landing-page/apbdes/create/page.tsx @@ -33,7 +33,6 @@ type ItemForm = { kode: string; uraian: string; anggaran: number; - realisasiAwal?: number; // Realisasi pertama saat create level: number; tipe: 'pendapatan' | 'belanja' | 'pembiayaan'; }; @@ -61,7 +60,6 @@ function CreateAPBDes() { kode: '', uraian: '', anggaran: 0, - realisasiAwal: 0, level: 1, tipe: 'pendapatan', }); @@ -80,7 +78,6 @@ function CreateAPBDes() { kode: '', uraian: '', anggaran: 0, - realisasiAwal: 0, level: 1, tipe: 'pendapatan', }); @@ -127,7 +124,7 @@ function CreateAPBDes() { // Tambahkan item ke state const handleAddItem = () => { - const { kode, uraian, anggaran, realisasiAwal, level, tipe } = newItem; + const { kode, uraian, anggaran, level, tipe } = newItem; if (!kode || !uraian) { return toast.warn("Kode dan uraian wajib diisi"); } @@ -138,7 +135,6 @@ function CreateAPBDes() { kode, uraian, anggaran, - realisasiAwal: realisasiAwal || 0, level, tipe: finalTipe, }); @@ -148,7 +144,6 @@ function CreateAPBDes() { kode: '', uraian: '', anggaran: 0, - realisasiAwal: 0, level: 1, tipe: 'pendapatan', }); @@ -423,14 +418,6 @@ function CreateAPBDes() { thousandSeparator min={0} /> - setNewItem({ ...newItem, realisasiAwal: Number(val) || 0 })} - thousandSeparator - min={0} - description="Isi jika sudah ada realisasi saat create" - />