import { createElement as _createElement } from "react";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import React from "react";
import { useTable } from "react-table";
import "./style.scss";
import RevenueTable from "./RevenueTable";
import { Loader } from "../..";
import clsx from "clsx";
const CompanyViewFinancialIncomeStatement = ({ expensesHeaders, revenueHeaders, revenueData, expensesData, isError = false, isLoading = false, }) => {
    const data = expensesData;
    const columns = React.useMemo(() => [{ Header: "Expenses", accessor: "expense" }, ...expensesHeaders], []);
    const { getTableProps, getTableBodyProps, headerGroups, rows, prepareRow } = useTable({ columns, data });
    const className = clsx({
        [``]: isError,
        [`companyViewFinancial--IncomeStatementWrapper`]: !isError || isLoading,
    });
    return (_jsx("div", { className: className, children: isLoading ? (_jsx("div", { className: "companyViewFinancial--IncomeStatementLoading", children: _jsx(Loader, { height: "32", width: "32", type: "tailSpin" }) })) : isError ? (_jsx("div", { className: "companyViewFinancial--IncomeStatementError", children: "NOT AVAILABLE" })) : (_jsxs(_Fragment, { children: [_jsx(RevenueTable, { revenueHeader: revenueHeaders, revenueData: revenueData }), _jsxs("table", { className: "companyViewFinancial-ExpenseTable", ...getTableProps(), children: [_jsx("thead", { children: headerGroups.map((headerGroup) => (_jsx("tr", { ...headerGroup.getHeaderGroupProps(), children: headerGroup.headers.map((column) => (_jsx("th", { ...column.getHeaderProps(), children: column.render("Header") }))) }))) }), _jsx("tbody", { ...getTableBodyProps(), children: rows.map((row) => {
                                prepareRow(row);
                                return (_createElement("tr", { ...row.getRowProps(), key: `${row.original.publicIdentifier}${row.original.isSelected}` }, row.cells.map((cell) => {
                                    return (_jsx("td", { ...cell.getCellProps(), children: cell.render("Cell") }));
                                    //   }
                                })));
                            }) })] })] })) }));
};
export default CompanyViewFinancialIncomeStatement;
