import { isEmpty } from 'lodash';
import { useContext } from 'react';
import { VmEmpty, VmPieCharts } from "../../../_components";
import { AlarmService } from "../../api";
import { RestaurantContext } 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(RestaurantContext),
    id = _useContext.id;
  var _AlarmService$useType = AlarmService.useTypeAnalysis({
      id: id,
      startDate: startDate,
      endDate: endDate
    }),
    data = _AlarmService$useType.data,
    loading = _AlarmService$useType.loading;
  var total = 0;
  var arr = data.map(function (item) {
    total += item.labelValue;
    return {
      name: item.labelName,
      value: item.labelValue
    };
  });
  return !loading && isEmpty(data) ? /*#__PURE__*/_jsx(VmEmpty, {}) : /*#__PURE__*/_jsx(VmPieCharts, {
    dataList: arr,
    name: '报警次数类型占比',
    title: '总次数',
    total: total,
    unit: '次',
    loading: loading
  });
};
export default AlarmTypeAnalysis;