import React, { Component } from "react";
import { Card, CardBody, TabContent, TabPane, Nav, NavItem, NavLink, Button, Row, Col } from "reactstrap";
import Router from "next/router";
import classnames from "classnames";
import ContentWrapper from "@/components/Layout/ContentWrapper";
import DetailSanksi from "@/components/Main/DetailSanksi";
import Header from "@/components/Main/Header";
import Link from "next/link";
import { getPelaporan } from "@/actions/pelaporan";
import { getOneSanksi } from "@/actions/sanksi";
import Loader from "@/components/Common/Loader";
import { connect } from "react-redux";

const stepNavitemStyle = {
	backgroundColor: "#fcfcfc",
};

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

	static getInitialProps = async ({ query }) => {
		return { query };
	};

	componentDidMount = async () => {
		const { query, token } = this.props;
		const sanksi = await getOneSanksi(token, query.id);
		this.setState({ sanksi });
	};

	render() {
		const { sanksi } = this.state;
		return (
			<ContentWrapper unwrap>
				{/* <Header /> */}
				<div className="p-3">
					<div className="content-heading">
						<div>Detail Sanksi</div>
						<div className="ml-auto">
							<Link href="/app/sanksi">
								<button className="btn btn-sm btn-secondary text-sm">&lt; back</button>
							</Link>
						</div>
					</div>
					{sanksi.data ? (
						<Card className="card-default">
							<CardBody>
								<Row>
									<Col>
										<DetailSanksi data={sanksi.data} />
									</Col>
								</Row>
							</CardBody>
						</Card>
					) : (
						<Loader />
					)}
				</div>
			</ContentWrapper>
		);
	}
}

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