import { DatumValue } from '@nivo/core' import { ResponsiveLine } from '@nivo/line' import dayjs from 'dayjs' import { useBets } from '../hooks/use-bets' import { Contract } from '../lib/firebase/contracts' export function ContractProbGraph(props: { contract: Contract }) { const { contract } = props const { id, seedAmounts } = contract let bets = useBets(id) if (bets === 'loading') bets = [] const seedProb = seedAmounts.YES ** 2 / (seedAmounts.YES ** 2 + seedAmounts.NO ** 2) const times = [ contract.createdTime, ...bets.map((bet) => bet.createdTime), ].map((time) => new Date(time)) const probs = [seedProb, ...bets.map((bet) => bet.probAfter)] const points = probs.map((prob, i) => ({ x: times[i], y: prob * 100 })) const data = [{ id: 'Yes', data: points, color: '#11b981' }] const lessThanAWeek = times[times.length - 1].getTime() - times[0].getTime() < 1000 * 60 * 60 * 24 * 7 const tickValues = [0, 25, 50, 75, 100] return (