Payout resolution notifications styling

This commit is contained in:
Ian Philips 2022-09-26 15:57:38 -04:00
parent a10e4c115e
commit 94ffac287e

View File

@ -971,6 +971,8 @@ function ContractResolvedNotification(props: {
const { sourceText, data } = notification const { sourceText, data } = notification
const { userInvestment, userPayout } = (data as ContractResolutionData) ?? {} const { userInvestment, userPayout } = (data as ContractResolutionData) ?? {}
const subtitle = 'resolved the market' const subtitle = 'resolved the market'
const profitable = userPayout >= userInvestment
const ROI = (userPayout - userInvestment) / userInvestment
const resolutionDescription = () => { const resolutionDescription = () => {
if (!sourceText) return <div /> if (!sourceText) return <div />
@ -1002,23 +1004,21 @@ function ContractResolvedNotification(props: {
const description = const description =
userInvestment && userPayout !== undefined ? ( userInvestment && userPayout !== undefined ? (
<Row className={'gap-1 '}> <>
Resolved: {resolutionDescription()} Resolved: {resolutionDescription()} Invested:
Invested:
<span className={'text-primary'}>{formatMoney(userInvestment)} </span> <span className={'text-primary'}>{formatMoney(userInvestment)} </span>
Payout: Payout:
<span <span
className={clsx( className={clsx(
userPayout > 0 ? 'text-primary' : 'text-red-500', profitable ? 'text-primary' : 'text-red-500',
'truncate' 'truncate text-ellipsis'
)} )}
> >
{formatMoney(userPayout)} {formatMoney(userPayout)}
{` (${userPayout > 0 ? '+' : ''}${Math.round( {userPayout > 0 &&
((userPayout - userInvestment) / userInvestment) * 100 ` (${profitable ? '+' : ''}${Math.round(ROI * 100)}%)`}
)}%)`}
</span> </span>
</Row> </>
) : ( ) : (
<span>Resolved {resolutionDescription()}</span> <span>Resolved {resolutionDescription()}</span>
) )
@ -1038,9 +1038,7 @@ function ContractResolvedNotification(props: {
highlighted={highlighted} highlighted={highlighted}
subtitle={subtitle} subtitle={subtitle}
> >
<Row> <Row className={'line-clamp-2 space-x-1'}>{description}</Row>
<span>{description}</span>
</Row>
</NotificationFrame> </NotificationFrame>
) )
} }