Skip to content

Commit

Permalink
mani: fix graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
IanPhilips committed Jan 15, 2025
1 parent e91b4b0 commit 729edef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
9 changes: 6 additions & 3 deletions mani/app/[contractId].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ function ContractPageContent(props: {
contract: manaContract,
userId: user?.id,
totalBets: totalManaBets,
afterTime: manaContractProp.lastBetTime,
})

const cashBetData = useBetData({
contract: cashContract,
userId: user?.id,
totalBets: totalCashBets,
afterTime: cashContractProp.lastBetTime,
})

const { bets, totalBets, yourNewBets, betPoints } =
Expand Down Expand Up @@ -122,7 +124,7 @@ function ContractPageContent(props: {
)}
<UserBetsSummary contract={contract} />
<ContractDescription contract={manaContract} />
<Bets contract={contract} bets={bets} totalBets={totalBets} />
<Bets contract={contract} totalBets={totalBets} />
<CommentsSection contract={manaContract} />
</Col>
</Page>
Expand All @@ -148,8 +150,9 @@ const useBetData = (props: {
contract: Contract
userId: string | undefined
totalBets: number | undefined
afterTime: number | undefined
}) => {
const { userId, contract } = props
const { userId, contract, afterTime } = props
const contractId = contract.id
const mechanism = contract.mechanism
const outcomeType = contract.outcomeType
Expand All @@ -159,7 +162,7 @@ const useBetData = (props: {
{
includeZeroShareRedemptions: isMulti,
filterRedemptions: true,
enabled: true,
afterTime,
},
useIsPageVisible,
(params) => api('bets', params)
Expand Down
22 changes: 16 additions & 6 deletions mani/components/contract/bets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ import { Col } from 'components/layout/col'
import { ThemedText } from 'components/themed-text'
import { useDisplayUserById, useUser } from 'hooks/use-user'
import { CoinNumber } from 'components/widgets/coin-number'
import { useContractBets } from 'client-common/hooks/use-bets'
import { api } from 'lib/api'
import { useIsPageVisible } from 'hooks/use-is-page-visibile'

export function Bets(props: { contract: Contract; totalBets: number }) {
const { contract } = props
// TODO: add pagination and fetching older bets
const bets = useContractBets(
contract.id,
{
includeZeroShareRedemptions: contract.mechanism === 'cpmm-multi-1',
filterRedemptions: true,
},
useIsPageVisible,
(params) => api('bets', params)
)

export function Bets(props: {
contract: Contract
bets: Bet[]
totalBets: number
}) {
const { contract, bets } = props
return (
<Col style={styles.container}>
{bets.map((bet) => (
Expand Down

0 comments on commit 729edef

Please sign in to comment.