"use client";

import React from "react";

import { Row } from "./Row";
import TableContext from "./TableContext";
import { TableContextType, TableRow } from "./types";

const Footer: React.FC = () => {
  const { footers } = React.useContext(TableContext) as TableContextType;

  return footers ? (
    <tfoot>
      {footers.map((row: TableRow, i: number) => (
        <tr key={i.toString()}>
          <Row row={row} />
        </tr>
      ))}
    </tfoot>
  ) : null;
};

Footer.displayName = "TableFooter";

export { Footer };
