import React, { Fragment, useState } from 'react' import { bids } from './sample-bids' import { Entry, makeEntries } from './entries' function toTable(entries: Entry[]) { return entries.map((entry, i) => { return ( {i + 1} {toRowStart(entry)} {toRowEnd(entry)} ) }) } function toRowStart(entry: Entry) { if (entry.yesBid && entry.noBid) { return (
SEED
{entry.yesBid} / {entry.noBid}
) } else if (entry.yesBid) { return (
YES
{entry.yesBid}
) } else if (entry.noBid) { return (
NO
{entry.noBid}
) } } function toRowEnd(entry: Entry) { if (!entry.yesBid && !entry.noBid) { return ( N/A N/A N/A N/A ) } else if (entry.yesBid && entry.noBid) { return ( N/A {entry.prob.toFixed(2)} N/A N/A ) } else if (entry.yesBid) { return ( {entry.yesWeight.toFixed(2)} {entry.prob.toFixed(2)} {entry.yesPayout.toFixed(2)} {(entry.yesReturn * 100).toFixed(2)}% ) } else { return ( {entry.noWeight.toFixed(2)} {entry.prob.toFixed(2)} {entry.noPayout.toFixed(2)} {(entry.noReturn * 100).toFixed(2)}% ) } } // Show a hello world React page export default function Simulator() { const [steps, setSteps] = useState(10) const entries = makeEntries(bids.slice(0, steps)) return (

Dynamic Parimutuel Market Simulator

{/* Range slider that sets the current step */} setSteps(parseInt(e.target.value))} />
{toTable(entries)}
Order # Type Bid Weight Prod Max Payout Return
) }