Guest User

Untitled

a guest
Mar 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Button, Page, Table } from 'proa-react';
  3. import PropTypes from 'prop-types';
  4. import 'proa/dist/css/proa.min.css';
  5. import { Link } from 'react-router';
  6.  
  7. class ConfigIndexPage extends Component {
  8. constructor(props) {
  9. super(props);
  10.  
  11. this.contentRender = this.contentRender.bind(this);
  12. }
  13.  
  14. componentDidMount() {
  15. this.props.fetchData();
  16. console.log(this.props);
  17. }
  18.  
  19. contentRender() {
  20. if (this.props.error.status !== 0) {
  21. return (
  22. <div>
  23. <p>Erro: {this.props.error.error} </p>
  24. <p>Status: {this.props.error.status} </p>
  25. </div>
  26. );
  27. } else if (this.props.filas.length === 0) {
  28. return (
  29. <div>
  30. <p>Nenhuma fila cadastrada!</p>
  31. </div>
  32. );
  33. }
  34.  
  35. const content = this.props.filas.map(fila => (
  36. <Table.Row>
  37. <Table.Cell>{fila.queueName}</Table.Cell>
  38. <Table.Cell>{fila.squadName}</Table.Cell>
  39. <Table.Cell>{fila.email}</Table.Cell>
  40. <Table.Cell />
  41. </Table.Row>
  42. ));
  43.  
  44. return (
  45. <Table>
  46. <Table.Head>
  47. <Table.Row>
  48. <Table.HeadCell>Nome da fila</Table.HeadCell>
  49. <Table.HeadCell>Squad</Table.HeadCell>
  50. <Table.HeadCell>Email de Contato</Table.HeadCell>
  51. <Table.HeadCell>Ações</Table.HeadCell>
  52. </Table.Row>
  53. </Table.Head>
  54. <Table.Body>
  55. {content}
  56. </Table.Body>
  57. </Table>
  58. );
  59. }
  60.  
  61. render() {
  62. const content = this.contentRender();
  63. return (
  64. <Page>
  65. <Page.Header title="Filas">
  66. <Link to="/home">
  67. <Button>Nova fila</Button>
  68. </Link>
  69. </Page.Header>
  70. <Page.Section>
  71. {content}
  72. </Page.Section>
  73. </Page>
  74. );
  75. }
  76. }
  77.  
  78. ConfigIndexPage.propTypes = {
  79. filas: PropTypes.arrayOf(PropTypes.shape({
  80. id: PropTypes.number,
  81. description: PropTypes.string,
  82. email: PropTypes.string,
  83. max_pool_size_by_type: PropTypes.number,
  84. min_poll_size_by_type: PropTypes.number,
  85. minutes_requeue: PropTypes.number,
  86. queue_name: PropTypes.string,
  87. squad_name: PropTypes.string,
  88. status: PropTypes.string,
  89. type: PropTypes.string,
  90. warning_email: PropTypes.string,
  91. })),
  92. error: PropTypes.shape({
  93. error: PropTypes.string,
  94. message: PropTypes.string,
  95. path: PropTypes.string,
  96. status: PropTypes.number,
  97. timestamp: PropTypes.number,
  98. }),
  99. fetchData: PropTypes.func.isRequired,
  100. };
  101.  
  102. ConfigIndexPage.defaultProps = {
  103. filas: [
  104. {
  105. id: 0,
  106. description: '',
  107. email: '',
  108. max_pool_size_by_type: 0,
  109. min_poll_size_by_type: 0,
  110. minutes_requeue: 0,
  111. queue_name: '',
  112. squad_name: '',
  113. status: '',
  114. type: '',
  115. warning_email: '',
  116. },
  117. ],
  118. error: {
  119. error: '',
  120. message: '',
  121. path: '',
  122. status: 0,
  123. timestamp: 0,
  124. },
  125. };
  126.  
  127. export default ConfigIndexPage;
Add Comment
Please, Sign In to add comment