import { isEmpty } from 'lodash';
import sumBy from 'lodash/sumBy';
import { useContext } from 'react';
import { VmEmpty, VmPieCharts } from "../../../_components";
import { AlarmService } from "../../api";
import { CcCpContext } from "../../index";
import { jsx as _jsx } from "react/jsx-runtime";
var AlarmTypeAnalysis = function AlarmTypeAnalysis(_ref) {
  var startDate = _ref.startDate,
    endDate = _ref.endDate;
  var _useContext = useContext(CcCpContext),
    id = _useContext.id;
  var _AlarmService$useGetS = AlarmService.useGetSyPointAbnormalTypeNums(id, startDate, endDate),
    data = _AlarmService$useGetS.data,
    loading = _AlarmService$useGetS.loading;
  var totalCount = sumBy(data, 'labelValue');
  var alarmTabsValue = data.map(function (item) {
    return {
      name: item.labelName,
      value: item.labelValue
    };
  });
  return !loading && isEmpty(data) ? /*#__PURE__*/_jsx(VmEmpty, {}) : /*#__PURE__*/_jsx(VmPieCharts, {
    dataList: alarmTabsValue,
    name: '类型分析',
    title: '总次数',
    total: totalCount,
    unit: '次',
    loading: loading
  });
};
export default AlarmTypeAnalysis;