index.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2017-2019 @polkadot/app-address-book 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 { AppProps, I18nProps } from '@polkadot/react-components/types';
  5. import { SubjectInfo } from '@polkadot/ui-keyring/observable/types';
  6. import { ComponentProps } from './types';
  7. import React from 'react';
  8. import { Route, Switch } from 'react-router';
  9. import { Link } from 'react-router-dom';
  10. import styled from 'styled-components';
  11. import { Breadcrumb } from 'semantic-ui-react';
  12. import { HelpOverlay } from '@polkadot/react-components';
  13. import basicMd from './md/basic.md';
  14. import Overview from './Overview';
  15. import translate from './translate';
  16. import MemoByAccount from './MemoByAccount';
  17. interface Props extends AppProps, I18nProps {
  18. allAddresses?: SubjectInfo;
  19. location: any;
  20. }
  21. const StyledHeader = styled.header`
  22. text-align: left;
  23. .ui.breadcrumb {
  24. padding: 1.4rem 0 0 .4rem;
  25. font-size: 1.4rem;
  26. }
  27. `;
  28. function AddressBookApp ({ basePath, onStatusChange }: Props): React.ReactElement<Props> {
  29. const _renderComponent = (Component: React.ComponentType<ComponentProps>): () => React.ReactNode => {
  30. // eslint-disable-next-line react/display-name
  31. return (): React.ReactNode =>
  32. <Component
  33. basePath={basePath}
  34. location={location}
  35. onStatusChange={onStatusChange}
  36. />;
  37. };
  38. const viewMemoPath = `${basePath}/memo/:accountId?`;
  39. return (
  40. <main className='address-book--App'>
  41. <HelpOverlay md={basicMd} />
  42. <StyledHeader>
  43. <Breadcrumb>
  44. <Switch>
  45. <Route path={viewMemoPath}>
  46. <Breadcrumb.Section link as={Link} to={basePath}>Contacts</Breadcrumb.Section>
  47. <Breadcrumb.Divider icon="right angle" />
  48. <Breadcrumb.Section active>View memo</Breadcrumb.Section>
  49. </Route>
  50. <Route>
  51. <Breadcrumb.Section active>Contacts</Breadcrumb.Section>
  52. </Route>
  53. </Switch>
  54. </Breadcrumb>
  55. </StyledHeader>
  56. <Switch>
  57. <Route path={viewMemoPath} component={MemoByAccount} />
  58. <Route render={_renderComponent(Overview)} />
  59. </Switch>
  60. </main>
  61. );
  62. }
  63. export default translate(AddressBookApp);