feat: include fund information in trade display and enhance fund trade styling
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m19s
Build Images and Deploy / Update-PROD-Stack (push) Successful in 1m19s
This commit is contained in:
@@ -40,7 +40,10 @@ export default async function ProfilePage({ params }: Props) {
|
|||||||
trades: {
|
trades: {
|
||||||
orderBy: { createdAt: 'desc' },
|
orderBy: { createdAt: 'desc' },
|
||||||
take: 30,
|
take: 30,
|
||||||
include: { hashtag: { select: { tag: true, displayTag: true } } },
|
include: {
|
||||||
|
hashtag: { select: { tag: true, displayTag: true } },
|
||||||
|
fund: { select: { name: true, slug: true } },
|
||||||
|
},
|
||||||
},
|
},
|
||||||
managedFunds: {
|
managedFunds: {
|
||||||
orderBy: { addedAt: 'asc' },
|
orderBy: { addedAt: 'asc' },
|
||||||
@@ -293,6 +296,7 @@ export default async function ProfilePage({ params }: Props) {
|
|||||||
const isLottery = t.type === 'LOTTERY_WIN'
|
const isLottery = t.type === 'LOTTERY_WIN'
|
||||||
const isLiquidation = t.type === 'LIQUIDATE_LONG' || t.type === 'LIQUIDATE_SHORT'
|
const isLiquidation = t.type === 'LIQUIDATE_LONG' || t.type === 'LIQUIDATE_SHORT'
|
||||||
const isSystemReset = t.type === 'DONATION' || t.type === 'BANKRUPTCY' || t.type === 'ACCOUNT_OPEN'
|
const isSystemReset = t.type === 'DONATION' || t.type === 'BANKRUPTCY' || t.type === 'ACCOUNT_OPEN'
|
||||||
|
const isFundTrade = t.type === 'FUND_INVEST' || t.type === 'FUND_REDEEM'
|
||||||
return (
|
return (
|
||||||
<div key={t.id} className="px-4 py-3 text-sm space-y-1.5">
|
<div key={t.id} className="px-4 py-3 text-sm space-y-1.5">
|
||||||
{/* Primary row: badge · hashtag/label · total */}
|
{/* Primary row: badge · hashtag/label · total */}
|
||||||
@@ -307,6 +311,8 @@ export default async function ProfilePage({ params }: Props) {
|
|||||||
? 'bg-purple-500/15 text-purple-400'
|
? 'bg-purple-500/15 text-purple-400'
|
||||||
: t.type === 'ACCOUNT_OPEN'
|
: t.type === 'ACCOUNT_OPEN'
|
||||||
? 'bg-emerald-500/15 text-emerald-400'
|
? 'bg-emerald-500/15 text-emerald-400'
|
||||||
|
: isFundTrade
|
||||||
|
? 'bg-indigo-500/15 text-indigo-400'
|
||||||
: t.type.startsWith('BUY')
|
: t.type.startsWith('BUY')
|
||||||
? 'bg-emerald-500/15 text-emerald-400'
|
? 'bg-emerald-500/15 text-emerald-400'
|
||||||
: 'bg-red-500/15 text-red-400'
|
: 'bg-red-500/15 text-red-400'
|
||||||
@@ -324,6 +330,13 @@ export default async function ProfilePage({ params }: Props) {
|
|||||||
? 'Bankruptcy declared'
|
? 'Bankruptcy declared'
|
||||||
: 'Account opened'}
|
: 'Account opened'}
|
||||||
</span>
|
</span>
|
||||||
|
) : isFundTrade ? (
|
||||||
|
<Link
|
||||||
|
href={`/fund/${t.fund!.slug}`}
|
||||||
|
className="text-indigo-300 hover:text-indigo-200 font-medium truncate flex-1 min-w-0"
|
||||||
|
>
|
||||||
|
{t.fund!.name}
|
||||||
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<Link
|
<Link
|
||||||
href={`/hashtag/${t.hashtag!.tag}`}
|
href={`/hashtag/${t.hashtag!.tag}`}
|
||||||
@@ -340,11 +353,11 @@ export default async function ProfilePage({ params }: Props) {
|
|||||||
<div className="flex items-center justify-between text-xs text-slate-500">
|
<div className="flex items-center justify-between text-xs text-slate-500">
|
||||||
<span>{formatDistanceToNow(t.createdAt, { addSuffix: true })}</span>
|
<span>{formatDistanceToNow(t.createdAt, { addSuffix: true })}</span>
|
||||||
{!isLottery && !isSystemReset && (
|
{!isLottery && !isSystemReset && (
|
||||||
<span className="tabular-nums ml-3">{formatNumber(t.shares)} sh @ {formatCurrency(t.price)}</span>
|
<span className="tabular-nums ml-3">{formatNumber(isFundTrade ? t.shares : t.shares)} sh @ {formatCurrency(t.price)}</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
{/* PnL: sell, liquidation, and reset trades */}
|
{/* PnL: sell, liquidation, reset, and fund redeem trades */}
|
||||||
{(t.type === 'SELL_LONG' || t.type === 'SELL_SHORT' || isLiquidation || t.type === 'DONATION' || t.type === 'BANKRUPTCY') && (
|
{(t.type === 'SELL_LONG' || t.type === 'SELL_SHORT' || isLiquidation || t.type === 'DONATION' || t.type === 'BANKRUPTCY' || t.type === 'FUND_REDEEM') && (
|
||||||
<div className={`text-xs text-right ${pnlColor(t.profit)}`}>{formatPnl(t.profit)}</div>
|
<div className={`text-xs text-right ${pnlColor(t.profit)}`}>{formatPnl(t.profit)}</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user