import Datatable from "@/components/Tables/Datatable";

function TableRiwayat({ data }) {
	return (
		<Datatable options={{ responsive: true }}>
			<table className="table table-striped my-4 w-100">
				<thead>
					<tr>
						<th>Tanggal Dibuat</th>
						<th>Tanggal Dokumen</th>
						<th>Judul Dokumen</th>
						<th>File Pendukung</th>
					</tr>
				</thead>
				<tbody>
					{data.penjadwalan.pemeriksaan.map((e, index) => (
						<tr key={`riwayatPemeriksaan-${index}`}>
							<td>{moment(e.createdAt).format("D MMMM YYYY")}</td>
							<td>{moment(e.date).format("D MMMM YYYY")}</td>
							<td>{e.title}</td>
							<td>
								{e.files.map((e, index) => (
									<>
										<em className="fa-lg far fa-file-code"></em>
										<a className="text-muted" href={`data:${e.type};base64, ${Buffer.from(e.data).toString("base64")}`} download={e.name}>
											{e.name}
										</a>
										<br />
									</>
								))}
							</td>
						</tr>
					))}
				</tbody>
			</table>
		</Datatable>
	);
}

export default TableRiwayat;
