import { FC, Fragment, useState } from "react"; import { eventSummary } from "shared/lib/slickgrid"; import { Overlay, Popup } from "entities/popup"; import { useMakeVisible, useSubscribeToEvent } from "../lib"; import { ITotal, SELECTED_ROWS_SUMMARY } from "../model"; import { TotalByColumn } from "./TotalByColumn"; import Styled from "./PopupSummary.style"; export const PopupSummary: FC = ({ tableId }) => { const [rowsNumber, setRowsNumber] = useState(0); const [isOpened, setIsOpened] = useState(false); const [totals, setTotals] = useState({}); function onClose() { eventSummary.open = false; } useMakeVisible(isOpened); useSubscribeToEvent(setIsOpened, setRowsNumber, setTotals, tableId); if (!isOpened) return null; return ( Selected rows summary {`Number of selected rows: ${rowsNumber}`} {Object.entries(totals).map( ([id, { label, total, totalFormatted }]) => (
  • ), )}
    Close
    ); }; interface Props { tableId: string; }