import { BZZ, DAI, RedistributionState } from '@ethersphere/bee-js' import { useContext, useEffect, useState } from 'react' import { Context } from '../providers/Settings' import ExpandableListItem from './ExpandableListItem' export function Redistribution() { const { beeApi } = useContext(Context) const [redistributionState, setRedistributionState] = useState(null) useEffect(() => { const interval = setInterval(() => { if (!beeApi) { return } beeApi.getRedistributionState().then(setRedistributionState).catch(console.error) // eslint-disable-line }, 3_000) return () => clearInterval(interval) }) const formatDurationSeconds = (s?: number) => { if (s === null || s === undefined) { return '-' } else { return `${s} s` } } const formatBzzAmount = (amount?: BZZ) => { if (amount === null || amount === undefined) { return '-' } else { return `${amount.toSignificantDigits(4)} xBZZ` } } const formatDaiAmount = (amount?: DAI) => { if (amount === null || amount === undefined) { return '-' } else { return `${amount.toSignificantDigits(4)} xDAI` } } return ( <> ) }