import React, { useEffect, useContext, useMemo } from 'react';
import AddService from "./addService";
import { Context } from "../../info/model";
import EditService from "./editService";
import "../../info/service/index.less";
import AddTimeModal from "./addTimeModal";
import useInfoHolder from "../../info/hooks/useInfoHolder";
import Lists from "../../info/service/Lists";
import useQuotation from "../../hooks/useQuotation";
import useClearCart from "../../hooks/useClearCart";
import EditNormalService from "./editNormalService";
var Service = function Service() {
  var _useContext = useContext(Context),
    state = _useContext.state,
    dispatch = _useContext.dispatch;
  var _useInfoHolder = useInfoHolder(state, dispatch),
    detailRef = _useInfoHolder.detailRef,
    handleEdit = _useInfoHolder.handleEdit,
    handleAction = _useInfoHolder.handleAction,
    dispatchService = _useInfoHolder.dispatchService,
    showAddTimeModal = _useInfoHolder.showAddTimeModal,
    editNormalServiceRef = _useInfoHolder.editNormalServiceRef;
  useEffect(function () {
    document.body.id = 'body';
  }, []);
  var clearCart = useClearCart(state, dispatch);
  var _useQuotation = useQuotation(state, dispatch),
    dom = _useQuotation.dom;
  var renderMemo = useMemo(function () {
    console.log('render info22222');
    return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
      className: "pisell-lowcode__booking-service-wrap"
    }, state !== null && state !== void 0 && state.isBookingTicket2 ? null : clearCart, /*#__PURE__*/React.createElement(Lists, {
      isParallelResource: true,
      onEdit: handleEdit,
      onAction: handleAction,
      onChange: function onChange(e, type) {
        return dispatchService(type || 'setService', e);
      }
    }), !state.isBookingCreatePage ? /*#__PURE__*/React.createElement(AddService, {
      onEdit: handleEdit
    }) : null), /*#__PURE__*/React.createElement(EditService, {
      ref: detailRef
    }), showAddTimeModal && /*#__PURE__*/React.createElement(AddTimeModal, null), /*#__PURE__*/React.createElement(EditNormalService, {
      ref: editNormalServiceRef
    }), dom);
  }, [dom, showAddTimeModal, clearCart, state === null || state === void 0 ? void 0 : state.isBookingTicket2]);
  return /*#__PURE__*/React.createElement(React.Fragment, null, renderMemo);
};
export default /*#__PURE__*/React.memo(Service);