From 947374d097528a543c67a4eb3077dc7c1c8f5a61 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Wed, 27 Jul 2022 18:17:30 -0700 Subject: [PATCH] Set up a Grants structure, cloned from Charities --- web/pages/grants/GranteeCard.tsx | 57 ++++++++++++++++++++++++++++++ web/pages/grants/index.tsx | 60 ++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 web/pages/grants/GranteeCard.tsx create mode 100644 web/pages/grants/index.tsx diff --git a/web/pages/grants/GranteeCard.tsx b/web/pages/grants/GranteeCard.tsx new file mode 100644 index 00000000..15361751 --- /dev/null +++ b/web/pages/grants/GranteeCard.tsx @@ -0,0 +1,57 @@ +import Link from 'next/link' +import Image from 'next/image' + +import { Grantee } from '.' +import { Row } from 'web/components/layout/row' +import { sumBy } from 'lodash' + +export default function GranteeCard(props: { grantee: Grantee }) { + const { grantee } = props + const { slug, photo, preview } = grantee + + // sumBy grantee.grantsReceived amount + const raised = sumBy(grantee.grantsReceived, (grant) => grant.amount) + + return ( + +
+
+
+ {photo ? ( + + ) : ( +
+
+ {grantee.name} +
+
+ )} +
+
+
+
{preview}
+ {raised > 0 && ( + + + + {formatUsd(raised)} + + raised + + {/* {match && ( + + +{formatUsd(match)} + match + + )} */} + + )} +
+
+ + ) +} + +function formatUsd(usd: number) { + return `$${usd}` +} diff --git a/web/pages/grants/index.tsx b/web/pages/grants/index.tsx new file mode 100644 index 00000000..6ed3375c --- /dev/null +++ b/web/pages/grants/index.tsx @@ -0,0 +1,60 @@ +import { Col } from 'web/components/layout/col' +import { Page } from 'web/components/page' +import { Title } from 'web/components/title' +import GranteeCard from './GranteeCard' + +export type Grantee = { + name: string // Better be unique lol + // slug = name.toLowerCase().replace(/\s/g, '-') + slug: string + website?: string + photo?: string + preview: string + description: string + grantsReceived: Grant[] +} + +export type Grant = { + date: string // in YYYY-MM-DD format + amount: number // in USD + from: 'FTX FF' | 'SFF' | 'OP' + to: string // The name of the receiving charity + description: string // Why the grant was given; if stated +} + +const grantees: Grantee[] = [ + { + name: 'Manifold Markets', + slug: 'manifold-markets', + website: 'https://manifold.markets', + preview: '', + description: '', + grantsReceived: [ + { + date: '2022-03-01', + amount: 500000, + from: 'FTX FF', + to: 'Manifold Markets', + description: 'Because you guys are awesome!', + }, + ], + }, +] + +export default function Grants() { + return ( + + + + + + <div className="grid max-w-xl grid-flow-row grid-cols-1 gap-4 lg:max-w-full lg:grid-cols-2 xl:grid-cols-3"> + {grantees.map((grantee) => ( + <GranteeCard grantee={grantee} key={grantee.name} /> + ))} + </div> + </Col> + </Col> + </Page> + ) +}