import React, { Component } from "react";
import Header from "@/components/Main/Header";
import DetailPT from "@/components/Main/DetailPT";
import { getPelaporan } from "@/actions/pelaporan";
import DetailLaporan from "@/components/Main/DetailLaporan";
import Link from "next/link";
import ContentWrapper from "@/components/Layout/ContentWrapper";
import { Row, Col, Card, CardBody } from "reactstrap";

class DetailPelaporan extends Component {
	static getInitialProps = async ({ query }) => {
		const pelaporan = await getPelaporan({ ptId: query.ptId, number: query.number });
		return { query, pelaporan };
	};

	render() {
		const { pelaporan } = this.props;
		return (
			<ContentWrapper unwrap>
				<Header />
				<div className="p-3">
					<div className="content-heading">
						<div>Detail Pelaporan</div>
						<div className="ml-auto">
							<Link href="/app/pelaporan">
								<button className="btn btn-sm btn-secondary text-sm">&lt; back</button>
							</Link>
						</div>
					</div>
					<Row>
						<Col xl="9">
							<Card className="card-default">
								<CardBody>
									<Row>
										<Col lg={12}>
											<DetailLaporan data={pelaporan.data[0]} />
										</Col>
									</Row>
								</CardBody>
							</Card>
						</Col>
						<Col xl="3">
							<DetailPT />
						</Col>
					</Row>
				</div>
			</ContentWrapper>
		);
	}
}

export default DetailPelaporan;
