import { Typography } from '../../../atoms/typography'; import type { PredictionBodyProps } from '../types'; import { nowTime, predictionMath, resolveOutcome, resolveStatus, toTime, } from '../utils'; import { ClosedHero } from './ClosedHero'; import { HorizonProgress } from './HorizonProgress'; import { OpenKpis } from './OpenKpis'; import { PredictionBadges } from './PredictionBadges'; import { PredictionHead } from './PredictionHead'; import { PredictionLadder } from './PredictionLadder'; import { PredictionLevels } from './PredictionLevels'; import { PredictionMeta } from './PredictionMeta'; import { PredictionRange } from './PredictionRange'; /** Header, hero, range bar, then the levels (compact) or the ladder, progress and caption (expanded). */ export function PredictionBody({ prediction: data, expanded, premium, caption, publishedAt, now, labels, }: PredictionBodyProps) { const math = predictionMath(data); const isOpen = resolveStatus(data) === 'open'; const prediction = { ...data, outcome: resolveOutcome(data, math.roi) }; const { symbol, market, expiresAt, closedAt, outcome } = prediction; const nowMs = nowTime(now); const secondsLeft = isOpen && expiresAt != null ? (toTime(expiresAt) - nowMs) / 1000 : 0; const part = { prediction, math, labels }; return ( <> {symbol} {market != null && ( {market} )} } meta={ 0 ? secondsLeft : null} labels={labels} /> } badges={ } /> {!isOpen && math.roi != null ? ( ) : ( )} {expanded ? ( ) : ( )} {expanded && isOpen && expiresAt != null && ( )} {expanded && caption != null && ( {caption} )} ); }