import React, { Component } from "react";
import ContentWrapper from "@/components/Layout/ContentWrapper";
import { Row, Col } from "reactstrap";
import { getSanksi } from "@/actions/sanksi";
import TableSanksi from "@/components/PT/JawabanPencabutanSanksi/TableSanksiJawaban";
import { connect } from "react-redux";

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

	componentDidMount = async () => {
		const { user } = this.props;
		const org_id = user.peran[0].organisasi.id;
		const sanksi = await getSanksi({ cabutSanksi: true, ptId: org_id });
		this.setState({ sanksi });
	};

	render() {
		const { sanksi } = this.state;
		return (
			<ContentWrapper>
				<div className="content-heading">Jawaban Permohonan Pencabutan Sanksi</div>
				<Row>
					<Col lg={12}>{sanksi.data && sanksi.data.length ? <TableSanksi listData={sanksi.data} to="/app/pt/jawaban-pencabutan-sanksi/detail" linkName="Detail" /> : ""}</Col>
				</Row>
			</ContentWrapper>
		);
	}
}

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