Show numeric resolution contract value

This commit is contained in:
Ian Philips 2022-07-11 07:51:48 -06:00
parent 1e68267e8e
commit a2a08b90ff

View File

@ -342,8 +342,6 @@ function IncomeNotificationItem(props: {
<div className={'inline-flex overflow-hidden text-ellipsis pl-1'}> <div className={'inline-flex overflow-hidden text-ellipsis pl-1'}>
<div className={'mr-1 text-black'}> <div className={'mr-1 text-black'}>
<NotificationTextLabel <NotificationTextLabel
contract={null}
defaultText={notification.sourceText ?? ''}
className={'line-clamp-1'} className={'line-clamp-1'}
notification={notification} notification={notification}
justSummary={true} justSummary={true}
@ -375,11 +373,7 @@ function IncomeNotificationItem(props: {
<div className={'line-clamp-2 flex max-w-xl shrink '}> <div className={'line-clamp-2 flex max-w-xl shrink '}>
<div className={'inline'}> <div className={'inline'}>
<span className={'mr-1'}> <span className={'mr-1'}>
<NotificationTextLabel <NotificationTextLabel notification={notification} />
contract={null}
defaultText={notification.sourceText ?? ''}
notification={notification}
/>
</span> </span>
</div> </div>
<span> <span>
@ -532,18 +526,6 @@ function NotificationItem(props: {
sourceText, sourceText,
} = notification } = notification
const [defaultNotificationText, setDefaultNotificationText] =
useState<string>('')
useEffect(() => {
if (sourceText) {
setDefaultNotificationText(sourceText)
} else if (reasonText) {
// Handle arbitrary notifications with reason text here.
setDefaultNotificationText(reasonText)
}
}, [reasonText, sourceText])
const [highlighted] = useState(!notification.isSeen) const [highlighted] = useState(!notification.isSeen)
useEffect(() => { useEffect(() => {
@ -569,8 +551,6 @@ function NotificationItem(props: {
</span> </span>
<div className={'ml-1 text-black'}> <div className={'ml-1 text-black'}>
<NotificationTextLabel <NotificationTextLabel
contract={null}
defaultText={defaultNotificationText}
className={'line-clamp-1'} className={'line-clamp-1'}
notification={notification} notification={notification}
justSummary={true} justSummary={true}
@ -648,11 +628,7 @@ function NotificationItem(props: {
</div> </div>
</Row> </Row>
<div className={'mt-1 ml-1 md:text-base'}> <div className={'mt-1 ml-1 md:text-base'}>
<NotificationTextLabel <NotificationTextLabel notification={notification} />
contract={null}
defaultText={defaultNotificationText}
notification={notification}
/>
</div> </div>
<div className={'mt-6 border-b border-gray-300'} /> <div className={'mt-6 border-b border-gray-300'} />
@ -770,18 +746,21 @@ function getSourceIdForLinkComponent(
} }
function NotificationTextLabel(props: { function NotificationTextLabel(props: {
defaultText: string
contract?: Contract | null
notification: Notification notification: Notification
className?: string className?: string
justSummary?: boolean justSummary?: boolean
}) { }) {
const { contract, className, defaultText, notification, justSummary } = props const { className, notification, justSummary } = props
const { sourceUpdateType, sourceType, sourceText, sourceContractTitle } = const {
notification sourceUpdateType,
sourceType,
sourceText,
sourceContractTitle,
reasonText,
} = notification
const defaultText = sourceText ?? reasonText ?? ''
if (sourceType === 'contract') { if (sourceType === 'contract') {
if (justSummary) if (justSummary) return <span>{sourceContractTitle}</span>
return <span>{contract?.question || sourceContractTitle}</span>
if (!sourceText) return <div /> if (!sourceText) return <div />
// Resolved contracts // Resolved contracts
if (sourceType === 'contract' && sourceUpdateType === 'resolved') { if (sourceType === 'contract' && sourceUpdateType === 'resolved') {
@ -795,11 +774,10 @@ function NotificationTextLabel(props: {
) )
if (sourceText === 'CANCEL') return <CancelLabel /> if (sourceText === 'CANCEL') return <CancelLabel />
if (sourceText === 'MKT' || sourceText === 'PROB') return <MultiLabel /> if (sourceText === 'MKT' || sourceText === 'PROB') return <MultiLabel />
if (contract?.outcomeType === 'PSEUDO_NUMERIC') { // Numeric market
return <NumericValueLabel value={parseFloat(sourceText)} /> return <NumericValueLabel value={parseFloat(sourceText)} />
} }
} }
}
// Close date will be a number - it looks better without it // Close date will be a number - it looks better without it
if (sourceUpdateType === 'closed') { if (sourceUpdateType === 'closed') {
return <div /> return <div />