contract card: simplify date display

This commit is contained in:
mantikoros 2022-01-19 16:01:54 -06:00
parent 2320f0b962
commit 4cca60b16e
2 changed files with 28 additions and 14 deletions

View File

@ -156,30 +156,39 @@ export function ContractDetails(props: { contract: Contract }) {
username={creatorUsername}
/>
<div className=""></div>
<div className="whitespace-nowrap">
<DateTimeTooltip time={contract.createdTime}>
<DateTimeTooltip text="Market created:" time={contract.createdTime}>
{createdDate}
</DateTimeTooltip>
{resolvedDate && contract.resolutionTime ? (
<>
{' - '}
<DateTimeTooltip time={contract.resolutionTime}>
<DateTimeTooltip
text="Market resolved:"
time={contract.resolutionTime}
>
{resolvedDate}
</DateTimeTooltip>
</>
) : null}
</div>
{!resolvedDate && closeTime && (
<>
<div className=""></div>
<div className="whitespace-nowrap">
{closeTime > Date.now() ? 'Closes' : 'Closed'}{' '}
<DateTimeTooltip time={closeTime}>
{!resolvedDate && closeTime && (
<>
{' - '}
<DateTimeTooltip
text={
closeTime > Date.now() ? 'Market closes: ' : 'Market closed:'
}
time={closeTime}
>
{dayjs(closeTime).format('MMM D, YYYY')}
</DateTimeTooltip>
</div>
</>
)}
</>
)}
</div>
<div className=""></div>
<div className="whitespace-nowrap">{formatMoney(truePool)} pool</div>
</Row>

View File

@ -9,14 +9,19 @@ dayjs.extend(advanced)
export function DateTimeTooltip(props: {
time: number
text?: string
children?: React.ReactNode
}) {
const { time } = props
const { time, text } = props
const formattedTime = dayjs(time).format('MMM DD, YYYY hh:mm a z')
const toolTip = text ? `${text} ${formattedTime}` : formattedTime
return (
<>
<span
className="tooltip cursor-default hidden sm:inline-block"
data-tip={dayjs(time).format('MMM DD, YYYY hh:mm a z')}
data-tip={toolTip}
>
{props.children}
</span>