generated from hack4impact-upenn/boilerplate-s2022
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
392 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import FilteringTable from './FilteringTable'; | ||
|
||
function CommunicationsTable() { | ||
// // Define the columns | ||
// // <Date>, <# of Recipients>, <Recipient List>, <Added Groups> | ||
// const columns = [ | ||
// { id: 'date_created', label: 'Date' }, | ||
// { id: 'donor_ids', label: '# of Recipients' }, | ||
// { id: 'donor_ids', label: 'Recipient List' }, | ||
// { id: 'group_name', label: 'Added Groups' }, | ||
// // Add more columns as needed | ||
// ]; | ||
|
||
// // Generate the rows | ||
// const rows = []; | ||
// const startDate = new Date('2023-01-01'); | ||
// const endDate = new Date('2024-12-31'); | ||
// for (let d = startDate; d <= endDate; d.setDate(d.getDate() + 1)) { | ||
// rows.push({ | ||
// id: rows.length + 1, | ||
// name: `Name ${rows.length + 1}`, | ||
// date: d.toISOString().split('T')[0], // Format the date as 'yyyy-mm-dd' | ||
// // Add more data as needed | ||
// }); | ||
// } | ||
|
||
// return <FilteringTable columns={columns} rows={rows} />; | ||
} | ||
|
||
export default CommunicationsTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { useData } from '../../util/api'; | ||
import FilteringTable from './FilteringTable'; | ||
|
||
interface BasicTableProps { | ||
alignment: string; | ||
} | ||
|
||
function DonationsTable({ alignment }: BasicTableProps) { | ||
const donations = useData('donation/all'); | ||
const [donationsData, setDonationsData] = useState<any>([]); | ||
|
||
useEffect(() => { | ||
const data = donations?.data || []; | ||
const filteredData = data.filter( | ||
(donation: any) => donation.type === alignment, | ||
); | ||
setDonationsData(filteredData); | ||
}, [donations?.data, alignment]); | ||
|
||
// columns: <Date>, <Amount>, <Donor>, <Payment Type>, <Purpose> | ||
const columns = [ | ||
{ id: 'date', label: 'Date' }, | ||
{ id: 'amount', label: 'Amount' }, | ||
{ id: 'donor_id', label: 'Donor' }, | ||
{ id: 'payment_type', label: 'Payment Type' }, | ||
{ id: 'purpose_id', label: 'Purpose' }, | ||
]; | ||
|
||
// const rows = donationsData.map((donation: any) => ({ | ||
// date: new Date(donation.date).toISOString().split('T')[0], | ||
// amount: donation.amount, | ||
// donor_id: donation.donor_id, | ||
// payment_type: donation.payment_type, | ||
// purpose_id: donation.purpose_id, | ||
// })); | ||
|
||
const rows: any = []; | ||
donationsData.forEach((donation: any, index: number) => { | ||
rows.push({ | ||
id: index + 1, | ||
date: new Date(donation.date).toISOString().split('T')[0], | ||
amount: donation.amount, | ||
donor_id: donation.donor_id, | ||
payment_type: donation.payment_type, | ||
purpose_id: donation.purpose_id, | ||
}); | ||
}); | ||
|
||
return <FilteringTable columns={columns} rows={rows} />; | ||
} | ||
|
||
export default DonationsTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import FilteringTable from './FilteringTable'; | ||
|
||
function DonorsTable() { | ||
// Define the columns | ||
// <Name>, <Donor Group>, <Recent Donation>, <Last Communication> | ||
// const columns = [ | ||
// { id: 'contact_name', label: 'Name' }, | ||
// { id: 'donor_group', label: 'Donor Group' }, | ||
// { id: 'last_donation_date', label: 'Recent Donation' }, | ||
// { id: 'last_communication_date', label: 'Last Communication' }, | ||
// // Add more columns as needed | ||
// ]; | ||
|
||
// // Generate the rows | ||
// const rows = []; | ||
// const startDate = new Date('2023-01-01'); | ||
// const endDate = new Date('2024-12-31'); | ||
// for (let d = startDate; d <= endDate; d.setDate(d.getDate() + 1)) { | ||
// rows.push({ | ||
// id: rows.length + 1, | ||
// name: `Name ${rows.length + 1}`, | ||
// date: d.toISOString().split('T')[0], // Format the date as 'yyyy-mm-dd' | ||
// // Add more data as needed | ||
// }); | ||
|
||
// } | ||
|
||
// return <FilteringTable columns={columns} rows={rows} />; | ||
} | ||
|
||
export default DonorsTable; |
Oops, something went wrong.