detail.js 3.1 KB

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