Remove quadratic matching from /charity
This commit is contained in:
parent
dcd2ccae1b
commit
b501776e33
|
@ -6,10 +6,9 @@ import { Charity } from 'common/charity'
|
||||||
import { useCharityTxns } from 'web/hooks/use-charity-txns'
|
import { useCharityTxns } from 'web/hooks/use-charity-txns'
|
||||||
import { manaToUSD } from '../../../common/util/format'
|
import { manaToUSD } from '../../../common/util/format'
|
||||||
import { Row } from '../layout/row'
|
import { Row } from '../layout/row'
|
||||||
import { Col } from '../layout/col'
|
|
||||||
|
|
||||||
export function CharityCard(props: { charity: Charity; match?: number }) {
|
export function CharityCard(props: { charity: Charity; match?: number }) {
|
||||||
const { charity, match } = props
|
const { charity } = props
|
||||||
const { slug, photo, preview, id, tags } = charity
|
const { slug, photo, preview, id, tags } = charity
|
||||||
|
|
||||||
const txns = useCharityTxns(id)
|
const txns = useCharityTxns(id)
|
||||||
|
@ -36,18 +35,18 @@ export function CharityCard(props: { charity: Charity; match?: number }) {
|
||||||
{raised > 0 && (
|
{raised > 0 && (
|
||||||
<>
|
<>
|
||||||
<Row className="mt-4 flex-1 items-end justify-center gap-6 text-gray-900">
|
<Row className="mt-4 flex-1 items-end justify-center gap-6 text-gray-900">
|
||||||
<Col>
|
<Row className="items-baseline gap-1">
|
||||||
<span className="text-3xl font-semibold">
|
<span className="text-3xl font-semibold">
|
||||||
{formatUsd(raised)}
|
{formatUsd(raised)}
|
||||||
</span>
|
</span>
|
||||||
<span>raised</span>
|
raised
|
||||||
</Col>
|
</Row>
|
||||||
{match && (
|
{/* {match && (
|
||||||
<Col className="text-gray-500">
|
<Col className="text-gray-500">
|
||||||
<span className="text-xl">+{formatUsd(match)}</span>
|
<span className="text-xl">+{formatUsd(match)}</span>
|
||||||
<span className="">match</span>
|
<span className="">match</span>
|
||||||
</Col>
|
</Col>
|
||||||
)}
|
)} */}
|
||||||
</Row>
|
</Row>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -13,7 +13,6 @@ import { CharityCard } from 'web/components/charity/charity-card'
|
||||||
import { Col } from 'web/components/layout/col'
|
import { Col } from 'web/components/layout/col'
|
||||||
import { Spacer } from 'web/components/layout/spacer'
|
import { Spacer } from 'web/components/layout/spacer'
|
||||||
import { Page } from 'web/components/page'
|
import { Page } from 'web/components/page'
|
||||||
import { SiteLink } from 'web/components/site-link'
|
|
||||||
import { Title } from 'web/components/title'
|
import { Title } from 'web/components/title'
|
||||||
import { getAllCharityTxns } from 'web/lib/firebase/txns'
|
import { getAllCharityTxns } from 'web/lib/firebase/txns'
|
||||||
import { manaToUSD } from 'common/util/format'
|
import { manaToUSD } from 'common/util/format'
|
||||||
|
@ -21,6 +20,9 @@ import { quadraticMatches } from 'common/quadratic-funding'
|
||||||
import { Txn } from 'common/txn'
|
import { Txn } from 'common/txn'
|
||||||
import { useTracking } from 'web/hooks/use-tracking'
|
import { useTracking } from 'web/hooks/use-tracking'
|
||||||
import { searchInAny } from 'common/util/parse'
|
import { searchInAny } from 'common/util/parse'
|
||||||
|
import { getUser } from 'web/lib/firebase/users'
|
||||||
|
import { User } from 'common/lib/user'
|
||||||
|
import { SiteLink } from 'web/components/site-link'
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
const txns = await getAllCharityTxns()
|
const txns = await getAllCharityTxns()
|
||||||
|
@ -34,6 +36,7 @@ export async function getStaticProps() {
|
||||||
])
|
])
|
||||||
const matches = quadraticMatches(txns, totalRaised)
|
const matches = quadraticMatches(txns, totalRaised)
|
||||||
const numDonors = uniqBy(txns, (txn) => txn.fromId).length
|
const numDonors = uniqBy(txns, (txn) => txn.fromId).length
|
||||||
|
const mostRecentDonor = await getUser(txns[txns.length - 1].fromId)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
@ -42,6 +45,7 @@ export async function getStaticProps() {
|
||||||
matches,
|
matches,
|
||||||
txns,
|
txns,
|
||||||
numDonors,
|
numDonors,
|
||||||
|
mostRecentDonor,
|
||||||
},
|
},
|
||||||
revalidate: 60,
|
revalidate: 60,
|
||||||
}
|
}
|
||||||
|
@ -50,22 +54,28 @@ export async function getStaticProps() {
|
||||||
type Stat = {
|
type Stat = {
|
||||||
name: string
|
name: string
|
||||||
stat: string
|
stat: string
|
||||||
|
url?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
function DonatedStats(props: { stats: Stat[] }) {
|
function DonatedStats(props: { stats: Stat[] }) {
|
||||||
const { stats } = props
|
const { stats } = props
|
||||||
return (
|
return (
|
||||||
<dl className="mt-3 grid grid-cols-1 gap-5 rounded-lg bg-gradient-to-r from-pink-300 via-purple-300 to-indigo-400 p-4 sm:grid-cols-3">
|
<dl className="mt-3 grid grid-cols-1 gap-5 rounded-lg bg-gradient-to-r from-pink-300 via-purple-300 to-indigo-400 p-4 sm:grid-cols-3">
|
||||||
{stats.map((item) => (
|
{stats.map((stat) => (
|
||||||
<div
|
<div
|
||||||
key={item.name}
|
key={stat.name}
|
||||||
className="overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6"
|
className="overflow-hidden rounded-lg bg-white px-4 py-5 shadow sm:p-6"
|
||||||
>
|
>
|
||||||
<dt className="truncate text-sm font-medium text-gray-500">
|
<dt className="truncate text-sm font-medium text-gray-500">
|
||||||
{item.name}
|
{stat.name}
|
||||||
</dt>
|
</dt>
|
||||||
|
|
||||||
<dd className="mt-1 text-3xl font-semibold text-gray-900">
|
<dd className="mt-1 text-3xl font-semibold text-gray-900">
|
||||||
{item.stat}
|
{stat.url ? (
|
||||||
|
<SiteLink href={stat.url}>{stat.stat}</SiteLink>
|
||||||
|
) : (
|
||||||
|
<span>{stat.stat}</span>
|
||||||
|
)}
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
@ -79,8 +89,9 @@ export default function Charity(props: {
|
||||||
matches: { [charityId: string]: number }
|
matches: { [charityId: string]: number }
|
||||||
txns: Txn[]
|
txns: Txn[]
|
||||||
numDonors: number
|
numDonors: number
|
||||||
|
mostRecentDonor: User
|
||||||
}) {
|
}) {
|
||||||
const { totalRaised, charities, matches, numDonors } = props
|
const { totalRaised, charities, matches, numDonors, mostRecentDonor } = props
|
||||||
|
|
||||||
const [query, setQuery] = useState('')
|
const [query, setQuery] = useState('')
|
||||||
const debouncedQuery = debounce(setQuery, 50)
|
const debouncedQuery = debounce(setQuery, 50)
|
||||||
|
@ -106,7 +117,7 @@ export default function Charity(props: {
|
||||||
<Col className="w-full rounded px-4 py-6 sm:px-8 xl:w-[125%]">
|
<Col className="w-full rounded px-4 py-6 sm:px-8 xl:w-[125%]">
|
||||||
<Col className="">
|
<Col className="">
|
||||||
<Title className="!mt-0" text="Manifold for Charity" />
|
<Title className="!mt-0" text="Manifold for Charity" />
|
||||||
<span className="text-gray-600">
|
{/* <span className="text-gray-600">
|
||||||
Through July 15, up to $25k of donations will be matched via{' '}
|
Through July 15, up to $25k of donations will be matched via{' '}
|
||||||
<SiteLink href="https://wtfisqf.com/" className="font-bold">
|
<SiteLink href="https://wtfisqf.com/" className="font-bold">
|
||||||
quadratic funding
|
quadratic funding
|
||||||
|
@ -116,7 +127,7 @@ export default function Charity(props: {
|
||||||
the FTX Future Fund
|
the FTX Future Fund
|
||||||
</SiteLink>
|
</SiteLink>
|
||||||
!
|
!
|
||||||
</span>
|
</span> */}
|
||||||
<DonatedStats
|
<DonatedStats
|
||||||
stats={[
|
stats={[
|
||||||
{
|
{
|
||||||
|
@ -128,8 +139,9 @@ export default function Charity(props: {
|
||||||
stat: `${numDonors}`,
|
stat: `${numDonors}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Matched via quadratic funding',
|
name: 'Most recent donor',
|
||||||
stat: manaToUSD(sum(Object.values(matches))),
|
stat: mostRecentDonor.name ?? 'Nobody',
|
||||||
|
url: `/${mostRecentDonor.username}`,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user