Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Link } from 'react-router-dom';
  3. import { Card, CardBody, CardHeader, Col, Row, Table,Pagination, PaginationItem, PaginationLink } from 'reactstrap';
  4.  
  5. import axios from 'axios';
  6.  
  7. const url = 'http://localhost:8099/';
  8.  
  9.  
  10. function CertRow(props) {
  11. const certificate = props.certificate;
  12. const certLink = `/certificate/${certificate.serialNumbeSubejctr}`;
  13. const issLink = `/certificate/${certificate.serialNumberIssuerr}`;
  14. return (
  15. <tr key={certificate.id.toString()}>
  16. <th scope="row"><Link to={certLink}>{certificate.id}</Link></th>
  17. <td><Link to={certLink}>{certificate.serialNumbeSubejctr}</Link></td>
  18. <td><Link to={issLink}>{certificate.serialNumberIssuerr}</Link></td>
  19. <td>{certificate.startDate}</td>
  20. <td>{certificate.endDate}</td>
  21. <td>{certificate.name}</td>
  22. <td>{certificate.surname}</td>
  23. </tr>
  24. )
  25. }
  26.  
  27. class Certificates extends Component {
  28. constructor(props) {
  29. super(props);
  30. this.state = {
  31. certificates: []
  32. };
  33. }
  34.  
  35. componentDidMount()
  36. {
  37. axios({
  38. method: 'get',
  39. url: url + 'certificates/getAllCertificates',
  40. }).then((response)=>{
  41. console.log(response);
  42. this.setState({certificates:response.data})
  43. },(error)=>{
  44. console.log(error);
  45. });
  46. }
  47.  
  48. render() {
  49.  
  50. const len = this.state.certificates.length;
  51.  
  52. return (
  53. <div className="animated fadeIn">
  54. <Row>
  55. <Col xl={10}>
  56. <Card>
  57. <CardHeader>
  58. <i className="fa fa-align-justify"></i> Certificates
  59. </CardHeader>
  60. <CardBody>
  61. <Table responsive hover striped>
  62. <thead>
  63. <tr>
  64. <th scope="col">Id</th>
  65. <th scope="col">Serial number</th>
  66. <th scope="col">Issuer serial number</th>
  67. <th scope="col">Start date</th>
  68. <th scope="col">End date</th>
  69. <th scope="col">Name</th>
  70. <th scope="col">Surname</th>
  71. </tr>
  72. </thead>
  73. <tbody>
  74. {this.state.certificates.map((certificate, index) =>
  75. <CertRow key={index} certificate={certificate}/>
  76. )}
  77. </tbody>
  78. </Table>
  79. <nav>
  80. <Pagination>
  81. <PaginationItem><PaginationLink previous tag="button"></PaginationLink></PaginationItem>
  82. <PaginationItem active>
  83. <PaginationLink tag="button">1</PaginationLink>
  84. </PaginationItem>
  85. <PaginationItem><PaginationLink tag="button">2</PaginationLink></PaginationItem>
  86. <PaginationItem><PaginationLink tag="button">3</PaginationLink></PaginationItem>
  87. <PaginationItem><PaginationLink tag="button">4</PaginationLink></PaginationItem>
  88. <PaginationItem><PaginationLink next tag="button"></PaginationLink></PaginationItem>
  89. </Pagination>
  90. </nav>
  91. </CardBody>
  92. </Card>
  93. </Col>
  94. </Row>
  95. </div>
  96. )
  97. }
  98. }
  99.  
  100. export default Certificates;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement