User page: Move portfolio graph and social stats to new tab
This commit is contained in:
parent
85be84071a
commit
21870d7edb
|
@ -8,16 +8,21 @@ import { formatTime } from 'web/lib/util/time'
|
||||||
|
|
||||||
export const PortfolioValueGraph = memo(function PortfolioValueGraph(props: {
|
export const PortfolioValueGraph = memo(function PortfolioValueGraph(props: {
|
||||||
portfolioHistory: PortfolioMetrics[]
|
portfolioHistory: PortfolioMetrics[]
|
||||||
|
mode: 'value' | 'profit'
|
||||||
height?: number
|
height?: number
|
||||||
includeTime?: boolean
|
includeTime?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { portfolioHistory, height, includeTime } = props
|
const { portfolioHistory, height, includeTime, mode } = props
|
||||||
const { width } = useWindowSize()
|
const { width } = useWindowSize()
|
||||||
|
|
||||||
const points = portfolioHistory.map((p) => {
|
const points = portfolioHistory.map((p) => {
|
||||||
|
const { timestamp, balance, investmentValue, totalDeposits } = p
|
||||||
|
const value = balance + investmentValue
|
||||||
|
const profit = value - totalDeposits
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: new Date(p.timestamp),
|
x: new Date(timestamp),
|
||||||
y: p.balance + p.investmentValue,
|
y: mode === 'value' ? value : profit,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const data = [{ id: 'Value', data: points, color: '#11b981' }]
|
const data = [{ id: 'Value', data: points, color: '#11b981' }]
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { usePortfolioHistory } from 'web/hooks/use-portfolio-history'
|
||||||
import { Period } from 'web/lib/firebase/users'
|
import { Period } from 'web/lib/firebase/users'
|
||||||
import { Col } from '../layout/col'
|
import { Col } from '../layout/col'
|
||||||
import { Row } from '../layout/row'
|
import { Row } from '../layout/row'
|
||||||
|
import { Spacer } from '../layout/spacer'
|
||||||
import { PortfolioValueGraph } from './portfolio-value-graph'
|
import { PortfolioValueGraph } from './portfolio-value-graph'
|
||||||
|
|
||||||
export const PortfolioValueSection = memo(
|
export const PortfolioValueSection = memo(
|
||||||
|
@ -24,15 +25,16 @@ export const PortfolioValueSection = memo(
|
||||||
return <></>
|
return <></>
|
||||||
}
|
}
|
||||||
|
|
||||||
const { balance, investmentValue } = lastPortfolioMetrics
|
const { balance, investmentValue, totalDeposits } = lastPortfolioMetrics
|
||||||
const totalValue = balance + investmentValue
|
const totalValue = balance + investmentValue
|
||||||
|
const totalProfit = totalValue - totalDeposits
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Row className="gap-8">
|
<Row className="gap-8">
|
||||||
<Col className="flex-1 justify-center">
|
<Col className="flex-1 justify-center">
|
||||||
<div className="text-sm text-gray-500">Portfolio value</div>
|
<div className="text-sm text-gray-500">Profit</div>
|
||||||
<div className="text-lg">{formatMoney(totalValue)}</div>
|
<div className="text-lg">{formatMoney(totalProfit)}</div>
|
||||||
</Col>
|
</Col>
|
||||||
<select
|
<select
|
||||||
className="select select-bordered self-start"
|
className="select select-bordered self-start"
|
||||||
|
@ -49,6 +51,17 @@ export const PortfolioValueSection = memo(
|
||||||
<PortfolioValueGraph
|
<PortfolioValueGraph
|
||||||
portfolioHistory={currPortfolioHistory}
|
portfolioHistory={currPortfolioHistory}
|
||||||
includeTime={portfolioPeriod == 'daily'}
|
includeTime={portfolioPeriod == 'daily'}
|
||||||
|
mode="profit"
|
||||||
|
/>
|
||||||
|
<Spacer h={8} />
|
||||||
|
<Col className="flex-1 justify-center">
|
||||||
|
<div className="text-sm text-gray-500">Portfolio value</div>
|
||||||
|
<div className="text-lg">{formatMoney(totalValue)}</div>
|
||||||
|
</Col>
|
||||||
|
<PortfolioValueGraph
|
||||||
|
portfolioHistory={currPortfolioHistory}
|
||||||
|
includeTime={portfolioPeriod == 'daily'}
|
||||||
|
mode="value"
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
@ -255,13 +255,6 @@ export function UserPage(props: { user: User }) {
|
||||||
title: 'Comments',
|
title: 'Comments',
|
||||||
content: (
|
content: (
|
||||||
<Col>
|
<Col>
|
||||||
<Row className={'mt-2 mb-4 flex-wrap items-center gap-6'}>
|
|
||||||
<FollowingButton user={user} />
|
|
||||||
<FollowersButton user={user} />
|
|
||||||
<ReferralsButton user={user} />
|
|
||||||
<GroupsButton user={user} />
|
|
||||||
<UserLikesButton user={user} />
|
|
||||||
</Row>
|
|
||||||
<UserCommentsList user={user} />
|
<UserCommentsList user={user} />
|
||||||
</Col>
|
</Col>
|
||||||
),
|
),
|
||||||
|
@ -270,11 +263,25 @@ export function UserPage(props: { user: User }) {
|
||||||
title: 'Bets',
|
title: 'Bets',
|
||||||
content: (
|
content: (
|
||||||
<>
|
<>
|
||||||
<PortfolioValueSection userId={user.id} />
|
|
||||||
<BetsList user={user} />
|
<BetsList user={user} />
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: 'Stats',
|
||||||
|
content: (
|
||||||
|
<Col className="mb-8">
|
||||||
|
<Row className={'mt-2 mb-8 flex-wrap items-center gap-6'}>
|
||||||
|
<FollowingButton user={user} />
|
||||||
|
<FollowersButton user={user} />
|
||||||
|
<ReferralsButton user={user} />
|
||||||
|
<GroupsButton user={user} />
|
||||||
|
<UserLikesButton user={user} />
|
||||||
|
</Row>
|
||||||
|
<PortfolioValueSection userId={user.id} />
|
||||||
|
</Col>
|
||||||
|
),
|
||||||
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user