import React, { useEffect } from 'react';
import { Row, Col } from 'antd';
import styles from './index.less';
import Icon from '@/tenants-ui/Icon';
import useMenuList, { menutype } from '@/hooks/useMenuList';
import { history, useModel } from 'umi';

const NavMenu: React.FC = () => {
  const { closeMenu } = useModel('controller');
  const { menuList } = useMenuList();
  //debugger;
  const menuClick = (item: menutype) => {
    closeMenu();
    history.push(`/${item.id}`);
  };
  //   console.log('navMenu');

  return (
    <div className={styles.drawerDiv}>
      <div className={styles.title}>头部</div>
      <div className={styles.menuList}>
        <Row gutter={[20, 20]}>
          {(menuList || []).map((item, index) => {
            return (
              <Col span={8} key={'col' + index}>
                <div
                  className={styles.menuItem}
                  onClick={() => {
                    menuClick(item);
                  }}
                >
                  <Icon className="" type={item.id} style={{ fontSize: 26 }}></Icon>
                  <div className={styles.name}>{item.name}</div>
                </div>
              </Col>
            );
          })}
        </Row>
      </div>
    </div>
  );
};
export default NavMenu;
