import React from 'react'; export default function DonationModal({ showDonationModal, setShowDonationModal, donationFormData, setDonationFormData, hubs, isSubmittingDonation, handleSaveDonation, donationsList, profile }) { if (!showDonationModal) return null; if (!profile) return null; // Secure fail-safe for unauthenticated users // Check roles: PIC, Hub Head, and Super Admin can record transactions const canEdit = profile.role === 'super_admin' || profile.role === 'pic' || profile.role === 'hub_head'; // Calculate Running / Total Balance const totalBalance = donationsList.reduce((acc, curr) => { if (curr.type === 'IN') { return acc + Number(curr.amount); } else { return acc - Number(curr.amount); } }, 0); // Filter hubs list based on role const allowedHubs = profile.role === 'super_admin' ? hubs : hubs.filter(h => h.pic_id === profile.id || h.head_id === profile.id); return (
Belum ada data transaksi.
) : (| Tanggal | Keterangan | Nominal |
|---|---|---|
| {d.transaction_date} |
{d.description}
{d.profiles && d.profiles.full_name && Oleh: {d.profiles.full_name} }
|
{d.type === 'IN' ? '+' : '-'} Rp{Number(d.amount).toLocaleString('id-ID')} |