diff --git a/web/package.json b/web/package.json index 2707476e..6e9d6f7d 100644 --- a/web/package.json +++ b/web/package.json @@ -47,8 +47,8 @@ "autoprefixer": "10.2.6", "concurrently": "6.5.1", "critters": "0.0.16", - "eslint": "8.15.0", - "eslint-config-next": "12.1.6", + "eslint": "7.32.0", + "eslint-config-next": "12.0.4", "husky": "7.0.4", "lint-staged": "12.1.3", "next-sitemap": "^2.5.14", diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index 6a1a726c..96b5feee 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -131,12 +131,6 @@ export function ContractPageContent(props: FirstArgument) { ) : null - // Create a map of userIds to total profits (including sales) - const betsByUser = _.groupBy(bets, 'userId') - const userProfits = _.mapValues(betsByUser, (bets) => - _.sumBy(bets, (bet) => resolvedPayout(contract, bet) - bet.amount) - ) - return ( {showConfetti && ( @@ -187,7 +181,7 @@ export function ContractPageContent(props: FirstArgument) { {isResolved && ( <>
- + ) { ) } -function ContractLeaderboard(props: { userProfits: { [id: string]: number } }) { - const { userProfits } = props +function ContractLeaderboard(props: { contract: Contract; bets: Bet[] }) { + const { contract, bets } = props const [users, setUsers] = useState() - useEffect(() => { - // Find the 5 users with the most profits - const top5Ids = _.entries(userProfits) - .sort(([i1, p1], [i2, p2]) => p2 - p1) - .filter(([, p]) => p > 0) - .slice(0, 5) - .map(([id]) => id) + // Create a map of userIds to total profits (including sales) + const betsByUser = _.groupBy(bets, 'userId') + const userProfits = _.mapValues(betsByUser, (bets) => + _.sumBy(bets, (bet) => resolvedPayout(contract, bet) - bet.amount) + ) + // Find the 5 users with the most profits + const top5Ids = _.entries(userProfits) + .sort(([i1, p1], [i2, p2]) => p2 - p1) + .filter(([, p]) => p > 0) + .slice(0, 5) + .map(([id]) => id) + + useEffect(() => { if (top5Ids.length > 0) { listUsers(top5Ids).then((users) => { const sortedUsers = _.sortBy(users, (user) => -userProfits[user.id]) setUsers(sortedUsers) }) } - }, [userProfits]) + }, []) return users && users.length > 0 ? ( - Manifold Markets — A market for every question diff --git a/web/pages/_document.tsx b/web/pages/_document.tsx index f1a7ccab..93d5d774 100644 --- a/web/pages/_document.tsx +++ b/web/pages/_document.tsx @@ -17,12 +17,28 @@ export default function Document() { href="https://fonts.googleapis.com/css2?family=Major+Mono+Display&family=Readex+Pro:wght@400;600;700&display=swap" rel="stylesheet" /> + + +