Advertisement
vandasche

Untitled

Apr 28th, 2020
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.14 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import '../style/transaction_item.css';
  3. import axios from 'axios';
  4. import Moment from 'react-moment';
  5. import { Container, Row, Col, Modal, Button, Form } from 'react-bootstrap';
  6.  
  7. export default class consult_item extends Component {
  8. state = {
  9. modal: false,
  10. reply: '',
  11. };
  12.  
  13. showModal = () => {
  14. this.setState({ modal: true });
  15. };
  16.  
  17. closeModal = () => {
  18. this.setState({ modal: false });
  19. };
  20.  
  21. handleChangeTxt = (e) => {
  22. this.setState({ [e.target.name]: e.target.value });
  23. };
  24.  
  25. handleReply = async () => {
  26. try {
  27. const data = JSON.parse(localStorage.getItem('credentials'));
  28. const token = data.token;
  29. const id = this.props.item.id;
  30. const user = await axios({
  31. method: 'POST',
  32. data: this.state.reply,
  33. headers: {
  34. 'content-type': 'application/json',
  35. authorization: `Bearer ${token}`,
  36. },
  37. url: `http://localhost:5000/api/v1/consultation/${id}/reply`,
  38. });
  39. console.log(user);
  40. } catch (error) {
  41. console.log(error);
  42. }
  43. };
  44.  
  45. render() {
  46. const data = this.props.item;
  47. return (
  48. <div>
  49. <Container fluid className='transaction-item-area'>
  50. <Row>
  51. <Col xs={2} className='transaction-item-text'>
  52. {data.id}
  53. </Col>
  54. <Col xs={2} className='transaction-item-text'>
  55. <div style={{ textTransform: 'capitalize' }}>{data.fullName}</div>
  56. </Col>
  57. <Col xs={2} className='transaction-item-text'>
  58. <div style={{ textTransform: 'capitalize' }}>{data.subject}</div>
  59. </Col>
  60. <Col xs={2} className='transaction-item-text'>
  61. <Moment format='YYYY-MM-DD'>{data.createdAt}</Moment>
  62. </Col>
  63. {data.status === 'Waiting Approve Consultation Live' && (
  64. <Col xs={2} className='transaction-item-text color-orange'>
  65. {data.status}
  66. </Col>
  67. )}
  68. {data.status === 'Waiting Live Consultation' && (
  69. <Col xs={2} className='transaction-item-text color-green'>
  70. {data.status}
  71. </Col>
  72. )}
  73. {data.status === 'Cancel' && (
  74. <Col xs={2} className='transaction-item-text color-red'>
  75. {data.status}
  76. </Col>
  77. )}
  78. <Col xs={2} className='transaction-item-text'>
  79. <img
  80. src={process.env.PUBLIC_URL + `../pic/search.png`}
  81. alt=''
  82. onClick={this.showModal}
  83. ></img>
  84. </Col>
  85. </Row>
  86. <p className='transaction-item-line' />
  87. </Container>
  88.  
  89. <Modal
  90. size='xl'
  91. show={this.state.modal}
  92. onHide={this.closeModal}
  93. aria-labelledby='example-modal-sizes-title-xl'
  94. >
  95. <Modal.Header closeButton></Modal.Header>
  96. <Modal.Body>
  97. <Row style={{}}>
  98. <Col xs={3}>
  99. <h3 style={{ textTransform: 'capitalize' }}>{data.subject}</h3>
  100. <p>{data.description}</p>
  101. </Col>
  102. <Col xs={5}></Col>
  103. <Col xs={4}>
  104. <h5 style={{ marginTop: '30px' }}>
  105. Date Complaint :{' '}
  106. <Moment format='DD,MMM YYYY'>{data.createdAt}</Moment>
  107. </h5>
  108. <br />
  109. <h5 style={{ marginTop: '30px' }}>
  110. Live Consult :{data.liveConsult}
  111. </h5>
  112. </Col>
  113. </Row>
  114.  
  115. <Row style={{ border: '1px solid black' }}>
  116. <Col xs={1}>
  117. <h4>No</h4>
  118. </Col>
  119. <Col xs={3}>
  120. <h4>FullName</h4>
  121. </Col>
  122. <Col xs={2}>
  123. <h4>Gender</h4>
  124. </Col>
  125. <Col xs={3}>
  126. <h4>Phone</h4>
  127. </Col>
  128. <Col xs={1}>
  129. <h4>Age</h4>
  130. </Col>
  131. <Col xs={1}>
  132. <h4>Height</h4>
  133. </Col>
  134. <Col xs={1}>
  135. <h4>Weight</h4>
  136. </Col>
  137. </Row>
  138. <Row
  139. style={{
  140. border: '1px solid black',
  141. borderTop: 'none',
  142. paddingTop: '10px',
  143. }}
  144. >
  145. <Col xs={1}>
  146. <h4>{data.id}</h4>
  147. </Col>
  148. <Col xs={3}>
  149. <h4>{data.fullName}</h4>
  150. </Col>
  151. <Col xs={2}>
  152. <h4>{data.gender}</h4>
  153. </Col>
  154. <Col xs={3}>
  155. <h4>{data.phone}</h4>
  156. </Col>
  157. <Col xs={1}>
  158. <h4>{data.age}</h4>
  159. </Col>
  160. <Col xs={1}>
  161. <h4>{data.height}</h4>
  162. </Col>
  163. <Col xs={1}>
  164. <h4>{data.weight}</h4>
  165. </Col>
  166. </Row>
  167. <Row
  168. style={{
  169. border: '1px solid',
  170. paddingTop: '3px',
  171. borderTop: 'none',
  172. }}
  173. >
  174. {' '}
  175. <Form.Control
  176. as='textarea'
  177. rows='3'
  178. name='reply'
  179. onChange={this.handleChangeTxt}
  180. value={this.state.reply}
  181. />
  182. </Row>
  183. </Modal.Body>
  184. <Modal.Footer>
  185. <Row>
  186. <Col xs={4}>
  187. <Button
  188. variant='danger'
  189. onClick={this.closeModal}
  190. style={{ marginRight: 50 }}
  191. >
  192. CANCEL
  193. </Button>
  194. </Col>
  195. <Col xs={8}>
  196. <Button variant='success' onClick={this.handleReply}>
  197. APPROVE
  198. </Button>
  199. </Col>
  200. </Row>
  201. </Modal.Footer>
  202. </Modal>
  203. </div>
  204. );
  205. }
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement