From de76557326eface9a8806f223343f899b8d3048d Mon Sep 17 00:00:00 2001
From: James Grugett <jahooma@gmail.com>
Date: Wed, 12 Oct 2022 13:55:58 -0500
Subject: [PATCH] Show shares as contract card position. Fix bug on outcome

---
 web/components/contract/contract-card.tsx | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx
index 80c90b93..66d56ee8 100644
--- a/web/components/contract/contract-card.tsx
+++ b/web/components/contract/contract-card.tsx
@@ -1,11 +1,7 @@
 import clsx from 'clsx'
 import Link from 'next/link'
 import { Row } from '../layout/row'
-import {
-  formatLargeNumber,
-  formatMoney,
-  formatPercent,
-} from 'common/util/format'
+import { formatLargeNumber, formatPercent } from 'common/util/format'
 import { contractPath, getBinaryProbPercent } from 'web/lib/firebase/contracts'
 import { Col } from '../layout/col'
 import {
@@ -42,6 +38,7 @@ import { SiteLink } from '../site-link'
 import { ProbChange } from './prob-change-table'
 import { Card } from '../card'
 import { ProfitBadgeMana } from '../profit-badge'
+import { floatingEqual } from 'common/util/math'
 
 export function ContractCard(props: {
   contract: Contract
@@ -405,7 +402,7 @@ export function ContractCardProbChange(props: {
   const metrics = useUserContractMetrics(user?.id, contract.id)
   const dayMetrics = metrics && metrics.from && metrics.from.day
   const outcome =
-    metrics && metrics.hasShares && metrics.totalShares.YES ? 'YES' : 'NO'
+    metrics && floatingEqual(metrics.totalShares.NO ?? 0, 0) ? 'YES' : 'NO'
 
   return (
     <Card className={clsx(className, 'mb-4')}>
@@ -423,7 +420,7 @@ export function ContractCardProbChange(props: {
         </SiteLink>
         <ProbChange className="py-2 pr-4" contract={contract} />
       </Row>
-      {showPosition && metrics && (
+      {showPosition && metrics && metrics.hasShares && (
         <Row
           className={clsx(
             'items-center justify-between gap-4 pl-6 pr-4 pb-2 text-sm'
@@ -431,7 +428,7 @@ export function ContractCardProbChange(props: {
         >
           <Row className="gap-1 text-gray-700">
             <div className="text-gray-500">Position</div>
-            {formatMoney(metrics.payout)} {outcome}
+            {Math.floor(metrics.totalShares[outcome])} {outcome}
           </Row>
 
           {dayMetrics && (