import React, { Component } from "react";
import ContentWrapper from "@/components/Layout/ContentWrapper";
import Link from "next/link";
import { Row, Col, Button, Card, CardBody, Table } from "reactstrap";
import { connect } from "react-redux";
import Loader from "@/components/Common/Loader";
import Router from "next/router";
import TableRiwayat from "@/components/Riwayat/TableRiwayat";
import ChartData from "@/components/Riwayat/ChartData";
import ChartDataBar from "@/components/Riwayat/ChartDataBar";
import Maps from "@/components/Riwayat/Maps"
import TableRiwayatt from "../../../components/Riwayat/TableRiwayatt";
import TableRadar from "../../../components/Riwayat/TableRadar";
import { getjumlahStatusLaporan } from "../../../actions/graph";
import ChartRadarB from "../../../components/Riwayat/ChartRadarB";
import ChartRadarA from "../../../components/Riwayat/ChartRadarA";




class Riwayat extends Component {
  constructor(props) {
    super(props);
    this.state = {
      jumlahStatusLaporan: {}
    };
  }
  handleClick = (e, idPembina) => {
    e.preventDefault();
    Router.push({
      pathname: "/app/riwayat/detail",
      query: { id: idPembina },
    });
  };

  componentDidMount = async () => {
    const { token } = this.props;
    const jumlahStatusLaporan = await getjumlahStatusLaporan(token);
    this.setState({ jumlahStatusLaporan });
  };


  render() {
    const { jumlahStatusLaporan } = this.state;
    return (
      <ContentWrapper>
        <div className="content-heading">
          <span className="font-color-white">Riwayat</span>
        </div>
        <Row>
          <Col lg="6">
            <ChartDataBar />
          </Col>
          <Col lg="6">
            <Maps />
          </Col>
          <Col lg="6">
            <ChartRadarA />
          </Col>
          <Col lg="6">
            <ChartRadarB />
          </Col>
          <Col lg="12">
            {jumlahStatusLaporan?.data ? <TableRadar listData={jumlahStatusLaporan.data} to="/app/riwayat/detail" jadwal="/app/riwayat/penjadwalan" pemeriksaan="/app/riwayat/pemeriksaan" sanksi="/app/riwayat/sanksi" keberatan="/app/riwayat/keberatan" banding="/app/riwayat/banding" perbaikan="/app/riwayat/perbaikan" cabutSanksi="/app/riwayat/cabutSanksi" linkName="Lihat" /> : <Loader />}
          </Col>
          <ChartData />
          <Col lg="12">
            <TableRiwayatt />
          </Col>
        </Row>
      </ContentWrapper>
    );
  }
}
const mapStateToProps = (state) => ({ user: state.user, token: state.token });
export default connect(mapStateToProps)(Riwayat);
