Advertisement
vandasche

Untitled

Apr 29th, 2020
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.21 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import { connect } from 'react-redux';
  3. import * as actConsult from '../_actions/consult';
  4. import Moment from 'react-moment';
  5.  
  6. class reservation_data extends Component {
  7. componentDidMount() {
  8. const id = this.props.consul.id;
  9. const data = JSON.parse(localStorage.getItem('credentials'));
  10. this.props.dispatch(actConsult.getConsult(data.token));
  11. this.props.dispatch(actConsult.getReply(data.token, id));
  12. }
  13.  
  14. render() {
  15. const { data: consul, loading, error } = this.props.consul;
  16. if (error) return <>error</>;
  17. if (loading) return <>Loading</>;
  18.  
  19. return (
  20. <>
  21. {consul &&
  22. consul.length > 0 &&
  23. consul.map((data, index) => (
  24. <div className='card p-3 mb-3'>
  25. <div className='d-flex align-items-top mb-3'>
  26. <div className='mr-3'>
  27. <img
  28. src={process.env.PUBLIC_URL + `../logos/login.png`}
  29. alt=''
  30. className='avatar'
  31. style={{ height: 60, width: 60, borderRadius: 45 }}
  32. />
  33. </div>
  34.  
  35. <div className='d-flex w-100 justify-content-between align-content-top'>
  36. <div>
  37. <h5 className='mb-0'>{data.subject}</h5>
  38. <small>
  39. <Moment format='DD,MMM YYYY'>{data.createdAt}</Moment>
  40. </small>
  41. <br />
  42. <small>{data.description}</small>
  43. </div>
  44. <div>
  45. <small className='bold'>
  46. <Moment format='DD,MMM YYYY'>{data.createdAt}</Moment>
  47. </small>
  48. </div>
  49. </div>
  50. </div>
  51. <div className='border-top'>
  52. <div className='text-center mt-3'>
  53. <h5>waiting reply</h5>
  54. </div>
  55. </div>
  56. </div>
  57. ))}
  58. </>
  59. );
  60. }
  61. }
  62.  
  63. const mapStateToProps = (state) => {
  64. return {
  65. consul: state.consultation,
  66. };
  67. };
  68.  
  69. export default connect(mapStateToProps)(reservation_data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement