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

const Filter: FC = function() {
  const [value, onChange] = useField();
  const onSearch = useSearch(value);
  const [isExporting, onExport] = useExport();
  const isSearching = useContextSection(context, state => state[0].isSearching);

  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;
