Don't show quick bet when signed out, or for numeric markets
This commit is contained in:
parent
29a05ffff2
commit
4c81106612
web/components/contract
|
@ -28,6 +28,7 @@ import { AvatarDetails, MiscDetails } from './contract-details'
|
|||
import { getExpectedValue, getValueFromBucket } from 'common/calculate-dpm'
|
||||
import { QuickBet, ProbBar, getColor } from './quick-bet'
|
||||
import { useContractWithPreload } from 'web/hooks/use-contract'
|
||||
import { useUser } from 'web/hooks/use-user'
|
||||
|
||||
export function ContractCard(props: {
|
||||
contract: Contract
|
||||
|
@ -40,10 +41,16 @@ export function ContractCard(props: {
|
|||
const { question, outcomeType } = contract
|
||||
const { resolution } = contract
|
||||
|
||||
const marketClosed = (contract.closeTime || Infinity) < Date.now() || !!resolution
|
||||
const user = useUser()
|
||||
|
||||
const marketClosed =
|
||||
(contract.closeTime || Infinity) < Date.now() || !!resolution
|
||||
|
||||
const showQuickBet = !(
|
||||
!user ||
|
||||
marketClosed ||
|
||||
(outcomeType === 'FREE_RESPONSE' && getTopAnswer(contract) === undefined)
|
||||
(outcomeType === 'FREE_RESPONSE' && getTopAnswer(contract) === undefined) ||
|
||||
outcomeType === 'NUMERIC'
|
||||
)
|
||||
|
||||
return (
|
||||
|
@ -96,7 +103,7 @@ export function ContractCard(props: {
|
|||
/>
|
||||
</Col>
|
||||
{showQuickBet ? (
|
||||
<QuickBet contract={contract} />
|
||||
<QuickBet contract={contract} user={user} />
|
||||
) : (
|
||||
<Col className="m-auto pl-2">
|
||||
{outcomeType === 'BINARY' && (
|
||||
|
|
|
@ -19,7 +19,7 @@ export function ContractsGrid(props: {
|
|||
const isBottomVisible = useIsVisible(elem)
|
||||
|
||||
useEffect(() => {
|
||||
if (isBottomVisible) {
|
||||
if (isBottomVisible && hasMore) {
|
||||
loadMore()
|
||||
}
|
||||
}, [isBottomVisible, hasMore, loadMore])
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
NumericContract,
|
||||
FreeResponseContract,
|
||||
} from 'common/contract'
|
||||
import { User } from 'common/user'
|
||||
import {
|
||||
formatLargeNumber,
|
||||
formatMoney,
|
||||
|
@ -21,7 +22,6 @@ import {
|
|||
} from 'common/util/format'
|
||||
import { useState } from 'react'
|
||||
import toast from 'react-hot-toast'
|
||||
import { useUser } from 'web/hooks/use-user'
|
||||
import { useUserContractBets } from 'web/hooks/use-user-bets'
|
||||
import { placeBet } from 'web/lib/firebase/api-call'
|
||||
import { getBinaryProb, getBinaryProbPercent } from 'web/lib/firebase/contracts'
|
||||
|
@ -33,11 +33,10 @@ import { useSaveShares } from '../use-save-shares'
|
|||
|
||||
const BET_SIZE = 10
|
||||
|
||||
export function QuickBet(props: { contract: Contract }) {
|
||||
const { contract } = props
|
||||
export function QuickBet(props: { contract: Contract; user: User }) {
|
||||
const { contract, user } = props
|
||||
|
||||
const user = useUser()
|
||||
const userBets = useUserContractBets(user?.id, contract.id)
|
||||
const userBets = useUserContractBets(user.id, contract.id)
|
||||
const topAnswer =
|
||||
contract.outcomeType === 'FREE_RESPONSE'
|
||||
? getTopAnswer(contract as FreeResponseContract)
|
||||
|
|
Loading…
Reference in New Issue
Block a user