detail.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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, 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. <div>Detail Laporan Delegasi</div>
  40. <div className="ml-auto">
  41. <Link href="/app/laporan-delegasi">
  42. <button className="btn btn-sm btn-secondary text-sm">&lt; back</button>
  43. </Link>
  44. </div>
  45. </div>
  46. <Row>
  47. <Col xl="9">
  48. {pelaporan.data ? (
  49. <Card className="card-default">
  50. <CardBody>
  51. <Row>
  52. <Col lg={12}>
  53. {<DetailLaporan data={pelaporan.data} />}
  54. <p className="lead bb">Keterangan Delegasi</p>
  55. <form className="form-horizontal">
  56. <FormGroup row>
  57. <Col md="4">Alasan Delegasi:</Col>
  58. <Col md="8">
  59. <Scrollable height="100px" className="list-group">
  60. <p>{pelaporan.data.alasan_delegasi}</p>
  61. </Scrollable>
  62. </Col>
  63. </FormGroup>
  64. </form>
  65. </Col>
  66. </Row>
  67. </CardBody>
  68. </Card>
  69. ) : (
  70. <Loader />
  71. )}
  72. </Col>
  73. <Col xl="3">{pelaporan.data ? <DetailPT data={pelaporan.data.pt} /> : <Loader />}</Col>
  74. </Row>
  75. <Row>
  76. {pemantauan.data && (
  77. <Col xl={12}>
  78. <Timeline data={pemantauan.data} />
  79. </Col>
  80. )}
  81. </Row>
  82. </div>
  83. </ContentWrapper>
  84. );
  85. }
  86. }
  87. const mapStateToProps = (state) => ({ user: state.user, token: state.token });
  88. export default connect(mapStateToProps)(DetailPelaporan);