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

function Riwayat({ 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>Status</th>
								<th>Dokumen Jawaban</th>
							</tr>
						</thead>
						<tbody>
							{data ? (
								<tr>
									<td>{moment(data.createAt).format("DD MMMM YYYY")}</td>
									<td>{data.status}</td>
									<td>
										{data.dokumen.map((e) => (
											<>
												<em className="fa-lg far fa-file-code"></em>
												<a className="text-muted" href={e.path} target="_blank" download={e.judul}>
													{e.judul}
												</a>
											</>
										))}
									</td>
								</tr>
							) : (
								""
							)}
						</tbody>
					</table>
				</Datatable>
			</CardBody>
		</Card>
	);
}

export default Riwayat;
