Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Depracating warning #97

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/components/OverviewSingleAssetTab.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react'
import { Link as RouterLink, useParams } from 'react-router-dom'
import moment from 'moment'

import { Box, Link, Table, TableBody, TableContainer, TableRow, Tooltip, Typography } from '@mui/material'

Expand All @@ -13,6 +12,7 @@ import { useDataSetAssetsContext } from '../hooks/useDatachainOutput'

import { getVerificationComponent } from './Verifications'
import Issuer from './Issuer'
import { formatTimeLeft } from '../utils/timestapFormater'

const OverviewSingleAssetTab = () => {
const { assetContract, assetTokenId, assetSerial, id } = useParams()
Expand Down Expand Up @@ -73,9 +73,7 @@ const OverviewSingleAssetTab = () => {
<TableRow sx={{ backgroundColor: 'grey.50' }}>
<TableNameCell>Last verified</TableNameCell>
<TableValueCell>
{!isLoading && lastVerified
? moment(moment.unix(lastVerified).utc().format('DD MMM YYYY HH:mm:ss [UTC]')).fromNow()
: 'loading...'}
{!isLoading && lastVerified ? formatTimeLeft(lastVerified) : 'loading...'}
</TableValueCell>
</TableRow>

Expand Down
3 changes: 2 additions & 1 deletion src/components/VerificationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useDataSetAssetsContext } from '../hooks/useDatachainOutput'
import Pagination from './Pagination'

import Gray from '../assets/images/Collection-gray.png'
import { formatTimeLeft } from '../utils/timestapFormater'

const PageSize = 5

Expand Down Expand Up @@ -94,7 +95,7 @@ const VerificationList = () => {
const publisher = asset?.metadata?.publisher
const datasetContract = asset?.metadata?.contract
const datasetAssetClass = asset?.metadata?.['asset-class']
const date = moment(moment.unix(lastVerified).utc().format('DD MMM YYYY HH:mm:ss [UTC]')).fromNow()
const date = formatTimeLeft(lastVerified)
const image = asset.metadata.image === '' ? Gray : asset.metadata.image
return (
<TableBodyRow
Expand Down
2 changes: 1 addition & 1 deletion src/utils/timestapFormater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const formatDate = (timestamp: number, formatType: string = format) =>
moment.unix(timestamp).utc().format(formatType)

export const formatTimeLeft = (timestamp: number, formatType: string = format) =>
moment(moment.unix(timestamp).utc().format(formatType)).fromNow()
moment(moment.unix(timestamp).toISOString()).fromNow()

export const formatTimeStamp = (timestamp: number) => {
const from = moment.unix(timestamp).utc().format(format)
Expand Down
6 changes: 2 additions & 4 deletions src/views/Dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import VerifiedFiles from './VerifiedFiles'

import { useDataSetAssetsContext, StatusType } from '../hooks/useDatachainOutput'
import { customTheme } from '../theme'
import { formatTimeLeft } from '../utils/timestapFormater'

const ContentContainer = styled(Container)(({ theme }) => ({
[theme.breakpoints.up('xl')]: {
Expand Down Expand Up @@ -258,10 +259,7 @@ const Dataset = () => {
ml={1.25}
sx={{ fontSize: '14px', fontStyle: 'italic', color: 'grey.400' }}
>
Last verified{' '}
{isLoading || !lastVerified
? 'loading...'
: moment(moment.unix(lastVerified).utc().format('DD MMM YYYY HH:mm:ss [UTC]')).fromNow()}
Last verified {isLoading || !lastVerified ? 'loading...' : formatTimeLeft(lastVerified)}
</Typography>
</Box>
</Box>
Expand Down