diff --git a/packages/atlas/src/components/_crt/RevenueShareStateWidget/RevenueShareStateWidget.tsx b/packages/atlas/src/components/_crt/RevenueShareStateWidget/RevenueShareStateWidget.tsx index 0a41ed784c..10e669e94d 100644 --- a/packages/atlas/src/components/_crt/RevenueShareStateWidget/RevenueShareStateWidget.tsx +++ b/packages/atlas/src/components/_crt/RevenueShareStateWidget/RevenueShareStateWidget.tsx @@ -6,9 +6,14 @@ import { formatDateTime, formatDurationShort } from '@/utils/time' export const RevenueShareStateWidget = ({ endsAtBlock }: { endsAtBlock?: number }) => { const { convertBlockToMsTimestamp } = useBlockTimeEstimation() - const status: 'active' | 'past' | 'inactive' = !endsAtBlock ? 'inactive' : endsAtBlock < 0 ? 'past' : 'active' const endingBlockTimestamp = convertBlockToMsTimestamp(endsAtBlock ?? 0) - const endingDate = endingBlockTimestamp ? new Date(endingBlockTimestamp) : new Date() + const endingDate = endingBlockTimestamp ? new Date(endingBlockTimestamp) : null + const status: 'active' | 'past' | 'inactive' = !endingBlockTimestamp + ? 'inactive' + : endingBlockTimestamp < Date.now() + ? 'past' + : 'active' + return ( - {formatDateTime(endingDate).replace(',', ' at')} + {endingDate ? formatDateTime(endingDate).replace(',', ' at') : 'N/A'} ) : ( - {formatDurationShort(Math.round((endingDate.getTime() - Date.now()) / 1000))} + {endingDate ? formatDurationShort(Math.round((endingDate.getTime() - Date.now()) / 1000)) : 'N/A'} - {formatDateTime(endingDate).replace(',', ' at')} + {endingDate ? formatDateTime(endingDate).replace(',', ' at') : 'N/A'} ) diff --git a/packages/atlas/src/components/_crt/StartRevenueShareModal/StartRevenueShareModal.tsx b/packages/atlas/src/components/_crt/StartRevenueShareModal/StartRevenueShareModal.tsx index e4fdd58b60..2170c1231f 100644 --- a/packages/atlas/src/components/_crt/StartRevenueShareModal/StartRevenueShareModal.tsx +++ b/packages/atlas/src/components/_crt/StartRevenueShareModal/StartRevenueShareModal.tsx @@ -80,10 +80,11 @@ export const StartRevenueShare = ({ tokenId, onClose, show }: StartRevenueShareP data.endDate?.type === 'date' ? convertMsTimestampToBlock(data.endDate.date.getTime()) : data.endDate?.durationDays - ? convertMsTimestampToBlock(addDaysToDate(data.endDate.durationDays, rawStartDate).getTime()) + ? (convertMsTimestampToBlock(addDaysToDate(data.endDate.durationDays, rawStartDate).getTime()) ?? 0) - + startBlock : null - if (typeof duration !== 'number') { + if (typeof duration !== 'number' || duration < 0) { displaySnackbar({ title: 'Failed to parse ending date', iconType: 'error', description: 'Please try again.' }) return }