index.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2017-2020 @polkadot/app-staking 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 { ComponentProps as Props } from '../types';
  5. import React from 'react';
  6. import { Button, CardGrid } from '@polkadot/react-components';
  7. import contracts from '../store';
  8. import { useTranslation } from '../translate';
  9. import Code from './Code';
  10. import Upload from './Upload';
  11. import Add from './Add';
  12. function Codes ({ onShowDeploy }: Props): React.ReactElement<Props> {
  13. const { t } = useTranslation();
  14. return (
  15. <>
  16. <CardGrid
  17. buttons={
  18. <Button.Group isCentered>
  19. <Upload />
  20. <Add />
  21. </Button.Group>
  22. }
  23. emptyText={t('No code hashes available')}
  24. >
  25. {contracts.getAllCode().map((code): React.ReactNode => {
  26. return (
  27. <Code
  28. code={code}
  29. key={code.json.codeHash}
  30. onShowDeploy={onShowDeploy}
  31. />
  32. );
  33. })}
  34. </CardGrid>
  35. </>
  36. );
  37. }
  38. export default React.memo(Codes);