import React, { useMemo } from 'react';
import { Row, Col, Card, Statistic } from '@pisell/materials';
import "../index.less";
var prefixCls = 'ecocup-cup-list';
export var useSummary = function useSummary(locales, staticsData, isPartner) {
  var summaryData = useMemo(function () {
    return [{
      key: 'cup-rent',
      title: isPartner ? locales.getText('pisell2.text.ecocup.cup-rent') : locales.getText('pisell2.text.ecocup.eco.cup-rent'),
      value: (staticsData === null || staticsData === void 0 ? void 0 : staticsData.rent_count) || 0,
      type: 'primary'
    }, {
      key: 'cup-returned',
      title: isPartner ? locales.getText('pisell2.text.ecocup.cup-returned') : locales.getText('pisell2.text.ecocup.eco.cup-returned'),
      value: (staticsData === null || staticsData === void 0 ? void 0 : staticsData.return_count) || 0,
      type: 'primary'
    }, {
      key: 'available-to-rent',
      title: locales.getText('pisell2.text.ecocup.available-to-rent'),
      value: (staticsData === null || staticsData === void 0 ? void 0 : staticsData.in_stock_count) || 0
    }];
  }, [staticsData, isPartner]);
  return useMemo(function () {
    return function () {
      return /*#__PURE__*/React.createElement(Row, {
        gutter: 8,
        className: "".concat(prefixCls, "-summary")
      }, summaryData.map(function (item) {
        return /*#__PURE__*/React.createElement(Col, {
          span: 8,
          key: item.key
        }, /*#__PURE__*/React.createElement(Card, {
          className: "".concat(prefixCls, "-summary-card ").concat((item === null || item === void 0 ? void 0 : item.type) === 'primary' ? "".concat(prefixCls, "-summary-primary") : '')
        }, /*#__PURE__*/React.createElement(Statistic, {
          title: item.title,
          value: item.value,
          className: "".concat(prefixCls, "-summary-card-statistic")
        })));
      }));
    };
  }, [summaryData]);
};