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

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

  return (
    <Card>
      <Row>
        <FilterField name='goodsCode' label='品号' value={value} onChange={onChange} />
        <FilterButtonGroup
          isExporting={isExporting}
          isSearching={isSearching}
          onSearch={onSearch}
          onExport={onExport}
          offset={12}
        />
      </Row>
    </Card>
  );
};

export default Filter;
