import { Col, Row } from 'antd';
import { useContext } from 'react';
import { VmInfoCollection, VmWrapper } from "../../../../_components";
import { MaintenanceService } from "../../../api";
import warn from "../../../imgs/warn.png";
import { CarContext } from "../../../index";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var Maintenance = function Maintenance() {
  var _useContext = useContext(CarContext),
    id = _useContext.id;
  var _MaintenanceService$u = MaintenanceService.useMaintenance(id),
    maintenanceRes = _MaintenanceService$u.maintenanceRes;
  var commercialInsurance = maintenanceRes.commercialInsurance,
    compulsoryInsurance = maintenanceRes.compulsoryInsurance,
    maintainDetail = maintenanceRes.maintainDetail;
  var compulsoryInsuranceList = [{
    key: 'insureDate',
    label: '投保日期',
    value: compulsoryInsurance === null || compulsoryInsurance === void 0 ? void 0 : compulsoryInsurance.insureDate
  }, {
    key: 'price',
    label: '投保金额(元)',
    value: (compulsoryInsurance === null || compulsoryInsurance === void 0 ? void 0 : compulsoryInsurance.price) || 0
  }, {
    key: 'dueDate',
    label: '到期日期',
    value: compulsoryInsurance === null || compulsoryInsurance === void 0 ? void 0 : compulsoryInsurance.dueDate
  }, {
    key: 'remainDays',
    label: '剩余天数',
    value: (compulsoryInsurance === null || compulsoryInsurance === void 0 ? void 0 : compulsoryInsurance.remainDays) || 0,
    render: function render() {
      return /*#__PURE__*/_jsxs("div", {
        className: "car-maintenance-main-item",
        children: [/*#__PURE__*/_jsx("div", {
          className: "car-maintenance-main-item-value",
          children: (compulsoryInsurance === null || compulsoryInsurance === void 0 ? void 0 : compulsoryInsurance.remainDays) || 0
        }), (compulsoryInsurance === null || compulsoryInsurance === void 0 ? void 0 : compulsoryInsurance.remainDays) < 0 && /*#__PURE__*/_jsxs("div", {
          className: "car-maintenance-main-item-warn",
          children: [/*#__PURE__*/_jsx("img", {
            src: warn
          }), "\u5DF2\u8D85\u671F", compulsoryInsurance.remainDays, "\u5929, \u8BF7\u53CA\u65F6\u7EED\u8D39"]
        })]
      });
    }
  }];
  var commercialInsuranceList = [{
    key: 'insureDate',
    label: '投保日期',
    value: commercialInsurance === null || commercialInsurance === void 0 ? void 0 : commercialInsurance.insureDate
  }, {
    key: 'price',
    label: '投保金额(元)',
    value: (commercialInsurance === null || commercialInsurance === void 0 ? void 0 : commercialInsurance.price) || 0
  }, {
    key: 'dueDate',
    label: '到期日期',
    value: commercialInsurance === null || commercialInsurance === void 0 ? void 0 : commercialInsurance.dueDate
  }, {
    key: 'remainDays',
    label: '剩余天数',
    value: (commercialInsurance === null || commercialInsurance === void 0 ? void 0 : commercialInsurance.remainDays) || 0,
    render: function render() {
      return /*#__PURE__*/_jsxs("div", {
        className: "car-maintenance-main-item",
        children: [/*#__PURE__*/_jsx("div", {
          className: "car-maintenance-main-item-value",
          children: (commercialInsurance === null || commercialInsurance === void 0 ? void 0 : commercialInsurance.remainDays) || 0
        }), (commercialInsurance === null || commercialInsurance === void 0 ? void 0 : commercialInsurance.remainDays) < 0 && /*#__PURE__*/_jsxs("div", {
          className: "car-maintenance-main-item-warn",
          children: [/*#__PURE__*/_jsx("img", {
            src: warn
          }), "\u5DF2\u8D85\u671F", commercialInsurance.remainDays, "\u5929, \u8BF7\u53CA\u65F6\u7EED\u8D39"]
        })]
      });
    }
  }];
  var maintainDetailList = [{
    key: 'insureDate',
    label: '年度累计维保次数',
    value: (maintainDetail === null || maintainDetail === void 0 ? void 0 : maintainDetail.yearMaintainCount) || 0
  }, {
    key: 'lastTime',
    label: '最近一次维保时间',
    value: maintainDetail === null || maintainDetail === void 0 ? void 0 : maintainDetail.lastTime
  }, {
    key: 'yearMaintainBudget',
    label: '年度维保预算(元)',
    value: (maintainDetail === null || maintainDetail === void 0 ? void 0 : maintainDetail.yearMaintainBudget) || 0
  }, {
    key: 'yearMaintainPrice',
    label: '年度累计维保金额(元)',
    value: (maintainDetail === null || maintainDetail === void 0 ? void 0 : maintainDetail.yearMaintainPrice) || 0
  }, {
    key: 'surplusBudget',
    label: '剩余预算(元)',
    value: (maintainDetail === null || maintainDetail === void 0 ? void 0 : maintainDetail.surplusBudget) || 0
  }];
  return /*#__PURE__*/_jsxs(Row, {
    align: 'middle',
    justify: 'center',
    gutter: [16, 16],
    children: [/*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '强制险',
        children: /*#__PURE__*/_jsx(VmInfoCollection, {
          data: compulsoryInsuranceList,
          width: '33%',
          horizontal: true
        })
      })
    }), /*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '商业险',
        children: /*#__PURE__*/_jsx(VmInfoCollection, {
          data: commercialInsuranceList,
          width: '33%',
          horizontal: true
        })
      })
    }), /*#__PURE__*/_jsx(Col, {
      span: 24,
      children: /*#__PURE__*/_jsx(VmWrapper, {
        title: '维保记录',
        children: /*#__PURE__*/_jsx(VmInfoCollection, {
          data: maintainDetailList,
          width: '33%',
          horizontal: true
        })
      })
    })]
  });
};
export default Maintenance;