4f9abc614e
* style: UI changes for postage stamp * feat: New postage stamp standard page --------- Co-authored-by: Seres Roland <seresroland@Seres-MBP.home>
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import { CircularProgress, createStyles, makeStyles } from '@material-ui/core'
|
|
import { ReactElement, useContext, useEffect } from 'react'
|
|
import { useNavigate } from 'react-router'
|
|
import PlusSquare from 'remixicon-react/AddBoxLineIcon'
|
|
import { Loading } from '../../../components/Loading'
|
|
import { SwarmButton } from '../../../components/SwarmButton'
|
|
import TroubleshootConnectionCard from '../../../components/TroubleshootConnectionCard'
|
|
import { Context as BeeContext, CheckState } from '../../../providers/Bee'
|
|
import { Context as StampsContext } from '../../../providers/Stamps'
|
|
import { ROUTES } from '../../../routes'
|
|
import StampsTable from '../../stamps/StampsTable'
|
|
import { AccountNavigation } from '../AccountNavigation'
|
|
import { Header } from '../Header'
|
|
|
|
const useStyles = makeStyles(() =>
|
|
createStyles({
|
|
root: {
|
|
width: '100%',
|
|
display: 'grid',
|
|
},
|
|
actions: {
|
|
display: 'flex',
|
|
width: '100%',
|
|
flex: '0 1 auto',
|
|
flexWrap: 'wrap',
|
|
alignItems: 'center',
|
|
},
|
|
}),
|
|
)
|
|
|
|
export function AccountStamps(): ReactElement {
|
|
const classes = useStyles()
|
|
|
|
const navigate = useNavigate()
|
|
|
|
const { stamps, isLoading, error, start, stop } = useContext(StampsContext)
|
|
const { status } = useContext(BeeContext)
|
|
|
|
useEffect(() => {
|
|
if (!status.all) return
|
|
start()
|
|
|
|
return () => stop()
|
|
}, [status]) // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
if (status.all === CheckState.ERROR) return <TroubleshootConnectionCard />
|
|
|
|
function navigateToNewStamp() {
|
|
navigate(ROUTES.ACCOUNT_STAMPS_NEW_STANDARD)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<Header />
|
|
<AccountNavigation active="STAMPS" />
|
|
<div className={classes.root}>
|
|
{error && <Loading />}
|
|
{!error && (
|
|
<>
|
|
<div className={classes.actions}>
|
|
<SwarmButton onClick={navigateToNewStamp} iconType={PlusSquare}>
|
|
Buy New Postage Stamp
|
|
</SwarmButton>
|
|
<div style={{ height: '5px' }}>{isLoading && <CircularProgress />}</div>
|
|
</div>
|
|
<StampsTable postageStamps={stamps} />
|
|
</>
|
|
)}
|
|
</div>
|
|
</>
|
|
)
|
|
}
|