detail.js 3.3 KB

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