Daily movers page

This commit is contained in:
James Grugett 2022-09-14 15:39:13 -05:00
parent 90f6aa7d06
commit 1d501ff88d
3 changed files with 29 additions and 4 deletions

View File

@ -11,8 +11,9 @@ export function ProbChangeTable(props: {
changes:
| { positiveChanges: CPMMContract[]; negativeChanges: CPMMContract[] }
| undefined
full?: boolean
}) {
const { changes } = props
const { changes, full } = props
if (!changes) return <LoadingIndicator />
@ -24,7 +25,10 @@ export function ProbChangeTable(props: {
negativeChanges.findIndex((c) => c.probChanges.day > -threshold) + 1
)
const maxRows = Math.min(positiveChanges.length, negativeChanges.length)
const rows = Math.min(3, Math.min(maxRows, countOverThreshold))
const rows = Math.min(
full ? Infinity : 3,
Math.min(maxRows, countOverThreshold)
)
const filteredPositiveChanges = positiveChanges.slice(0, rows)
const filteredNegativeChanges = negativeChanges.slice(0, rows)

View File

@ -0,0 +1,21 @@
import { ProbChangeTable } from 'web/components/contract/prob-change-table'
import { Col } from 'web/components/layout/col'
import { Page } from 'web/components/page'
import { Title } from 'web/components/title'
import { useProbChanges } from 'web/hooks/use-prob-changes'
import { useUser } from 'web/hooks/use-user'
export default function DailyMovers() {
const user = useUser()
const changes = useProbChanges(user?.id ?? '')
return (
<Page>
<Col className="pm:mx-10 gap-4 sm:px-4 sm:pb-4">
<Title className="mx-4 !mb-0 sm:mx-0" text="Daily movers" />
<ProbChangeTable changes={changes} full />
</Col>
</Page>
)
}

View File

@ -61,7 +61,7 @@ export default function Home() {
</Row>
</Row>
<Row className={'w-full items-center gap-8'}>
<Row className={'mb-2 w-full items-center gap-8'}>
<SearchRow />
<DailyProfitAndBalance className="" user={user} />
</Row>
@ -197,7 +197,7 @@ function DailyMoversSection(props: { userId: string | null | undefined }) {
return (
<Col className="gap-2">
<SectionHeader label="Daily movers" href="daily-movers" />
<SectionHeader label="Daily movers" href="/experimental/daily-movers" />
<ProbChangeTable changes={changes} />
</Col>
)