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: {
|
||||
orderBy: { createdAt: 'desc' },
|
||||
take: 30,
|
||||
include: { hashtag: { select: { tag: true, displayTag: true } } },
|
||||
include: {
|
||||
hashtag: { select: { tag: true, displayTag: true } },
|
||||
fund: { select: { name: true, slug: true } },
|
||||
},
|
||||
},
|
||||
managedFunds: {
|
||||
orderBy: { addedAt: 'asc' },
|
||||
@@ -293,6 +296,7 @@ export default async function ProfilePage({ params }: Props) {
|
||||
const isLottery = t.type === 'LOTTERY_WIN'
|
||||
const isLiquidation = t.type === 'LIQUIDATE_LONG' || t.type === 'LIQUIDATE_SHORT'
|
||||
const isSystemReset = t.type === 'DONATION' || t.type === 'BANKRUPTCY' || t.type === 'ACCOUNT_OPEN'
|
||||
const isFundTrade = t.type === 'FUND_INVEST' || t.type === 'FUND_REDEEM'
|
||||
return (
|
||||
<div key={t.id} className="px-4 py-3 text-sm space-y-1.5">
|
||||
{/* Primary row: badge · hashtag/label · total */}
|
||||
@@ -307,6 +311,8 @@ export default async function ProfilePage({ params }: Props) {
|
||||
? 'bg-purple-500/15 text-purple-400'
|
||||
: t.type === 'ACCOUNT_OPEN'
|
||||
? 'bg-emerald-500/15 text-emerald-400'
|
||||
: isFundTrade
|
||||
? 'bg-indigo-500/15 text-indigo-400'
|
||||
: t.type.startsWith('BUY')
|
||||
? 'bg-emerald-500/15 text-emerald-400'
|
||||
: 'bg-red-500/15 text-red-400'
|
||||
@@ -324,6 +330,13 @@ export default async function ProfilePage({ params }: Props) {
|
||||
? 'Bankruptcy declared'
|
||||
: 'Account opened'}
|
||||
</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
|
||||
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">
|
||||
<span>{formatDistanceToNow(t.createdAt, { addSuffix: true })}</span>
|
||||
{!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>
|
||||
{/* PnL: sell, liquidation, and reset trades */}
|
||||
{(t.type === 'SELL_LONG' || t.type === 'SELL_SHORT' || isLiquidation || t.type === 'DONATION' || t.type === 'BANKRUPTCY') && (
|
||||
{/* 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 === 'FUND_REDEEM') && (
|
||||
<div className={`text-xs text-right ${pnlColor(t.profit)}`}>{formatPnl(t.profit)}</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user