feat: remove the last update component (#179)
This commit is contained in:
@@ -1,23 +0,0 @@
|
|||||||
import { ReactElement, useEffect, useState } from 'react'
|
|
||||||
|
|
||||||
interface Props {
|
|
||||||
date: number | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function LastUpdate({ date }: Props): ReactElement {
|
|
||||||
const [duration, setDuration] = useState<string>('never')
|
|
||||||
|
|
||||||
const refresh = () => {
|
|
||||||
if (!date) setDuration('never')
|
|
||||||
else setDuration(`${((Date.now() - date) / 1000).toFixed()} seconds ago`)
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
refresh()
|
|
||||||
const i = setInterval(refresh, 1000)
|
|
||||||
|
|
||||||
return () => clearInterval(i)
|
|
||||||
}, [date])
|
|
||||||
|
|
||||||
return <span>Last Update: {duration}</span>
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,6 @@ import { Activity, FileText, DollarSign, Share2, Settings, Layers } from 'react-
|
|||||||
import SwarmLogoOrange from '../assets/swarm-logo-orange.svg'
|
import SwarmLogoOrange from '../assets/swarm-logo-orange.svg'
|
||||||
import { Health } from '@ethersphere/bee-js'
|
import { Health } from '@ethersphere/bee-js'
|
||||||
|
|
||||||
import LastUpdate from './LastUpdate'
|
|
||||||
|
|
||||||
const drawerWidth = 240
|
const drawerWidth = 240
|
||||||
|
|
||||||
const navBarItems = [
|
const navBarItems = [
|
||||||
@@ -87,7 +85,6 @@ interface Props extends RouteComponentProps {
|
|||||||
themeMode: string
|
themeMode: string
|
||||||
health: boolean
|
health: boolean
|
||||||
nodeHealth: Health | null
|
nodeHealth: Health | null
|
||||||
lastUpdate: number | null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SideBar(props: Props): ReactElement {
|
export default function SideBar(props: Props): ReactElement {
|
||||||
@@ -170,9 +167,6 @@ export default function SideBar(props: Props): ReactElement {
|
|||||||
<span>Debug API</span>
|
<span>Debug API</span>
|
||||||
</div>
|
</div>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<div style={{ width: '100%', textAlign: 'center' }}>
|
|
||||||
<LastUpdate date={props.lastUpdate} />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ const Dashboard = (props: Props): ReactElement => {
|
|||||||
|
|
||||||
const [themeMode, toggleThemeMode] = useState('light')
|
const [themeMode, toggleThemeMode] = useState('light')
|
||||||
|
|
||||||
// FIXME: handle errrors and loading
|
const { isLoading, apiHealth, debugApiHealth } = useContext(Context)
|
||||||
const { isLoading, lastUpdate, apiHealth, debugApiHealth } = useContext(Context)
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const theme = localStorage.getItem('theme')
|
const theme = localStorage.getItem('theme')
|
||||||
@@ -57,13 +56,7 @@ const Dashboard = (props: Props): ReactElement => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<SideBar
|
<SideBar {...props} themeMode={themeMode} health={apiHealth} nodeHealth={debugApiHealth} />
|
||||||
{...props}
|
|
||||||
themeMode={themeMode}
|
|
||||||
health={apiHealth}
|
|
||||||
nodeHealth={debugApiHealth}
|
|
||||||
lastUpdate={lastUpdate}
|
|
||||||
/>
|
|
||||||
<NavBar themeMode={themeMode} />
|
<NavBar themeMode={themeMode} />
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<main className={classes.content}>
|
<main className={classes.content}>
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import { Container, CircularProgress } from '@material-ui/core'
|
|||||||
import StampsTable from './StampsTable'
|
import StampsTable from './StampsTable'
|
||||||
import TroubleshootConnectionCard from '../../components/TroubleshootConnectionCard'
|
import TroubleshootConnectionCard from '../../components/TroubleshootConnectionCard'
|
||||||
import CreatePostageStampModal from './CreatePostageStampModal'
|
import CreatePostageStampModal from './CreatePostageStampModal'
|
||||||
import LastUpdate from '../../components/LastUpdate'
|
|
||||||
|
|
||||||
import { Context } from '../../providers/Stamps'
|
import { Context } from '../../providers/Stamps'
|
||||||
import { Context as BeeContext } from '../../providers/Bee'
|
import { Context as BeeContext } from '../../providers/Bee'
|
||||||
@@ -33,7 +32,7 @@ export default function Accounting(): ReactElement {
|
|||||||
const classes = useStyles()
|
const classes = useStyles()
|
||||||
|
|
||||||
const beeContext = useContext(BeeContext)
|
const beeContext = useContext(BeeContext)
|
||||||
const { stamps, isLoading, error, lastUpdate, start, stop } = useContext(Context)
|
const { stamps, isLoading, error, start, stop } = useContext(Context)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
start()
|
start()
|
||||||
|
|
||||||
@@ -61,7 +60,6 @@ export default function Accounting(): ReactElement {
|
|||||||
<>
|
<>
|
||||||
<div className={classes.actions}>
|
<div className={classes.actions}>
|
||||||
<CreatePostageStampModal />
|
<CreatePostageStampModal />
|
||||||
<LastUpdate date={lastUpdate} />
|
|
||||||
<div style={{ height: '5px' }}>{isLoading && <CircularProgress />}</div>
|
<div style={{ height: '5px' }}>{isLoading && <CircularProgress />}</div>
|
||||||
</div>
|
</div>
|
||||||
<StampsTable postageStamps={stamps} />
|
<StampsTable postageStamps={stamps} />
|
||||||
|
|||||||
Reference in New Issue
Block a user