import React, { useMemo, useRef, useCallback, useState } from 'react'
import {Button} from 'antd'
import apis from '@/services/apis'
import AuthButton from '@/components/AuthButton';
// import QueryTable from '@/components/QueryTable'
import TableList from '@/components/TableList'
import getTableColumns from './tableColumns'
import { router } from 'umi';

export default (props) => {
  const ref = useRef()
  const [page, setPage] = useState({current: 1, pageSize: 10})
  const toEdit = useCallback((row) => {
    //
    router.push({
      pathname: '/building/Developers/Edit',
      query: {
        id: row?.id || undefined,
      },
    });
  }, [])

  const onDelete = useCallback((row) => {

  }, [])


  const tableColumns = useMemo(() => {
    return getTableColumns({
      page,
      onEdit:(e)=>toEdit(e),
      onDelete,
    })
  }, [page])

  const actionRender = () => {
    return (
      <AuthButton name="admin.tdBuildingType.add" noRight={null}>
        <Button type="primary" icon="plus" onClick={() => toEdit()} >
          新增
        </Button>
      </AuthButton>
    );
  };

  return (
    <>
      <TableList
        rowKey="buildingId"
        api={apis.building.getList}
        columns={tableColumns}
        actionRender={actionRender}
      />
    </>
  )
}
