import { InvoiceListProps } from '../model/types';
import { ListDateGroup } from './list-date-group';

export const InvoiceList = ({
  listItems
}: InvoiceListProps) => {

  const getListDateGroup = () => {
    let rs = [];
    for (const [key, value] of Object.entries(listItems)) {
      rs.push(
        <ListDateGroup
          key={ key }
          date={ key }
          items={ value }
        ></ListDateGroup>
      );  
    }
    return rs;
  };

  return (
    <>
      <div className="transaction-list">
        { getListDateGroup() }
      </div>
    </>
  )
};