import React, { FC } from "react";
import clientApi from "@/package/SimpleTrade/api/client";
import MyTable from "@/components/MyTable";
import { Input } from "antd";
import { getTime, splitAddress } from "@/utils";

const RechargeRecord: FC = () => {
  const columns = [
    {
      title: '用户ID',
      dataIndex: 'user_id'
    },
    {
      title: 'from地址',
      dataIndex: 'from_address',
      render: (_val) => (<div>{splitAddress(_val)}</div>)
    },
    {
      title: 'to地址',
      dataIndex: 'to_address',
      render: (_val) => (<div>{splitAddress(_val)}</div>)
    },
    {
      title: '链ID',
      dataIndex: 'chain_id'
    },
    {
      title: '区块高度',
      dataIndex: 'block_height'
    },
    {
      title: '数量',
      dataIndex: 'balance_real'
    },
    {
      title: '币种',
      dataIndex: 'symbol'
    },
    {
      title: '时间',
      dataIndex: 'create_time',
      render: (_time) => (<div>{getTime(_time * 1000)}</div>)
    }
  ]

  // 搜索栏配置项
  const searchConfigList = [
    {
      key: 'name',
      slot: <Input placeholder="用户名" allowClear />,
      initialValue: ''
    }
  ]

  return (
    <div>
      <MyTable
        columns={columns}
        apiFun={clientApi.recharge_list}
        searchConfigList={searchConfigList}
        rowKey="ID"
      />
    </div>
  )
};

export default RechargeRecord;