From f42e3c23da34ca360bad179316ecf806f4e50c1c Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Mon, 13 Dec 2021 23:59:04 -0800 Subject: [PATCH] Split markets into Open and Resolved --- web/components/title.tsx | 2 +- web/pages/markets.tsx | 103 +++++++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 44 deletions(-) diff --git a/web/components/title.tsx b/web/components/title.tsx index df53dcad..d96b5162 100644 --- a/web/components/title.tsx +++ b/web/components/title.tsx @@ -5,7 +5,7 @@ export function Title(props: { text: string; className?: string }) { return (

diff --git a/web/pages/markets.tsx b/web/pages/markets.tsx index 6544a1c3..75620bd1 100644 --- a/web/pages/markets.tsx +++ b/web/pages/markets.tsx @@ -1,4 +1,5 @@ import dayjs from 'dayjs' +import Link from 'next/link' import React, { useEffect, useState } from 'react' import { Header } from '../components/header' import { Col } from '../components/layout/col' @@ -19,48 +20,50 @@ function ContractCard(props: { contract: Contract }) { const probPercent = Math.round(prob * 100) + '%' return ( -
  • -
    -
    -
    - {/* Left side of card */} -
    -

    {contract.question}

    - - {/* Copied from contract-overview.tsx */} - -
    - By {contract.creatorName} + + +
  • +
    +
    +
    + {/* Left side of card */} +
    +

    + {contract.question} +

    + + {/* Copied from contract-overview.tsx */} + +
    + By {contract.creatorName} +
    +
    +
    + {dayjs(createdTime).format('MMM D')} +
    +
    +
    + {formatWithCommas(volume)} vol +
    +
    -
    -
    - {dayjs(createdTime).format('MMM D')} -
    -
    -
    - {formatWithCommas(volume)} vol -
    - -
    - {/* Right side of card */} - - - {probPercent} - - {/* Show a yes and a no button side-by-side */} -
    - - + {/* Right side of card */} + + + {contract.resolution || ( +
    + {probPercent} +
    chance
    +
    + )} + +
    - +
    - - -
  • + + + ) } @@ -74,14 +77,28 @@ export default function Markets() {
    - + <Title text="Open markets" /> <ul role="list" className="grid grid-cols-1 gap-6 sm:grid-cols-1 lg:grid-cols-2" > - {contracts.map((contract) => ( - <ContractCard contract={contract} key={contract.id} /> - ))} + {contracts + .filter((c) => !c.resolution) + .map((contract) => ( + <ContractCard contract={contract} key={contract.id} /> + ))} + </ul> + + <Title text="Resolved markets" className="mt-20" /> + <ul + role="list" + className="grid grid-cols-1 gap-6 sm:grid-cols-1 lg:grid-cols-2" + > + {contracts + .filter((c) => c.resolution) + .map((contract) => ( + <ContractCard contract={contract} key={contract.id} /> + ))} </ul> </div> </div>