function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import React, { useMemo } from 'react';
import { ProductCard } from '@pisell/materials';
import useSelectPet from "../../../components/booking/info/service2/hooks/useSelectPet";
import { formatProducts } from "../../../components/booking/info/service2/utils";
/**
 * 跨日预约「预约列表」Tab：不依赖 booking miniRedux Context，由 props 注入 state。
 */
export var SalesSdkBookingList = function SalesSdkBookingList(_ref) {
  var items = _ref.items,
    bookingState = _ref.bookingState;
  var _useSelectPet = useSelectPet(bookingState),
    holderLists = _useSelectPet.holderLists;
  var productParams = useMemo(function () {
    var _bookingState$isTermi;
    return {
      hideAddBtn: (_bookingState$isTermi = bookingState.isTerminalDayBookingPage) !== null && _bookingState$isTermi !== void 0 ? _bookingState$isTermi : false,
      isShowNote: false,
      isShowPackageNote: false,
      holders: holderLists,
      isEdit: false,
      disabledEdit: true
    };
  }, [bookingState.isTerminalDayBookingPage, holderLists]);
  var formatted = useMemo(function () {
    return formatProducts(items, bookingState, false);
  }, [items, bookingState]);
  if (!formatted.length) {
    return null;
  }
  return /*#__PURE__*/React.createElement("div", {
    style: {
      display: 'flex',
      flexWrap: 'wrap',
      gap: 16
    }
  }, formatted.map(function (item) {
    var _item$_id;
    return /*#__PURE__*/React.createElement("div", {
      key: (_item$_id = item._id) !== null && _item$_id !== void 0 ? _item$_id : item.id,
      style: {
        width: '100%'
      }
    }, /*#__PURE__*/React.createElement(ProductCard, _extends({
      dataSource: item
    }, productParams)));
  }));
};