Handle case when no charity txns
This commit is contained in:
parent
d18dd5b8fb
commit
aa3647e0f3
|
@ -39,8 +39,8 @@ 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[0].fromId)
|
const mostRecentDonor = txns[0] ? await getUser(txns[0].fromId) : null
|
||||||
const mostRecentCharity = txns[0].toId
|
const mostRecentCharity = txns[0]?.toId ?? ''
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
|
@ -94,8 +94,8 @@ export default function Charity(props: {
|
||||||
matches: { [charityId: string]: number }
|
matches: { [charityId: string]: number }
|
||||||
txns: Txn[]
|
txns: Txn[]
|
||||||
numDonors: number
|
numDonors: number
|
||||||
mostRecentDonor: User
|
mostRecentDonor?: User | null
|
||||||
mostRecentCharity: string
|
mostRecentCharity?: string
|
||||||
}) {
|
}) {
|
||||||
const {
|
const {
|
||||||
totalRaised,
|
totalRaised,
|
||||||
|
@ -159,8 +159,8 @@ export default function Charity(props: {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Most recent donor',
|
name: 'Most recent donor',
|
||||||
stat: mostRecentDonor.name ?? 'Nobody',
|
stat: mostRecentDonor?.name ?? 'Nobody',
|
||||||
url: `/${mostRecentDonor.username}`,
|
url: `/${mostRecentDonor?.username}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'Most recent donation',
|
name: 'Most recent donation',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user