import React from "react";
import "./indexBasicInfo.css";
import { Typography, Table, Button } from "antd";

const { Text, Title, Link } = Typography;

class indexBasicInfo extends React.Component {
  constructor(props) {
    super(props);
    // this.title = title[props.location.pathname];
  }
  render() {
    console.log(this.props.location.state);
    const outPutList = this.props.location.state.outputResult;
    const errorList = this.props.location.state.errorResult;
    return (
      <div>
        <Title level={4}>{title[this.props.location.pathname]}</Title>
        <div>
          <Title className="stocks-title" level={5}>
            输入参数：
          </Title>
          <Text>
            method=stock_info&code=股票代码&timestamp=时间戳&sign=签名值
          </Text>
        </div>

        <div>
          <Title className="stocks-title" level={5}>
            输出结果：
          </Title>
          <Table
            columns={columns}
            dataSource={outPutList}
            pagination={false}
            size="small"
          />
        </div>
        <div>
          <Title className="stocks-title" level={5}>
            输出结果异常：
          </Title>
          <Table
            columns={errColumns}
            dataSource={errorList}
            pagination={false}
            size="small"
          />
        </div>

        <div>
          <Title className="stocks-title" level={5}>
            测试地址：
          </Title>
          <Button type="primary" className="stocks-button">
            API测试工具
          </Button>
        </div>
        <div>
          <Title className="stocks-title" level={5}>
            SDK包：
          </Title>
          <Link>php程序包下载</Link>
        </div>
      </div>
    );
  }
}

export default indexBasicInfo;
var title = {
  "/indexBasicInfo": "指数基本信息",
  "/indexNow": "指数当天信息",
  "/indexBefore": "指数回溯"
};
const columns = [
  {
    title: "名称",
    dataIndex: "name",
    key: "name",
    render: (text) => <span>{text}</span>
  },
  {
    title: "说明",
    dataIndex: "desc",
    key: "desc"
  }
];
// var data = [
//   {
//     key: "1",
//     name: "message_code",
//     desc: 200
//   },
//   {
//     key: "2",
//     name: "message",
//     desc: "success"
//   },
//   {
//     key: "3",
//     name: "code",
//     desc: "指数代码"
//   },
//   {
//     key: "4",
//     name: "name",
//     desc: "指数名称"
//   },
//   {
//     key: "5",
//     name: "sector",
//     desc: "交易板块"
//   },
//   {
//     key: "6",
//     name: "sector",
//     desc: "所属市场"
//   }
// ];
const errColumns = [
  {
    title: "错误类型",
    dataIndex: "type",
    key: "type",
    render: (text) => <span>{text}</span>
  },
  {
    title: "message_code",
    dataIndex: "code",
    key: "code"
  },
  {
    title: "message",
    dataIndex: "message",
    key: "message"
  }
];
// var errdata = [
//   {
//     key: "1",
//     type: "股票代码错误",
//     code: 301,
//     message: "股票代码不存在/错误"
//   },
//   {
//     key: "3",
//     type: "签名错误",
//     code: 304,
//     message: "非法签名"
//   },
//   {
//     key: "4",
//     type: "返回数据为空",
//     code: 401,
//     message: "股票数据为空"
//   },
//   {
//     key: "5",
//     type: "服务器错误",
//     code: 501,
//     message: "服务器错误"
//   }
// ];
