import React , { useEffect , useState } from 'react';
import { Menu } from 'antd';
import { Link } from 'react-router-dom';
import Base from './Base';
import Password from './Password';
import './Index.scss';
import '../../SecuritySetting/notice/manager/Index.scss';

function Index(props){
  // const { username } = props && props.match && props.match.params;
  const { pathname } = props && props.location;
  // const { current_user } = props;


  const [ key , setKey ] = useState("0");

  useEffect(()=>{
    if(pathname){
      if(pathname === `/settings/profile`){
        setKey("0");
      }else{
        setKey("1");
      }
    }
  },[pathname])


  return(
    <div className="notice01">
      <div className="sshHead">
        <Menu selectedKeys={[key]} mode={'horizontal'} className="infosRightMenu">
          <Menu.Item key="0"><Link to={`/settings/profile`}>基本资料</Link></Menu.Item>
          {/* <Menu.Item key="0"><Link to={`/settings/profile`}>基本资料</Link></Menu.Item> */}
          {/* <Menu.Item key="1"><Link to={`/${username}/password`}>密码管理</Link></Menu.Item> */}
        </Menu>
      </div>
      <div style={{padding:"20px"}}>
        {
          key === "0" ?
          <Base {...props}/>
          :
          <Password {...props}/>
        }
        
      </div>
    </div>
  )
}
export default Index;