import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Descriptions, Divider } from "antd";
import { useEffect, useState } from "react";
import useDictionary from "zy-react-library/hooks/useDictionary";
import { getLabelName } from "zy-react-library/utils";
import { NS_BI_MARK_INFO } from "~/enumerate/namespace";

const FireWaterSource = (props) => {
  const { getDictionary } = useDictionary();

  const [info, setInfo] = useState({});

  const getData = async () => {
    const { data } = await props.fireWaterSourceInfo({ id: props.id });
    const dictionaryData = await getDictionary({ dictValue: "fire_resource_water_type" });

    setInfo({
      ...data,
      waterSourceStatusName: getLabelName({
        list: dictionaryData,
        status: data.waterSourceStatus,
        idKey: "dictValue",
        nameKey: "dictLabel",
      }),
    });
  };

  useEffect(() => {
    getData();
  }, []);

  return (
    <div>
      <Divider titlePlacement="start">基本信息</Divider>
      <Descriptions
        bordered
        column={1}
        items={[
          { label: "消防水源名称", children: info.waterSourceName },
          { label: "消防水源状态", children: info.waterSourceStatusName },
          { label: "经度", children: info.lng },
          { label: "纬度", children: info.lat },
          { label: "水源位置", children: info.waterLocation },
          { label: "所属单位或部门", children: info.belongOrgDept },
          { label: "接口形式", children: info.interfaceForm },
          { label: "水源类型", children: info.waterType },
          { label: "水源编号", children: info.waterCode },
          { label: "吸水口规格", children: info.suctionSpec },
          { label: "水源容量", children: info.capacity },
          { label: "供水能力", children: info.supplyAbility },
          { label: "设备清单", children: info.equipmentList },
        ]}
      />
    </div>
  );
};

export default Connect([NS_BI_MARK_INFO], true)(FireWaterSource);
