detail.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import React, { Component } from "react";
  2. import Header from "@/components/Main/Header";
  3. import DetailPT from "@/components/Main/DetailPT";
  4. import { getOneLaporan } from "@/actions/pelaporan";
  5. import { getLog } from "@/actions/log";
  6. import DetailLaporan from "@/components/Main/DetailLaporan";
  7. import Link from "next/link";
  8. import ContentWrapper from "@/components/Layout/ContentWrapper";
  9. import { Row, Col, Card, CardBody, Button, FormGroup } from "reactstrap";
  10. import Loader from "@/components/Common/Loader";
  11. import { connect } from "react-redux";
  12. import Scrollable from "@/components/Common/Scrollable";
  13. import Timeline from "@/components/Main/Timeline";
  14. class DetailPelaporan extends Component {
  15. constructor(props) {
  16. super(props);
  17. this.state = {
  18. pelaporan: {},
  19. pemantauan: {},
  20. };
  21. }
  22. static getInitialProps = async ({ query }) => {
  23. return { query };
  24. };
  25. componentDidMount = async () => {
  26. const { query } = this.props;
  27. const pelaporan = await getOneLaporan(this.props.token, query.id + "?delegasi=true");
  28. const pemantauan = await getLog(this.props.token, query.id + "?delegasi=true&asc=true");
  29. pemantauan.data = pemantauan.data.filter((e) => e.action != "CREATE LAPORAN");
  30. this.setState({ pelaporan, pemantauan });
  31. };
  32. render() {
  33. const { pelaporan, pemantauan } = this.state;
  34. return (
  35. <ContentWrapper unwrap>
  36. {/* <Header /> */}
  37. <div className="p-3">
  38. <div className="content-heading">
  39. <span className="font-color-white">
  40. Detail Laporan Delegasi
  41. </span>
  42. <div className="ml-auto">
  43. <Link href="/app/laporan-delegasi">
  44. <Button className="color-3e3a8e" color>
  45. <span className="font-color-white">
  46. &lt; Kembali
  47. </span>
  48. </Button>
  49. </Link>
  50. </div>
  51. </div>
  52. <Row>
  53. <Col xl="9">
  54. {pelaporan.data ? (
  55. <Card className="card-default">
  56. <CardBody>
  57. <Row>
  58. <Col lg={12}>
  59. {<DetailLaporan data={pelaporan.data} />}
  60. <p className="lead bb">Keterangan Delegasi</p>
  61. <form className="form-horizontal">
  62. <FormGroup row>
  63. <Col md="4">Alasan Delegasi:</Col>
  64. <Col md="8">
  65. <Scrollable height="100px" className="list-group">
  66. <p>{pelaporan.data.alasan_delegasi}</p>
  67. </Scrollable>
  68. </Col>
  69. </FormGroup>
  70. </form>
  71. </Col>
  72. </Row>
  73. </CardBody>
  74. </Card>
  75. ) : (
  76. <Loader />
  77. )}
  78. </Col>
  79. <Col xl="3">{pelaporan.data ? <DetailPT data={pelaporan.data.pt} /> : <Loader />}</Col>
  80. </Row>
  81. <Row>
  82. {pemantauan.data && (
  83. <Col xl={12}>
  84. <Timeline data={pemantauan.data} />
  85. </Col>
  86. )}
  87. </Row>
  88. </div>
  89. </ContentWrapper>
  90. );
  91. }
  92. }
  93. const mapStateToProps = (state) => ({ user: state.user, token: state.token });
  94. export default connect(mapStateToProps)(DetailPelaporan);