import { useMemoizedFn } from 'ahooks';
import { Col, Row } from 'antd';
import { useContext } from 'react';
import { VmInfoCollection, VmWrapper } from "../../../../_components";
import { BaseService } from "../../../api";
import { CarContext } from "../../../index";
import { jsx as _jsx } from "react/jsx-runtime";
var DeviceInfo = function DeviceInfo() {
  var _useContext = useContext(CarContext),
    id = _useContext.id;
  var _BaseService$useDevic = BaseService.useDeviceInfo(id),
    deviceList = _BaseService$useDevic.deviceList;
  var getItem = useMemoizedFn(function (item) {
    return [{
      label: '设备名称',
      value: item.name,
      key: 'name'
    }, {
      label: '设备卡号',
      value: item.cardNumber,
      key: 'cardNumber'
    }, {
      label: '原始设备编码',
      value: item.originalCode,
      key: 'originalCode'
    }, {
      label: '是否上传数据',
      value: item.uploadData ? '是' : '否',
      key: 'uploadData'
    }, {
      label: '数据类型',
      value: item.dataTypeNames,
      key: 'dataTypeNames'
    }, {
      label: '是否转发数据',
      value: item.forwardDataStr,
      key: 'forwardDataStr'
    }, {
      label: '转发类型',
      value: item.forwardTypeName,
      key: 'forwardTypeName'
    }, {
      label: '转发url',
      value: item.forwardUrl,
      key: 'forwardUrl',
      width: '66.66%'
    }, {
      label: '生产厂商',
      value: item.buildFactory,
      key: 'buildFactory'
    }, {
      label: '厂商联系人',
      value: item.contactPerson,
      key: 'contactPerson'
    }, {
      label: '厂商联系电话',
      value: item.contactPhoneNo,
      key: 'contactPhoneNo'
    }, {
      label: '使用年限（年）',
      value: item.serviceLife,
      key: 'serviceLife'
    }, {
      label: '生效时间',
      value: item.bindEffectFromTime ? "".concat(item.bindEffectFromTime, " - ").concat(item.bindEffectToTime) : '',
      key: 'bindEffectFromTime'
    }, {
      label: '固件类型',
      value: item.hardwareTypeName,
      key: 'hardwareTypeName'
    }];
  });
  return /*#__PURE__*/_jsx(Row, {
    gutter: [16, 16],
    children: deviceList.map(function (item) {
      return /*#__PURE__*/_jsx(Col, {
        span: 24,
        children: /*#__PURE__*/_jsx(VmWrapper, {
          title: item.deviceTypeName,
          children: /*#__PURE__*/_jsx(VmInfoCollection, {
            data: getItem(item),
            gap: 18,
            horizontal: true,
            ellipsis: true,
            width: '33.33%'
          })
        })
      }, item.id);
    })
  });
};
export default DeviceInfo;