| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 | 
							- import Datatable from "@/components/Tables/Datatable";
 
- import { Button } from "reactstrap";
 
- import Link from "next/link";
 
- import moment from "moment";
 
- import 'moment/min/locales';
 
- moment.locale('id');
 
- function TableLaporan({ listData, to, linkName, status = false, noBy = false }) {
 
- 	const getLabelSanksi = (arrayOfObjects, property) => {
 
- 		if (arrayOfObjects?.length === 0) {
 
- 			return undefined; // Return undefined for empty arrays
 
- 		}
 
- 		// let data = null
 
- 		let maxValue = arrayOfObjects[0][property];
 
- 		for (let i = 1; i < arrayOfObjects.length; i++) {
 
- 			if (arrayOfObjects[i][property] > maxValue) {
 
- 				maxValue = arrayOfObjects[i][property];
 
- 				// data = arrayOfObjects[i]
 
- 			}
 
- 			// else {
 
- 			// 	data = arrayOfObjects[i]
 
- 			// }
 
- 		}
 
- 		return maxValue;
 
- 	}
 
- 	return (
 
- 		<div className="card b ">
 
- 			<div className="card-body card-over">
 
- 				{listData && (
 
- 					<Datatable options={{ responsive: false, ordering: true }}>
 
- 						<table className="table w-100" data-order='[[0, "desc"]]'>
 
- 							<thead>
 
- 								<tr>
 
- 									<th>No.Laporan</th>
 
- 									<th>No.Sanksi</th>
 
- 									<th>Deskripcasdasi Laporan</th>
 
- 									{status && <th>Status</th>}
 
- 									{!noBy && <th>Dibuat Oleh</th>}
 
- 									{/* <th>Created</th> */}
 
- 									<th></th>
 
- 								</tr>
 
- 							</thead>
 
- 							<tbody>
 
- 								{listData.map((data) => {
 
- 									return (
 
- 										<tr key={data._id}>
 
- 											<td>
 
- 												{/* <td>{data.no_laporan}</td> */}
 
- 												<div className="media align-items-center">
 
- 													<div className="media-body d-flex">
 
- 														<div>
 
- 															<p style={{ display: "none" }}>{data.createdAt}</p>
 
- 															<h4>{data.laporan.no_laporan}</h4>
 
- 															<p>{moment(data.createdAt).format("DD-MMMM-YYYY")}</p>
 
- 														</div>
 
- 													</div>
 
- 												</div>
 
- 											</td>
 
- 											<td className=" col-md-3">
 
- 												<div>
 
- 													<h4>{data.no_sanksi}</h4>
 
- 												</div>
 
- 											</td>
 
- 											<td className=" col-md-6">
 
- 												<div>
 
- 													<h4 className="m-0">{data.laporan.pt.nama.length > 64 ? data.laporan.pt.nama.substring(0, 64) + "..." : data.laporan.pt.nama}</h4>
 
- 													<p>{data.laporan.keterangan}</p>
 
- 												</div>
 
- 											</td>
 
- 											<td className=" col-md-5">
 
- 												<div>
 
- 													<h4 className="m-0">{data.laporan.role_data === "dikti" ? "Ditindaklanjuti DIKTI" : "Delegasi Ke LLDIKTI"}</h4>
 
- 													{/* {data.pelanggaran.map((e) => (<h2 className="w-105">Sanksi Administratif:  {e.label_sanksi}</h2>))} */}
 
- 													Sanksi Administratif : {getLabelSanksi(data.sanksi, "level") === 3 ? "Berat" : getLabelSanksi(data.sanksi, "level") === 2 ? "Sedang" : "Ringan"}
 
- 												</div>
 
- 											</td>
 
- 											{!noBy && <td>{data.user.isPrivate ? "" : data.user.nama}</td>}
 
- 											<td>
 
- 												<div className="ml-auto">
 
- 													<Link
 
- 														href={{
 
- 															pathname: to,
 
- 															query: { id: data._id },
 
- 														}}
 
- 													>
 
- 														<Button className="btn-login" color>
 
- 															<span className="font-color-white">
 
- 																{linkName}
 
- 															</span>
 
- 														</Button>
 
- 													</Link>
 
- 												</div>
 
- 											</td>
 
- 										</tr>
 
- 									);
 
- 								})}
 
- 							</tbody>
 
- 						</table>
 
- 					</Datatable>
 
- 				)}
 
- 			</div>
 
- 		</div>
 
- 	);
 
- }
 
- export default TableLaporan;
 
 
  |