import React from 'react';

// utils
import { OrderProductsListProps } from '../utils/types';
import { groupLines } from '../utils/helperFunctions';

// components
import OrderProduct from '../OrderProduct';

// styles
import { OrderProductsListWrapper } from './style';

const OrderProductsList = (props: OrderProductsListProps): JSX.Element => {
  const { lines, orderId, currency, isZoomIN } = props;

  return (
    <OrderProductsListWrapper isZoomIn={isZoomIN}>
      {groupLines(lines).map((line) => (
        <OrderProduct
          key={line.id}
          line={line}
          orderId={orderId}
          currency={currency}
        />
      ))}
    </OrderProductsListWrapper>
  );
};

export default OrderProductsList;
