Advertisement
ndieee

Untitled

May 19th, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import {
  3. Nav, NavLink, NavItem, Card, Button, CardTitle, CardText, CardDeck,
  4. CardSubtitle, CardBody,
  5. } from 'reactstrap';
  6. import axios from 'axios';
  7. import { Link } from 'react-router-dom';
  8.  
  9.  
  10. class BodySurveyView extends Component {
  11. constructor(props) {
  12. super(props);
  13. this.state = {
  14. items: [],
  15. };
  16. [
  17. 'handleClick',
  18. ].forEach((v) => { this[v] = this[v].bind(this); });
  19. }
  20.  
  21. componentDidMount() {
  22. const datas = [
  23. {
  24. username: 'radiancesoft.sby@gmail.com',
  25. password: 'warpin1234567890',
  26. },
  27. ];
  28. axios({
  29. method: 'post',
  30. url: 'https://oc6tq8iop5.execute-api.ap-southeast-1.amazonaws.com/dev/opening/interview',
  31. headers: {
  32. 'Content-Type': 'application/json',
  33. 'x-api-key': 'TUMYmAEXi22OkOnHx8fzoa3F3nR5traDRdcuBy31',
  34. 'Access-Control-Allow-Origin': true,
  35. },
  36. data: JSON.stringify(datas),
  37. })
  38. .then((data) => {
  39. this.setState({ items: data.data });
  40. console.log(data);
  41. });
  42. }
  43. /* eslint-disable react/no-unused-state */
  44. handleClick(item) {
  45. console.log('mitra_id: ', item.mitraId);
  46. this.setState({ Data: item.mitraId });
  47. }
  48. /* eslint-enable react/no-unused-state */
  49. renderData() {
  50. const data = this.state.items.map(item => (
  51. <CardDeck key={item.id}>
  52. <Card>
  53. <CardBody>
  54. <CardTitle><div className="text-right">Mitra ID :</div> <p className="text-left"> {item.mitraId}</p></CardTitle>
  55. <CardSubtitle><p className="text-right">name :</p> <p className="text-left"> {item.mitra_name} </p></CardSubtitle>
  56. <CardText><p className="text-right">lokasi Warung :</p> {item.lokasi_warung} </CardText>
  57. <CardText><p className="text-right"> Nama Mitra :</p> {item.nama_mitra} </CardText>
  58. <Link
  59. to={{
  60. pathname: '/BodySurveyForm',
  61. state: { Data: item.mitraId, Datas: item.mitra_name, DataName: item.nama_mitra },
  62. }}
  63. >
  64. <Button
  65. id="send"
  66. >
  67. Survey Sekarang
  68. </Button>
  69. </Link>
  70. </CardBody>
  71. </Card>
  72. </CardDeck>));
  73. return data;
  74. }
  75.  
  76.  
  77. /* eslint-disable react/no-sequences */
  78. render() {
  79. return (
  80. <div className="comp-body-leads-view">
  81. <div className="card card-body-user-are">
  82. <Nav className="nav-fill nav-fill-compact">
  83. <NavItem className="text-left">
  84. <NavLink className="pl-0"> List Survey </NavLink>
  85. </NavItem>
  86. </Nav>
  87. {this.renderData()}
  88. </div>
  89. </div>
  90. /* eslint-enable react/no-sequences */
  91. );
  92. }
  93. }
  94.  
  95. export default BodySurveyView;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement