From 10ad07179c79a3843d058b0d8010eaeb7d6b4ab9 Mon Sep 17 00:00:00 2001 From: Sinclair Chen Date: Wed, 24 Aug 2022 23:25:38 -0700 Subject: [PATCH] Make entire title clickable --- web/pages/tournament/index.tsx | 72 ++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/web/pages/tournament/index.tsx b/web/pages/tournament/index.tsx index d6bcf976..ccf79d67 100644 --- a/web/pages/tournament/index.tsx +++ b/web/pages/tournament/index.tsx @@ -11,7 +11,8 @@ import dayjs, { Dayjs } from 'dayjs' import customParseFormat from 'dayjs/plugin/customParseFormat' import timezone from 'dayjs/plugin/timezone' import utc from 'dayjs/plugin/utc' -import { throttle } from 'lodash' +import { keyBy, mapValues, throttle } from 'lodash' +import Link from 'next/link' import { ReactNode, useEffect, useRef, useState } from 'react' import { ContractCard } from 'web/components/contract/contract-card' import { DateTimeTooltip } from 'web/components/datetime-tooltip' @@ -20,7 +21,7 @@ import { Row } from 'web/components/layout/row' import { Page } from 'web/components/page' import { SEO } from 'web/components/SEO' import { listContractsByGroupSlug } from 'web/lib/firebase/contracts' -import { getGroup } from 'web/lib/firebase/groups' +import { getGroup, groupPath } from 'web/lib/firebase/groups' dayjs.extend(utc) dayjs.extend(timezone) @@ -48,7 +49,6 @@ const tourneys: Tourney[] = [ { title: 'Fantasy Football Stock Exchange', blurb: 'How many points will each NFL player score?', - url: 'https://manifold.markets/group/fantasy-football-stock-exchange', award: 500, endTime: toDate('Jan 6, 2023'), groupId: 'SxGRqXRpV3RAQKudbcNb', @@ -84,18 +84,19 @@ export async function getStaticProps() { groupIds.map((id, i) => [id, contracts[i]]) ) - const numPeople = Object.fromEntries( - groups.map((g) => [g?.id, g?.memberIds.length]) - ) + const groupMap = keyBy(groups, 'id') + const numPeople = mapValues(groupMap, (g) => g?.memberIds.length) + const slugs = mapValues(groupMap, 'slug') - return { props: { markets, numPeople }, revalidate: 60 * 10 } + return { props: { markets, numPeople, slugs }, revalidate: 60 * 10 } } export default function TournamentPage(props: { markets: { [groupId: string]: Contract[] } numPeople: { [groupId: string]: number } + slugs: { [groupId: string]: string } }) { - const { markets = {}, numPeople = {} } = props + const { markets = {}, numPeople = {}, slugs = {} } = props return ( @@ -110,6 +111,7 @@ export default function TournamentPage(props: { {tourneys.map(({ groupId, ...data }) => (
@@ -121,7 +123,7 @@ export default function TournamentPage(props: { function Section(props: { title: string - url?: string + url: string blurb: string award?: number ppl?: number @@ -132,32 +134,34 @@ function Section(props: { return (
- -

- {url ? {title} : title} -

- - {!!award && ( - - 🏆 ${formatLargeNumber(award)} - - )} - {!!ppl && ( - - - {ppl} - - )} - {endTime && ( - - - - {endTime.format('MMM D')} + + +

+ {title} +

+ + {!!award && ( + + 🏆 ${formatLargeNumber(award)} -
- )} -
-
+ )} + {!!ppl && ( + + + {ppl} + + )} + {endTime && ( + + + + {endTime.format('MMM D')} + + + )} + + + {blurb}