diff --git a/web/pages/charity/index.tsx b/web/pages/charity/index.tsx index 80003c81..e9014bfb 100644 --- a/web/pages/charity/index.tsx +++ b/web/pages/charity/index.tsx @@ -26,7 +26,9 @@ import { User } from 'common/user' import { SEO } from 'web/components/SEO' export async function getStaticProps() { - const txns = await getAllCharityTxns() + let txns = await getAllCharityTxns() + // Sort by newest txns first + txns = sortBy(txns, 'createdTime').reverse() const totals = mapValues(groupBy(txns, 'toId'), (txns) => sumBy(txns, (txn) => txn.amount) ) @@ -37,7 +39,8 @@ export async function getStaticProps() { ]) const matches = quadraticMatches(txns, totalRaised) const numDonors = uniqBy(txns, (txn) => txn.fromId).length - const mostRecentDonor = await getUser(txns[txns.length - 1].fromId) + const mostRecentDonor = await getUser(txns[0].fromId) + const mostRecentCharity = txns[0].toId return { props: { @@ -47,6 +50,7 @@ export async function getStaticProps() { txns, numDonors, mostRecentDonor, + mostRecentCharity, }, revalidate: 60, } @@ -71,7 +75,7 @@ function DonatedStats(props: { stats: Stat[] }) { {stat.name} -