import {FilterButtonGroup, FilterField} from '@components';
import {Card, Row} from 'antd';
import {FC} from 'react';
import {useExport, useField, useSearch} from './hooks';
import {useTableSearch} from '@hooks';
import {searchContext} from '../context';

const Filter: FC = function() {
  const [value, onChange] = useField();
  const onSearch = useSearch(value);
  const [isExporting, onExport] = useExport();
  const [isSearching] = useTableSearch(searchContext);

  return (
    <Card>
      <Row>
        <FilterField name='roleName' label='角色名称' value={value} onChange={onChange} />
        <FilterButtonGroup
          isSearching={isSearching}
          isExporting={isExporting}
          onSearch={onSearch}
          onExport={onExport}
          offset={12}
        />
      </Row>
    </Card>
  );
};

export default Filter;
