import React, { Component } from "react";
import ContentWrapper from "@/components/Layout/ContentWrapper";
import { Row, Col } from "reactstrap";
import CaseProgress from "@/components/Main/CaseProgress";
import TableSanksi from "@/components/Keberatan/TableSanksi";
import { getSanksi } from "@/actions/sanksi";
import { connect } from "react-redux";
import Loader from "@/components/Common/Loader";
import { createLog } from "@/actions/log";

class Keberatan extends Component {
	constructor(props) {
		super(props);
		this.state = {
			sanksi: {},
		};
	}

	componentDidMount = async () => {
		const { token } = this.props;
		await createLog(token, { aktivitas: "Mengakses halaman Keberatan", menu: "Keberatan" });
		const sanksi = await getSanksi(token, { keberatan: true });
		this.setState({ sanksi });
	};

	render() {
		const { sanksi } = this.state;
		console.log(sanksi)
		return (
			<ContentWrapper>
				<div className="content-heading">
					<span className="font-color-white">Keberatan</span>
				</div>
				<Row>
					{/* <Col lg="4">
						<CaseProgress />
					</Col> */}
					<Col lg="12">{sanksi.data ? <TableSanksi listData={sanksi.data} to="/app/keberatan/detail" linkName="Detail" /> : <Loader />}</Col>
				</Row>
			</ContentWrapper>
		);
	}
}

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