import { BookingOptionUnit } from '@qite/tide-client/build/types';
import { isEmpty } from 'lodash';
import React from 'react';
import SummaryPerUnitOptionGroup from './summary-per-unit-option-group';

interface SummaryBookingOptionUnitProps {
  unit: BookingOptionUnit;
}

const SummaryBookingOptionUnit: React.FC<SummaryBookingOptionUnitProps> = ({ unit }) => {
  return (
    <>
      {unit.groups.map((y) => {
        const unitOptions = y.options.filter((y) => y.isSelected);
        if (isEmpty(unitOptions)) return;

        return <SummaryPerUnitOptionGroup group={y} />;
      })}
    </>
  );
};

export default SummaryBookingOptionUnit;
