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

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

  return (
    <Card>
      <Row>
        <FilterField name='childMenuName' label='菜单名称' value={value} onChange={onChange} />
        <FilterButtonGroup
          isSearching={isSearching}
          onSearch={onSearch}
          offset={12}
          searchTestId='child_menu_search_btn'
        />
      </Row>
    </Card>
  );
};

export default Filter;
