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</th>
						<th>Judul Dokumen</th>
						<th>File Pendukung</th>
					</tr>
				</thead>
				<tbody>
					{data.penjadwalan.pemeriksaan.map((e) => (
						<tr>
							<td>{moment(e.createdAt).format("D MMMM YYYY")}</td>
							<td>{e.title}</td>
							<td>
								{e.files.map((e) => (
									<>
										<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>
									</>
								))}
							</td>
						</tr>
					))}
				</tbody>
			</table>
		</Datatable>
	);
}

export default TableRiwayat;
