import React, { useState, useEffect } from 'react';
import mapstyles from '@/assets/css/map.less';
import { getMapList } from '@/services/ant-design-pro/environment';
import cx from 'classnames';

type MapProps = {
  //mapList: API.MapInfo[];
  type: string;
  render: (item: API.MapInfo, index: number) => React.ReactNode;
};

const Map: React.FC<MapProps> = ({ type, render }) => {
  const [mapList, setMapList] = useState<API.MapInfo[]>([]);
  useEffect(() => {
    getMapList({ floorId: 'sffsdfdsfdf', floorNumber: 22 }).then(function (res) {
      var data: API.MapInfo[] = res.data || [];
      setMapList(data);
    });
  }, []);
  return (
    <div className={cx(mapstyles.map, { [mapstyles.equipmentMap]: type == 'equipment' })}>
      {mapList.map(function (item, index) {
        return render(item, index);
      })}
    </div>
  );
};
export default Map;
