import moment from "moment";
import { Button, Table } from "reactstrap";
import Link from "next/link";

function TableSanksi({ listData, to, linkName }) {
	return (
		<div className="card b">
			<div className="card-body card-over">
				<Table className="table w-100">
					<thead>
						<tr>
							<th>Nomor Sanksi</th>
							<th>Keterangan Sanksi</th>
							{/* <th>Created</th> */}
							<th>Status</th>
						</tr>
					</thead>
					<tbody>
						{listData.map((data) => {
							return (
								<tr key={data._id}>
									{/* <td>{data.no_sanksi}</td> */}
									<td>
										<div className="media align-items-center">
											<div className="media-body d-flex">
												<div>
													<h4>{data.no_sanksi}</h4>
													<p>{moment(data.createdAt).format("MM-DD-YYYY")}</p>
												</div>
											</div>
										</div>
									</td>
									<td>
										<div className="table-desc">
											<div className="media align-items-center">
												{/* <img className="img-fluid rounded thumb64" src="/static/img/dummy-search.png" alt="Dummy" /> */}
												<div className="media-body d-flex">
													<div>
														<h4 className="m-0">{data.laporan.pt.nama.length > 64 ? data.laporan.pt.nama.substring(0, 64) + "..." : data.laporan.pt.nama}</h4>
														{/* <small className="text-muted">0742/O/1990 - www.satyagama.ac.id - info@satyagama.ac.id</small> */}
														{/* <p className="w-105">{data.keterangan.length > 200 ? data.keterangan.substring(0, 200) + "..." : data.keterangan}</p> */}
														<p className="w-105">{data.keterangan}</p>
													</div>
												</div>
											</div>
										</div>
									</td>
									{/* <td>{moment(data.createdAt).format("DD MMMM YYYY")}</td> */}
									<td>
										{data.jawaban?.keberatan ? (
											<Link href={{ pathname: to, query: { id: data._id } }}>
												<Button color="primary">{linkName}</Button>
											</Link>
										) : (
											<div className="badge-info badge">Menunggu Jawaban</div>
										)}
									</td>
								</tr>
							);
						})}
					</tbody>
				</Table>
			</div>
		</div>
	);
}

export default TableSanksi;
