diff --git a/web/components/layout/tabs.tsx b/web/components/layout/tabs.tsx
index 88f27c78..575a9f0b 100644
--- a/web/components/layout/tabs.tsx
+++ b/web/components/layout/tabs.tsx
@@ -1,10 +1,13 @@
import clsx from 'clsx'
+import Link from 'next/link'
import { useState } from 'react'
type Tab = {
title: string
tabIcon?: JSX.Element
content: JSX.Element
+ // If set, change the url to this href when the tab is selected
+ href?: string
}
export function Tabs(props: { tabs: Tab[]; defaultIndex?: number }) {
@@ -16,24 +19,27 @@ export function Tabs(props: { tabs: Tab[]; defaultIndex?: number }) {
{tabs.map((tab, i) => (
- {
- e.preventDefault()
- setActiveIndex(i)
- }}
- >
- {tab.tabIcon ? {tab.tabIcon} : null}
- {tab.title}
-
+
+ {
+ if (!tab.href) {
+ e.preventDefault()
+ }
+ setActiveIndex(i)
+ }}
+ >
+ {tab.tabIcon ? {tab.tabIcon} : null}
+ {tab.title}
+
+
))}
diff --git a/web/pages/fold/[...slugs]/index.tsx b/web/pages/fold/[...slugs]/index.tsx
index 01c4a471..093c2d85 100644
--- a/web/pages/fold/[...slugs]/index.tsx
+++ b/web/pages/fold/[...slugs]/index.tsx
@@ -40,6 +40,7 @@ import { useRecentBets } from '../../../hooks/use-bets'
import { useRecentComments } from '../../../hooks/use-comments'
import { LoadingIndicator } from '../../../components/loading-indicator'
import { findActiveContracts } from '../../../components/feed/find-active-contracts'
+import { Tabs } from '../../../components/layout/tabs'
export const getStaticProps = fromPropz(getStaticPropz)
export async function getStaticPropz(props: { params: { slugs: string[] } }) {
@@ -169,6 +170,47 @@ export default function FoldPage(props: {
)}
+
+
+ )
+
+ const activityTab = (
+
+ {user !== null && !fold.disallowMarketCreation && (
+
+ )}
+ {recentBets && recentComments ? (
+ <>
+
+ {activeContracts.length === 0 && (
+
+ No activity from matching markets.{' '}
+ {isCurator && 'Try editing to add more tags!'}
+
+ )}
+ >
+ ) : (
+
+ )}
+
+ )
+
+ const leaderboardsTab = (
+
-
-
- {(page === 'activity' || page === 'markets') && (
-
-
- {user !== null && !fold.disallowMarketCreation && (
-
- )}
- {page === 'activity' ? (
- recentBets && recentComments ? (
- <>
-
- {activeContracts.length === 0 && (
-
- No activity from matching markets.{' '}
- {isCurator && 'Try editing to add more tags!'}
-
- )}
- >
- ) : (
-
- )
- ) : (
-
- )}
-
-
- )}
-
- {page === 'leaderboards' && (
-
-
-
- )}
+ ,
+ href: foldPath(fold, 'markets'),
+ },
+ {
+ title: 'Leaderboards',
+ content: leaderboardsTab,
+ href: foldPath(fold, 'leaderboards'),
+ },
+ ]}
+ />
)
}
@@ -333,55 +310,56 @@ function FoldOverview(props: { fold: Fold; curator: User }) {
)
}
+function YourPerformance(props: {
+ traderScores: { [userId: string]: number }
+ creatorScores: { [userId: string]: number }
+
+ user: User | null | undefined
+}) {
+ const { traderScores, creatorScores, user } = props
+
+ const yourTraderScore = user ? traderScores[user.id] : undefined
+ const yourCreatorScore = user ? creatorScores[user.id] : undefined
+
+ return user ? (
+
+
+ Your performance
+
+
+
+
+
+ Trading profit
+ {formatMoney(yourTraderScore ?? 0)}
+
+ {yourCreatorScore && (
+
+ Created market vol
+ {formatMoney(yourCreatorScore)}
+
+ )}
+
+
+
+
+ ) : null
+}
+
function FoldLeaderboards(props: {
traderScores: { [userId: string]: number }
creatorScores: { [userId: string]: number }
topTraders: User[]
topCreators: User[]
user: User | null | undefined
- yourPerformanceClassName?: string
}) {
- const {
- traderScores,
- creatorScores,
- topTraders,
- topCreators,
- user,
- yourPerformanceClassName,
- } = props
-
- const yourTraderScore = user ? traderScores[user.id] : undefined
- const yourCreatorScore = user ? creatorScores[user.id] : undefined
+ const { traderScores, creatorScores, topTraders, topCreators } = props
const topTraderScores = topTraders.map((user) => traderScores[user.id])
const topCreatorScores = topCreators.map((user) => creatorScores[user.id])
return (
<>
- {user && (
-
-
- Your performance
-
-
-
-
-
- Trading profit
- {formatMoney(yourTraderScore ?? 0)}
-
- {yourCreatorScore && (
-
- Created market vol
- {formatMoney(yourCreatorScore)}
-
- )}
-
-
-
-
- )}
-