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} username={creatorUsername}
/> />
<div className=""></div> <div className=""></div>
<div className="whitespace-nowrap"> <div className="whitespace-nowrap">
<DateTimeTooltip time={contract.createdTime}> <DateTimeTooltip text="Market created:" time={contract.createdTime}>
{createdDate} {createdDate}
</DateTimeTooltip> </DateTimeTooltip>
{resolvedDate && contract.resolutionTime ? ( {resolvedDate && contract.resolutionTime ? (
<> <>
{' - '} {' - '}
<DateTimeTooltip time={contract.resolutionTime}> <DateTimeTooltip
text="Market resolved:"
time={contract.resolutionTime}
>
{resolvedDate} {resolvedDate}
</DateTimeTooltip> </DateTimeTooltip>
</> </>
) : null} ) : null}
</div>
{!resolvedDate && closeTime && ( {!resolvedDate && closeTime && (
<> <>
<div className=""></div> {' - '}
<div className="whitespace-nowrap"> <DateTimeTooltip
{closeTime > Date.now() ? 'Closes' : 'Closed'}{' '} text={
<DateTimeTooltip time={closeTime}> closeTime > Date.now() ? 'Market closes: ' : 'Market closed:'
}
time={closeTime}
>
{dayjs(closeTime).format('MMM D, YYYY')} {dayjs(closeTime).format('MMM D, YYYY')}
</DateTimeTooltip> </DateTimeTooltip>
</div> </>
</> )}
)} </div>
<div className=""></div> <div className=""></div>
<div className="whitespace-nowrap">{formatMoney(truePool)} pool</div> <div className="whitespace-nowrap">{formatMoney(truePool)} pool</div>
</Row> </Row>

View File

@ -9,14 +9,19 @@ dayjs.extend(advanced)
export function DateTimeTooltip(props: { export function DateTimeTooltip(props: {
time: number time: number
text?: string
children?: React.ReactNode 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 ( return (
<> <>
<span <span
className="tooltip cursor-default hidden sm:inline-block" 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} {props.children}
</span> </span>