import { mapValues, groupBy, sumBy, sum, debounce, uniqBy } from 'lodash' import { useState, useMemo } from 'react' import { Charity as CharityType } from 'common/charity' import { CharityCard } from 'web/components/charity/charity-card' import { Col } from 'web/components/layout/col' import { Spacer } from 'web/components/layout/spacer' import { Page } from 'web/components/page' import { Title } from 'web/components/title' import { manaToUSD } from 'common/util/format' import { quadraticMatches } from 'common/quadratic-funding' import { DonationTxn, Txn } from 'common/txn' import { useTracking } from 'web/hooks/use-tracking' import { searchInAny } from 'common/util/parse' import { getUser } from 'web/lib/firebase/users' import { SiteLink } from 'web/components/site-link' import { User } from 'common/user' import { SEO } from 'web/components/SEO' export async function getStaticProps() { const txns: DonationTxn[] = [] const totals = mapValues(groupBy(txns, 'toId'), (txns) => sumBy(txns, (txn) => txn.amount) ) const totalRaised = sum(Object.values(totals)) const matches = quadraticMatches(txns, totalRaised) const numDonors = uniqBy(txns, (txn) => txn.fromId).length const mostRecentDonor = await getUser(txns[txns.length - 1].fromId) return { props: { totalRaised, charities: [], matches, txns, numDonors, mostRecentDonor, }, revalidate: 60, } } type Stat = { name: string stat: string url?: string } function DonatedStats(props: { stats: Stat[] }) { const { stats } = props return (