From aa3647e0f316aada5ccd74f2e39884e8d70922ca Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Sun, 21 Aug 2022 17:10:58 -0700 Subject: [PATCH 1/3] Handle case when no charity txns --- web/pages/charity/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/pages/charity/index.tsx b/web/pages/charity/index.tsx index e9014bfb..0bc6f0f8 100644 --- a/web/pages/charity/index.tsx +++ b/web/pages/charity/index.tsx @@ -39,8 +39,8 @@ export async function getStaticProps() { ]) const matches = quadraticMatches(txns, totalRaised) const numDonors = uniqBy(txns, (txn) => txn.fromId).length - const mostRecentDonor = await getUser(txns[0].fromId) - const mostRecentCharity = txns[0].toId + const mostRecentDonor = txns[0] ? await getUser(txns[0].fromId) : null + const mostRecentCharity = txns[0]?.toId ?? '' return { props: { @@ -94,8 +94,8 @@ export default function Charity(props: { matches: { [charityId: string]: number } txns: Txn[] numDonors: number - mostRecentDonor: User - mostRecentCharity: string + mostRecentDonor?: User | null + mostRecentCharity?: string }) { const { totalRaised, @@ -159,8 +159,8 @@ export default function Charity(props: { }, { name: 'Most recent donor', - stat: mostRecentDonor.name ?? 'Nobody', - url: `/${mostRecentDonor.username}`, + stat: mostRecentDonor?.name ?? 'Nobody', + url: `/${mostRecentDonor?.username}`, }, { name: 'Most recent donation', From 258b2a318fa626df536ca31ce178ec6ea6af4919 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Sun, 21 Aug 2022 21:02:56 -0700 Subject: [PATCH 2/3] Default to showing weekly bet graph --- web/components/portfolio/portfolio-value-section.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/components/portfolio/portfolio-value-section.tsx b/web/components/portfolio/portfolio-value-section.tsx index 13880bd4..604873e9 100644 --- a/web/components/portfolio/portfolio-value-section.tsx +++ b/web/components/portfolio/portfolio-value-section.tsx @@ -14,7 +14,7 @@ export const PortfolioValueSection = memo( }) { const { disableSelector, userId } = props - const [portfolioPeriod, setPortfolioPeriod] = useState('allTime') + const [portfolioPeriod, setPortfolioPeriod] = useState('weekly') const [portfolioHistory, setUsersPortfolioHistory] = useState< PortfolioMetrics[] >([]) @@ -53,13 +53,15 @@ export const PortfolioValueSection = memo( {!disableSelector && ( )} From 3158740ea3195bcf2146a4e5eb9c2d65179444d4 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Sun, 21 Aug 2022 22:13:42 -0700 Subject: [PATCH 3/3] Minor tweaks for custom instances --- web/components/nav/sidebar.tsx | 9 ++++++++- web/components/user-page.tsx | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/web/components/nav/sidebar.tsx b/web/components/nav/sidebar.tsx index 6c4addc4..056ab78a 100644 --- a/web/components/nav/sidebar.tsx +++ b/web/components/nav/sidebar.tsx @@ -58,7 +58,14 @@ function getNavigation() { function getMoreNavigation(user?: User | null) { if (IS_PRIVATE_MANIFOLD) { - return [{ name: 'Leaderboards', href: '/leaderboards' }] + return [ + { name: 'Leaderboards', href: '/leaderboards' }, + { + name: 'Sign out', + href: '#', + onClick: logout, + }, + ] } if (!user) { diff --git a/web/components/user-page.tsx b/web/components/user-page.tsx index 407983fc..2aa837e9 100644 --- a/web/components/user-page.tsx +++ b/web/components/user-page.tsx @@ -29,6 +29,7 @@ import { formatMoney } from 'common/util/format' import { ShareIconButton } from 'web/components/share-icon-button' import { ENV_CONFIG } from 'common/envs/constants' import { BettingStreakModal } from 'web/components/profile/betting-streak-modal' +import { REFERRAL_AMOUNT } from 'common/user' export function UserLink(props: { name: string @@ -226,7 +227,7 @@ export function UserPage(props: { user: User }) { )} - {currentUser?.id === user.id && ( + {currentUser?.id === user.id && REFERRAL_AMOUNT > 0 && ( - Earn {formatMoney(500)} when you refer a friend! + Earn {formatMoney(REFERRAL_AMOUNT)} when you refer a friend! {' '} You have