import React, { Component } from "react";
import ContentWrapper from "@/components/Layout/ContentWrapper";
import { Row, Col } from "reactstrap";
import { getPelaporan } from "@/actions/pelaporan";
import { getSanksi } from "@/actions/sanksi";
import TableLaporan from "@/components/TurunSanksi/TableLaporan";
import { connect } from "react-redux";
import Loader from "@/components/Common/Loader";

class NaikSanksi extends Component {
	constructor(props) {
		super(props);
		this.state = {
			pelaporan: {},
			graph: {},
			tahun: new Date().getFullYear(),
			sanksi: {}
		};
	}

	componentDidMount = async () => {
		const { token } = this.props;
		const pelaporan = await getPelaporan(token, { sanksi: true });
		const sanksi = await getSanksi(token, { turunSanksi: true, perbaikan: true })
		this.setState({ pelaporan, sanksi });
	};

	render() {
		const { pelaporan, sanksi } = this.state;
		return (
			<ContentWrapper>
				<div className="content-heading">
					<span className="font-color-white">Perubahan Turun Sanksi</span>
				</div>
				<Row>
					{/* <Col lg="12">{graph?.data ? <CaseProgress data={graph.data} nextButton={this.nextButton} prevButton={this.prevButton} tahun={this.state.tahun} excel={this.excel} /> : <Loader />}</Col> */}
					<Col lg="12">{sanksi?.data ? <TableLaporan status noBy listData={sanksi.data} to="/app/turun-sanksi/detail" linkName="Detail" /> : <Loader />}</Col>
				</Row>
			</ContentWrapper>
		);
	}
}

const mapStateToProps = (state) => ({ user: state.user, token: state.token });
export default connect(mapStateToProps)(NaikSanksi);
