import { createElement as _createElement } from "react";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React from "react";
import "./style.scss";
import { useTable } from "react-table";
import CheckboxComponent from "../CheckboxComponent";
import RectangularIcon from "../RectangularIcon";
import PersonCompanyNameClickable from "../PersonCompanyNameClickable";
const SearchCompanyTable = ({ onCheckClick, onNameClick, companyData, companyTableColums = [], }) => {
    const data = companyData;
    const columns = React.useMemo(() => 
    // [
    //   { Header: "Name", accessor: "name" },
    //   { Header: "Industries", accessor: "industries" },
    //   { Header: "Specialties", accessor: "specialties" },
    //   { Header: "Company Size", accessor: "staffCount" },
    //   { Header: "Location", accessor: "location" },
    // ]
    companyTableColums, []);
    const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({ columns, data });
    return (_jsxs("table", { className: "searchCompanyTable--Generic", ...getTableProps(), children: [_jsx("thead", { children: headerGroups.map((headerGroup) => (_jsx("tr", { ...headerGroup.getHeaderGroupProps(), children: headerGroup.headers.map((column) => (_jsx("th", { className: "searchPersonTable-Header-Cell", ...column.getHeaderProps(), children: column.render("Header") }))) }))) }), _jsx("tbody", { ...getTableBodyProps(), children: rows.map((row) => {
                    prepareRow(row);
                    return (_createElement("tr", { ...row.getRowProps(), key: `${row.original.universalName}${row.original.isSelected}` }, row.cells.map((cell) => {
                        if (cell.column.Header === "Name") {
                            return (_jsx("td", { ...cell.getCellProps(), children: _jsxs("span", { className: "searchPersonTable--NameCell", children: [_jsx("p", { children: cell.row.original.index }), _jsx(CheckboxComponent, { sizeVariant: "xs", checked: cell.row.original.isSelected, onClick: (_checked) => {
                                                onCheckClick(cell.row.original.universalName);
                                            } }), _jsx(RectangularIcon, { iconPath: cell.row.original.logo, iconSize: "40", borderRadius: "6", altImageType: "company" }), _jsx(PersonCompanyNameClickable, { text: cell?.value, onClick: () => onNameClick(cell.row.original.universalName) })] }) }));
                        }
                        else if (cell.column.Header === "Employees") {
                            return (_jsx("td", { ...cell.getCellProps(), className: cell.row.original.staffCount === "" ||
                                    cell.row.original.staffCount === "0"
                                    ? "searchCompanyTable--NotAvailable"
                                    : "", children: (() => {
                                    if (typeof cell.row.original.staffCount === "string") {
                                        if (cell.row.original.staffCount === "" ||
                                            cell.row.original.staffCount === "0") {
                                            return "Not Available";
                                        }
                                        return Math.floor(parseInt(cell.row.original.staffCount))?.toLocaleString("en-US");
                                    }
                                    if (typeof cell.row.original.staffCount === "number") {
                                        if (Math.floor(cell.row.original.staffCount) === 0) {
                                            return "Not Available";
                                        }
                                        return Math.floor(cell.row.original.staffCount)?.toLocaleString("en-US");
                                    }
                                    return "Not Available";
                                })() }));
                        }
                        else if (cell.column.Header === "Location") {
                            return (_jsx("td", { ...cell.getCellProps(), className: cell.row.original.location === "Not Available"
                                    ? "searchCompanyTable--NotAvailable"
                                    : "", children: cell.row.original.location === ""
                                    ? "Not Available"
                                    : cell.row.original.location }));
                        }
                        else {
                            return (_jsx("td", { ...cell.getCellProps(), className: cell?.value === "Not Available"
                                    ? "searchCompanyTable--NotAvailable"
                                    : "", children: cell.render("Cell") || "N/A" }));
                        }
                    })));
                }) })] }));
};
export default SearchCompanyTable;
