import React, { useContext } from "react"; import { useNavigate } from "react-router-dom"; import { GlobalContext } from "@/globalContext"; import moment from "moment"; import { IMAGE_STATUS } from "@/utils/constants"; const Table = ({ columns, rows, actions, profile, tableType, type, table1, table2, deleteMessage, deleteTitle, showDelete = true, onSort, id, rejectImage, approveImage, setActivePicture, openPictureModal, baasDelete, emailActions, }) => { const { dispatch: globalDispatch } = useContext(GlobalContext); const navigate = useNavigate(); return (
| onSort(column.accessor)} > {column.header} {column.isSorted} {column.isSorted ? (column.isSortedDesc ? " ▼" : " ▲") : ""} | ))}||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {cell.accessor.split(",").map((accessor, i) => ( {row[accessor.trim()]} ))} | ); } if (cell.accessor === "" && emailActions) { return ({showDelete && ( )} | ); } if (cell.accessor === "" && profile && cell.viewProperty) { return ({showDelete && ( )} | ); } if (cell.accessor === "" && actions) { return ({row?.is_photo_approved == IMAGE_STATUS.IN_REVIEW ? ( <> > ) : row?.is_photo_approved === IMAGE_STATUS.APPROVED ? ( ) : ( )} | ); } if (cell.accessor === "" && profile) { return ({showDelete && ( )} | ); } if (cell.accessor == "image" || cell.accessor == "photo_url") { return (
|
);
}
if (cell.accessor == "icon") {
return (
|
);
}
if (cell.statusMapping) {
return (
{" "} {cell.statusMapping[row[cell.accessor]]} | ); } if (cell.mapping) { return ({cell.mapping[row[cell.accessor]] ?? "N/A"} | ); } if (cell.accessor == "dob") { return ({row[cell.accessor] ? moment(row[cell.accessor]).format("MM/DD/YY") : ""} | ); } if (cell.accessor?.includes("email")) { return ({row[cell.accessor]} | ); } if (cell.accessor == "num_properties") { return ({/* {row[cell.accessor]} */} | ); } if (cell.accessor.includes("payout") || cell.amountField) { return (${(row[cell.accessor] ? row[cell.accessor] : 0).toFixed(2)} | ); } if (cell.formatDate) { return ({new Date(row[cell.accessor]).toUTCString()} | ); } if (cell.nested) { return ({row[cell.nested][cell.accessor]} | ); } if (cell.idPrefix) { return ({cell.idPrefix + row[cell.accessor]} | ); } if (cell.format) { return ({cell.format(row[cell.accessor])} | ); } if (cell.accessor === "cost") { return (${row[cell.accessor]} | ); } return ({row[cell.accessor]} | ); })}