import { Col, Row } from 'antd';
import _ from 'lodash';
import { useContext } from 'react';
import { VmLineCharts, VmPieCharts, VmWrapper } from "../../../../_components";
import { LjsyService } from "../../../api";
import { CarContext } from "../../../index";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var StaticInfo = function StaticInfo(_ref) {
  var startDate = _ref.startDate,
    endDate = _ref.endDate;
  var _useContext = useContext(CarContext),
    id = _useContext.id;
  var _LjsyService$useGetAl = LjsyService.useGetAlarmInfo({
      carId: id,
      startDate: startDate,
      endDate: endDate
    }),
    alarmInfo = _LjsyService$useGetAl.alarmInfo,
    loading = _LjsyService$useGetAl.loading;
  var _LjsyService$useGetAl2 = LjsyService.useGetAlarmInfoAnalysis({
      carId: id,
      startDate: startDate,
      endDate: endDate
    }),
    alarmInfoAnalysis = _LjsyService$useGetAl2.alarmInfoAnalysis,
    alarmInfoAnalysisLoading = _LjsyService$useGetAl2.loading;
  var total = _.sumBy(alarmInfo, 'count');
  var list = alarmInfo.map(function (item) {
    return {
      name: item.typeName,
      value: item.count
    };
  });
  var dataList = (alarmInfoAnalysis.legends || []).map(function (legend, index) {
    return {
      name: legend,
      data: alarmInfoAnalysis.values[index]
    };
  });
  return /*#__PURE__*/_jsxs(Row, {
    gutter: [16, 16],
    style: {
      height: 360
    },
    children: [/*#__PURE__*/_jsx(Col, {
      span: 12,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '报警汇总',
        children: /*#__PURE__*/_jsx(VmPieCharts, {
          dataList: list,
          name: '报警类型',
          title: '报警总次数',
          total: total,
          loading: loading,
          unit: '次'
        })
      })
    }), /*#__PURE__*/_jsx(Col, {
      span: 12,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '报警趋势分析',
        children: /*#__PURE__*/_jsx(VmLineCharts, {
          xAxis: alarmInfoAnalysis.names,
          dataList: dataList,
          unit: "\u6B21",
          loading: alarmInfoAnalysisLoading,
          legendOption: {
            width: '95%'
          },
          gridOption: {
            top: 70
          }
        })
      })
    })]
  });
};
export default StaticInfo;