diff --git a/apps/frontend/src/app/components/DataTable.tsx b/apps/frontend/src/app/components/DataTable.tsx index b9f9357c..872b2f64 100644 --- a/apps/frontend/src/app/components/DataTable.tsx +++ b/apps/frontend/src/app/components/DataTable.tsx @@ -89,7 +89,7 @@ export default function DataTable({ ]; return ( - + {hasWidths && ( {selection && } @@ -182,7 +182,13 @@ export default function DataTable({ )} {columns.map((column) => ( - + {column.cell(row)} ))} diff --git a/apps/frontend/src/app/components/DropdownSelector.tsx b/apps/frontend/src/app/components/DropdownSelector.tsx index 0d5ac92b..4e616e8c 100644 --- a/apps/frontend/src/app/components/DropdownSelector.tsx +++ b/apps/frontend/src/app/components/DropdownSelector.tsx @@ -95,8 +95,7 @@ export default function DropdownSelector({ - - {collection.items.map((item) => + {collection.items.map((item) => multiSelect ? ( )} + {icon && ( + + {icon} + + )} ); -} +} \ No newline at end of file diff --git a/apps/frontend/src/app/donations/page.tsx b/apps/frontend/src/app/donations/page.tsx index 294f9db2..12518a67 100644 --- a/apps/frontend/src/app/donations/page.tsx +++ b/apps/frontend/src/app/donations/page.tsx @@ -38,7 +38,7 @@ export default function DonationsPage() { const [currentPage, setCurrentPage] = useState(1); const [search, setSearch] = useState(''); const [showFilter, setShowFilter] = useState(false); - const [selectedDonor, setSelectedDonor] = useState(''); + const [selectedDonors, setSelectedDonors] = useState([]); const [showSort, setShowSort] = useState(false); const [selectedSort, setSelectedSort] = useState(''); @@ -98,9 +98,9 @@ export default function DonationsPage() { ) : rows; - if (selectedDonor) { - matching = matching.filter((row) => String(row.donor_id) === selectedDonor); - } + if (selectedDonors.length > 0) { + matching = matching.filter((row) => selectedDonors.includes(String(row.donor_id))); + } if (selectedSort === 'Amount') { return [...matching].sort((a, b) => Number(b.amount) - Number(a.amount)); @@ -111,7 +111,7 @@ export default function DonationsPage() { ); } return matching; - }, [rows, search, selectedDonor, selectedSort]); + }, [rows, search, selectedDonors, selectedSort]); const totalPages = Math.max(1, Math.ceil(filtered.length / ROWS_PER_PAGE)); const page = Math.min(currentPage, totalPages); @@ -128,29 +128,22 @@ export default function DonationsPage() { cell: (donation) => formatDateNumeric(donation.donated_at) || '—', skeleton: { width: '70%' }, }, - { - key: 'donor', - header: 'Donor ID', - width: '15%', - cell: (donation) => `#${String(donation.donor_id).padStart(6, '0')}`, - skeleton: { width: '80%' }, - }, { key: 'donor_name', - header: 'Donor', - width: '20%', + header: 'Donor Name', + width: '30%', cell: (donation) => donation.donor_name, }, { key: 'project', header: 'Project Name', - width: '25%', + width: '30%', cell: (donation) => donation.project_name, }, { key: 'amount', header: 'Amount', - width: '15%', + width: '20%', cell: (donation) => formatCurrencyPrecise(donation.amount), skeleton: { width: '55%' }, }, @@ -198,7 +191,6 @@ export default function DonationsPage() { setSaving(true); setSaveError(null); try { - // Previously this only closed the dialog, so nothing was ever persisted. await api.post('/donors/donations', { donor_id: Number(newDonor), project_id: Number(newProject), @@ -255,15 +247,17 @@ export default function DonationsPage() { onClick={() => setShowFilter((prev) => !prev)} > Filter By Donor + {selectedDonors.length > 0 && ` (${selectedDonors.length})`} {showFilter && (
{ - setSelectedDonor(val as string); + setSelectedDonors(val as string[]); setCurrentPage(1); }} /> @@ -468,4 +462,4 @@ export default function DonationsPage() {
); -} +} \ No newline at end of file diff --git a/apps/frontend/src/lib/api.ts b/apps/frontend/src/lib/api.ts index f68fec48..df85f563 100644 --- a/apps/frontend/src/lib/api.ts +++ b/apps/frontend/src/lib/api.ts @@ -3,6 +3,7 @@ const SERVICE_PORTS: Record = { users: '3001', projects: '3002', donors: '3003', + donations: '3003', expenditures: '3004', reports: '3005', }; diff --git a/apps/frontend/test/components/Donations.test.tsx b/apps/frontend/test/components/Donations.test.tsx index 1ae3c91e..89de193b 100644 --- a/apps/frontend/test/components/Donations.test.tsx +++ b/apps/frontend/test/components/Donations.test.tsx @@ -22,7 +22,7 @@ describe('Donations Page Component', () => { it('renders the table with correct headers', () => { render(); expect(screen.getByText('Date')).toBeInTheDocument(); - expect(screen.getByText('Donor ID')).toBeInTheDocument(); + expect(screen.getByText('Donor Name')).toBeInTheDocument(); expect(screen.getByText('Project Name')).toBeInTheDocument(); expect(screen.getByText('Amount')).toBeInTheDocument(); });