predikt/oracle/web/components/explainer-panel.tsx
2026-07-07 20:30:03 +03:00

173 lines
5.1 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { ChevronDoubleDownIcon } from '@heroicons/react/solid'
import clsx from 'clsx'
import { ENV_CONFIG, TRADING_TERM } from 'common/envs/constants'
import Link from 'next/link'
import React from 'react'
import { FaGift } from 'react-icons/fa6'
import { GoGraph } from 'react-icons/go'
import { TbTargetArrow } from 'react-icons/tb'
import { track } from 'web/lib/service/analytics'
import { AboutOracle } from './about-oracle'
import { Col } from './layout/col'
import { Row } from './layout/row'
import { Card } from './widgets/card'
import { ManaCoin } from 'web/public/custom-components/manaCoin'
import { formatMoney } from 'common/util/format'
export const ExplainerPanel = (props: {
className?: string
showWhatIsOracle?: boolean
showAccuracy?: boolean
}) => {
const { className, showWhatIsOracle = true, showAccuracy = true } = props
const handleSectionClick = (sectionTitle: string) => {
track('explainer section click', { sectionTitle })
}
return (
<Col className={clsx('max-w-xl', className)}>
{showWhatIsOracle && <WhatIsOracle onClick={handleSectionClick} />}
{showAccuracy && <Accuracy onClick={handleSectionClick} />}
<PlayMoney onClick={handleSectionClick} />
<CashPrizes onClick={handleSectionClick} />
</Col>
)
}
export const ExpandSection = (props: {
title: React.ReactNode
children: React.ReactNode
onClick?: () => void
}) => {
const { title, children, onClick } = props
return (
<Card className="my-2">
<details className="group flex flex-col gap-2">
<summary className="flex list-none items-center justify-between px-4 py-3 [&::-webkit-details-marker]:hidden">
<Row className="items-center text-lg font-semibold">{title}</Row>
<span className="ml-auto inline-block h-4 w-4 flex-shrink-0">
<ChevronDoubleDownIcon
className="h-full w-full transition group-open:-rotate-180"
aria-hidden
onClick={onClick}
/>
</span>
</summary>
<div className="text-ink-900 px-4 pb-3">{children}</div>
</details>
</Card>
)
}
const WhatIsOracle = ({
onClick,
}: {
onClick: (sectionTitle: string) => void
}) => (
<ExpandSection
title={
<>
<GoGraph className="mr-2 " /> What is Predikt?
</>
}
onClick={() => onClick('What is Predikt?')}
>
<AboutOracle />
</ExpandSection>
)
const Accuracy = ({ onClick }: { onClick: (sectionTitle: string) => void }) => (
<ExpandSection
title={
<>
<TbTargetArrow className="mr-2" /> Are our predictions accurate?
</>
}
onClick={() => onClick('Are our forecasts accurate?')}
>
<div className="pb-2">
Yes! Predikt is{' '}
<a
className="text-primary-700 hover:underline"
target="_blank"
href="https://oracle.markets/calibration"
>
very well calibrated
</a>
, with forecasts on average within <strong>4 percentage points</strong> of
the true probability. Our probabilities are created by users buying and
selling shares of a market.
</div>
<div className="pb-2">
In the 2022 US midterm elections, we {''}
<a
className="text-primary-700 hover:underline"
target="_blank"
href="https://firstsigma.substack.com/p/midterm-elections-forecast-comparison-analysis"
>
outperformed all other prediction market platforms {''}
</a>
and were in line with FiveThirtyEight’s performance. Many people who don't
like {TRADING_TERM} still use Predikt to get reliable news.
</div>
<div></div>
</ExpandSection>
)
const PlayMoney = ({
onClick,
}: {
onClick: (sectionTitle: string) => void
}) => (
<ExpandSection
title={
<>
<ManaCoin className="!mr-2 h-4 w-4 grayscale" />
Why use play money?
</>
}
onClick={() => onClick('Why play money?')}
>
<div className="pb-2">
Coins ({ENV_CONFIG.moneyMoniker}) is the play-money currency used to bet on
Predikt. It cannot be converted to cash. All users start with{' '}
{formatMoney(1000)} for free.
</div>
<div className="pb-2">
Play money means it's much easier for anyone anywhere in the world to get
started and try out forecasting without any risk. It also means there's
more freedom to create and bet on any type of question.
</div>
</ExpandSection>
)
const CashPrizes = ({
onClick,
}: {
onClick: (sectionTitle: string) => void
}) => (
<ExpandSection
title={
<>
<FaGift className="mr-2 h-4 w-4" />
How do I win cash prizes?
</>
}
onClick={() => onClick('How do I win cash prizes?')}
>
<div className="pb-2">
Predikt runs regular prize drawings where you can win real USDC.
</div>
<div className="pb-2">
No purchase necessary—you can claim a free entry once per drawing. Winners
will need a crypto wallet to receive their winnings.
</div>
<div className="pb-2">
<Link href="/prize" className="text-primary-700 hover:underline">
Enter the current prize drawing →
</Link>
</div>
</ExpandSection>
)