import React from 'react';
import { Button } from 'antd';
// import { addWiki } from '../api';
import './index.scss';

export default ({ project, isManager, history, showNotification, match, reloadList }) => {

  let projectsId = match.params.projectsId;
  let owner = match.params.owner;

  // function addFile() {
  //   addWiki({
  //     owner,
  //     repo: projectsId,
  //     pagename: 'Home',
  //     name: 'Home',
  //     content: 'Welcome to the wiki!',
  //     commit_message: '',
  //   }).then(res => {
  //     if (res.message === "200") {
  //       reloadList(Math.random());
  //       showNotification("创建成功");
  //     } else {
  //       showNotification("创建失败");
  //     }
  //   });
  // }

  function addFile() {
    history.push(`/${owner}/${projectsId}/wiki/add`);
  }

  return (
    <div className="welcome-main">
      <i className="iconfont icon-huanying_icon" ></i>
      <p className="welcome-title">欢迎使用&nbsp;
        <span className="wiki-title">
          {project && project.name}
        </span>
        &nbsp;Wiki</p>
      <p className="welcome-content">Wiki主要是您项目的产品设计、文档描述、注释等等</p>
      <div className="wiki-line"></div>

      {
        isManager ? <Button type="primary" onClick={addFile}>创建Wiki文档</Button>
          : <p className="welcome-des">该项目暂时没有创建Wiki</p>
      }
    </div>
  )
}