diff --git a/src/v2/components/Accounts/Table/index.jsx b/src/v2/components/Accounts/Table/index.jsx index f57b7357..f09bf159 100644 --- a/src/v2/components/Accounts/Table/index.jsx +++ b/src/v2/components/Accounts/Table/index.jsx @@ -11,8 +11,8 @@ import {map} from 'lodash/fp'; import TypeLabel from 'v2/components/UI/TypeLabel'; import Table from 'v2/components/UI/Table'; import type {TableHeadProps} from 'v2/@types/table'; -import formatDistanceToNow from 'date-fns/formatDistanceToNow'; import TableCard from 'v2/components/UI/TableCard'; +import asTime from 'v2/utils/asTime'; import useStyles from './styles'; @@ -48,10 +48,6 @@ const AccountsTable = ({ const theme = useTheme(); const showTable = useMediaQuery(theme.breakpoints.up('md')); - const asTime = x => { - return formatDistanceToNow(Date.parse(x), {addSuffix: true}); - }; - const renderRow = ({data: account}) => { return ( diff --git a/src/v2/components/Blocks/Detail/index.jsx b/src/v2/components/Blocks/Detail/index.jsx index 7ad02b3e..74ad2e26 100644 --- a/src/v2/components/Blocks/Detail/index.jsx +++ b/src/v2/components/Blocks/Detail/index.jsx @@ -4,7 +4,6 @@ import {observer} from 'mobx-react-lite'; import React, {useEffect} from 'react'; import {map} from 'lodash/fp'; import {Match} from 'react-router-dom'; -import formatDistanceToNow from 'date-fns/formatDistanceToNow'; import SectionHeader from 'v2/components/UI/SectionHeader'; import Mixpanel from 'v2/mixpanel'; import CopyBtn from 'v2/components/UI/CopyBtn'; @@ -13,6 +12,7 @@ import Loader from 'v2/components/UI/Loader'; import BlockDetailStore from 'v2/stores/blocks/detail'; import ValidatorName from 'v2/components/UI/ValidatorName'; import InfoRow from 'v2/components/InfoRow'; +import asTime from 'v2/utils/asTime'; import useStyles from './styles'; @@ -34,15 +34,11 @@ const BlockDetail = ({match}: {match: Match}) => { return ; } - const asTime = x => { - return formatDistanceToNow(Date.parse(x), {addSuffix: true}); - }; - const specs = [ { label: 'Time', hint: block.timestamp, - value: block.timestamp && asTime(block.timestamp), + value: asTime(block.timestamp), }, { label: 'Fee', diff --git a/src/v2/components/Blocks/Table/index.jsx b/src/v2/components/Blocks/Table/index.jsx index c507379c..14f0303b 100644 --- a/src/v2/components/Blocks/Table/index.jsx +++ b/src/v2/components/Blocks/Table/index.jsx @@ -3,7 +3,6 @@ import React from 'react'; import {TableCell, TableRow} from '@material-ui/core'; import cn from 'classnames'; -import formatDistanceToNow from 'date-fns/formatDistanceToNow'; import useMediaQuery from '@material-ui/core/useMediaQuery'; import {useTheme} from '@material-ui/core/styles'; import {observer} from 'mobx-react-lite'; @@ -13,6 +12,7 @@ import Table from 'v2/components/UI/Table'; import type {TableHeadProps} from 'v2/@types/table'; import ValidatorName from 'v2/components/UI/ValidatorName'; import TableCard from 'v2/components/UI/TableCard'; +import asTime from 'v2/utils/asTime'; import useStyles from './styles'; @@ -66,10 +66,6 @@ const BlocksTable = ({ const theme = useTheme(); const showTable = useMediaQuery(theme.breakpoints.up('md')); - const asTime = x => { - return formatDistanceToNow(Date.parse(x), {addSuffix: true}); - }; - const renderRow = ({data: block}) => { return ( diff --git a/src/v2/components/Favorites/index.jsx b/src/v2/components/Favorites/index.jsx index aad3ad1f..6db25e1f 100644 --- a/src/v2/components/Favorites/index.jsx +++ b/src/v2/components/Favorites/index.jsx @@ -19,10 +19,10 @@ import Table from 'v2/components/UI/Table'; import TypeLabel from 'v2/components/UI/TypeLabel'; import {ReactComponent as WarnIcon} from 'v2/assets/icons/warn.svg'; import FavoritesStore from 'v2/stores/favorites'; +import asTime from 'v2/utils/asTime'; +import {Link} from 'react-router-dom'; import useStyles from './styles'; -import {Link} from 'react-router-dom'; -import formatDistanceToNow from 'date-fns/formatDistanceToNow'; const fields: TableHeadProps[] = [ { @@ -77,10 +77,6 @@ const FavoritesPage = () => { removeFavorites(id, tab); }; - const asTime = x => { - return formatDistanceToNow(Date.parse(x), {addSuffix: true}); - }; - const renderRow = ({data: row}) => { const {id, type, timestamp} = row; @@ -95,7 +91,7 @@ const FavoritesPage = () => { - {(timestamp && asTime(timestamp)) || 'Unknown'} + {asTime(timestamp) || 'Unknown'}