Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { Card, CardBody, CardHeader, Col, Row, Table } from 'reactstrap';
  3. import axios from 'axios';
  4.  
  5. const url = 'http://localhost:8099/';
  6.  
  7. class Certificate extends Component {
  8. constructor(props) {
  9. super(props);
  10. this.state = {
  11. certificate: {}
  12. };
  13. }
  14.  
  15. componentDidMount()
  16. {
  17. const {id} = this.props.match.params;
  18. axios({
  19. method: 'get',
  20. url: url + 'certificates/'+id,
  21. }).then((response)=>{
  22. console.log(response);
  23. this.setState({certificate:response.data})
  24. },(error)=>{
  25. console.log(error);
  26. });
  27. }
  28.  
  29. render() {
  30.  
  31. const certDetails = this.state.certificate ? Object.entries(this.state.certificate) : [['id', (<span><i className="text-muted icon-ban"></i> Not found</span>)]]
  32.  
  33. return (
  34. <div className="animated fadeIn">
  35. <Row>
  36. <Col lg={8} xs = {12}>
  37. <Card>
  38. <CardHeader>
  39. <strong><i className="icon-info pr-1"></i>Certificate id: {this.props.match.params.id}</strong>
  40. </CardHeader>
  41. <CardBody>
  42. <Table responsive striped hover>
  43. <tbody>
  44. {
  45. certDetails.map(([key, value]) => {
  46. return (
  47. <tr key={key}>
  48. <td>{`${key}:`}</td>
  49. <td><strong>{value}</strong></td>
  50. </tr>
  51. )
  52. })
  53. }
  54. </tbody>
  55. </Table>
  56. </CardBody>
  57. </Card>
  58. </Col>
  59. </Row>
  60. </div>
  61. )
  62. }
  63. }
  64.  
  65. export default Certificate;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement