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

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

	render() {
		const { pelaporan, query } = this.props;

		return (
			<ContentWrapper unwrap>
				<Header />
				<div className="p-3">
					<div className="content-heading">
						<div>Evaluasi Laporan</div>
						<div className="ml-auto">
							<Link href="/app/pemeriksaan">
								<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="6">
											<DetailLaporan data={pelaporan.data[0]} />
										</Col>
										<Col lg={6}>
											<InputEvaluasi query={query} />
										</Col>
									</Row>
								</CardBody>
							</Card>
						</Col>
						<Col xl="3">
							<DetailPT />
						</Col>
					</Row>
					<Row>
						<Col>
							<Card className="card-default">
								<CardHeader>
									<CardTitle>Riwayat Evaluasi</CardTitle>
								</CardHeader>
								<CardBody>
									<TableRiwayat data={pelaporan.data[0]} />
								</CardBody>
							</Card>
						</Col>
					</Row>
				</div>
			</ContentWrapper>
		);
	}
}

export default PemeriksaanNew;
