import {useContextSection, useQueryTableList} from '@hooks';
import {FC} from 'react';
import {context, pageContext, searchContext} from '../context';
import {getOtherIn} from '@apis';
import {Card} from 'antd';
import {useColumns} from './hooks';
import {Table, TableTools} from '@components';

const TableList: FC = function () {
  const params = useContextSection(context, state => state[0]);
  const [{data, count}, {refetch}] = useQueryTableList({
    queryFn: getOtherIn,
    pageContext,
    params,
    searchContext,
  });
  const columns = useColumns(refetch);

  return (
    <Card className='table-wrapper'>
      <TableTools pageContext={pageContext} searchContext={searchContext} />

      <Table
        data={data}
        count={count}
        pageContext={pageContext}
        searchContext={searchContext}
        columns={columns}
        data-testid='other_in_table'
      />
    </Card>
  );
};

export default TableList;
