manifold/web/pages/daily-movers.tsx

37 lines
1.2 KiB
TypeScript
Raw Permalink Normal View History

import { ProfitChangeTable } from 'web/components/contract/prob-change-table'
import { Col } from 'web/components/layout/col'
import { Row } from 'web/components/layout/row'
import { LoadingIndicator } from 'web/components/loading-indicator'
import { Page } from 'web/components/page'
import { Title } from 'web/components/title'
2022-09-20 22:40:28 +00:00
import { useTracking } from 'web/hooks/use-tracking'
import { useUser, useUserContractMetricsByProfit } from 'web/hooks/use-user'
import { DailyProfit } from './home'
export default function DailyMovers() {
const user = useUser()
2022-09-20 22:40:28 +00:00
useTracking('view daily movers')
return (
<Page>
<Col className="pm:mx-10 gap-4 sm:px-4 sm:pb-4">
<Row className="mt-4 items-start justify-between sm:mt-0">
<Title className="mx-4 !mb-0 !mt-0 sm:mx-0" text="Daily movers" />
<DailyProfit user={user} />
</Row>
2022-09-29 16:42:16 +00:00
{user && <ProbChangesWrapper userId={user.id} />}
</Col>
</Page>
)
}
2022-09-29 16:42:16 +00:00
function ProbChangesWrapper(props: { userId: string }) {
const { userId } = props
const data = useUserContractMetricsByProfit(userId)
if (!data) return <LoadingIndicator />
2022-09-29 16:42:16 +00:00
return <ProfitChangeTable contracts={data.contracts} metrics={data.metrics} />
2022-09-29 16:42:16 +00:00
}