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 ( {columns.map((column, index) => ( ))} {rows?.length > 0 && rows.map((row, i) => { return ( {columns.map((cell, index) => { if (cell.accessor.split(",").length > 1) { return ( ); } if (cell.accessor === "" && emailActions) { return ( ); } if (cell.accessor === "" && profile && cell.viewProperty) { return ( ); } if (cell.accessor === "" && actions) { return ( ); } if (cell.accessor === "" && profile) { return ( ); } if (cell.accessor == "image" || cell.accessor == "photo_url") { return ( ); } if (cell.accessor == "icon") { return ( ); } if (cell.statusMapping) { return ( ); } if (cell.mapping) { return ( ); } if (cell.accessor == "dob") { return ( ); } if (cell.accessor?.includes("email")) { return ( ); } if (cell.accessor == "num_properties") { return ( ); } if (cell.accessor.includes("payout") || cell.amountField) { return ( ); } if (cell.formatDate) { return ( ); } if (cell.nested) { return ( ); } if (cell.idPrefix) { return ( ); } if (cell.format) { return ( ); } if (cell.accessor === "cost") { return ( ); } return ( ); })} ); })}
onSort(column.accessor)} > {column.header} {column.isSorted} {column.isSorted ? (column.isSortedDesc ? " ▼" : " ▲") : ""}
{cell.accessor.split(",").map((accessor, i) => ( {row[accessor.trim()]} ))} {showDelete && ( )} {showDelete && ( )} {row?.is_photo_approved == IMAGE_STATUS.IN_REVIEW ? ( <> ) : row?.is_photo_approved === IMAGE_STATUS.APPROVED ? ( ) : ( )} {showDelete && ( )} image icon {" "} {cell.statusMapping[row[cell.accessor]]} {cell.mapping[row[cell.accessor]] ?? "N/A"} {row[cell.accessor] ? moment(row[cell.accessor]).format("MM/DD/YY") : ""} {row[cell.accessor]} {/* {row[cell.accessor]} */} ${(row[cell.accessor] ? row[cell.accessor] : 0).toFixed(2)} {new Date(row[cell.accessor]).toUTCString()} {row[cell.nested][cell.accessor]} {cell.idPrefix + row[cell.accessor]} {cell.format(row[cell.accessor])} ${row[cell.accessor]} {row[cell.accessor]}
); }; export default Table;