import Datatable from "@/components/Tables/Datatable";
import moment from "moment";
import { Card, CardHeader, CardBody, CardTitle } from "reactstrap";
import { API_URL } from "@/env";

function Riwayat({ data }) {
	const { cabut_sanksi } = data.sanksi;
	console.log(data);
	return (
		<Card className="card-default">
			<CardHeader>
				<CardTitle>Riwayat</CardTitle>
			</CardHeader>
			<CardBody>
				<Datatable options={{ responsive: true }}>
					<table className="table table-striped my-4 w-100">
						<thead>
							<tr>
								<th>Tanggal</th>
								<th>Dokumen</th>
							</tr>
						</thead>
						<tbody>
							{cabut_sanksi ? (
								<tr>
									<td>{moment(data.createAt).format("DD MMMM YYYY")}</td>
									<td>
										{cabut_sanksi.files.map((e) => (
											<>
												<em className="fa-lg far fa-file-code"></em>
												<a className="text-muted" href={API_URL + e.path} target="_blank" download={e.name}>
													{e.name}
												</a>
											</>
										))}
									</td>
								</tr>
							) : (
								""
							)}
						</tbody>
					</table>
				</Datatable>
			</CardBody>
		</Card>
	);
}

export default Riwayat;
