Summary.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2017-2020 @polkadot/app-explorer authors & contributors
  2. // This software may be modified and distributed under the terms
  3. // of the Apache-2.0 license. See the LICENSE file for details.
  4. import React from 'react';
  5. import { useApi } from '@polkadot/react-hooks';
  6. import { SummaryBox, CardSummary } from '@polkadot/react-components';
  7. import { BestFinalized, BestNumber, BlockToTime, TimeNow, TotalIssuance } from '@polkadot/react-query';
  8. import { BN_ONE } from '@polkadot/util';
  9. import SummarySession from './SummarySession';
  10. import { useTranslation } from './translate';
  11. function Summary (): React.ReactElement {
  12. const { t } = useTranslation();
  13. const { api } = useApi();
  14. return (
  15. <SummaryBox>
  16. <section>
  17. <CardSummary label={t<string>('last block')}>
  18. <TimeNow />
  19. </CardSummary>
  20. <CardSummary
  21. className='ui--media-small'
  22. label={t<string>('target')}
  23. >
  24. <BlockToTime blocks={BN_ONE} />
  25. </CardSummary>
  26. {api.query.balances && (
  27. <CardSummary
  28. className='ui--media-small'
  29. label={t<string>('total issuance')}
  30. >
  31. <TotalIssuance />
  32. </CardSummary>
  33. )}
  34. </section>
  35. <section className='ui--media-large'>
  36. <SummarySession withEra={false} />
  37. </section>
  38. <section>
  39. {api.query.grandpa && (
  40. <CardSummary label={t<string>('finalized')}>
  41. <BestFinalized />
  42. </CardSummary>
  43. )}
  44. <CardSummary label={t<string>('best')}>
  45. <BestNumber />
  46. </CardSummary>
  47. </section>
  48. </SummaryBox>
  49. );
  50. }
  51. export default React.memo(Summary);