import {Col, Space, Button} from 'antd';
import {CSSProperties, FC} from 'react';

type Props = {
  offset?: number;
  disableAlign?: boolean;
  onSearch: () => void;
  onExport?: () => void;
  searchTestId?: string;
  isSearching?: boolean;
  isExporting?: boolean;
};

const colStyle: CSSProperties = {textAlign: 'right'};

const FiterButtonGroup: FC<Props> = function({
  onSearch,
  onExport,
  offset,
  disableAlign,
  searchTestId,
  isSearching,
  isExporting,
}) {
  return (
    <>
      <Col span={6} style={disableAlign ? void 0 : colStyle} offset={offset}>
        <Space>
          <Button
            loading={isSearching}
            type='primary'
            onClick={onSearch}
            data-testid={searchTestId ?? 'search_btn'}
          >
            查询
          </Button>
          {onExport && <Button
            data-testid='export_btn'
            loading={isExporting}
            type='default'
            onClick={onExport}
          >
            导出
          </Button>}
        </Space>
      </Col>
    </>
  );
};

export default FiterButtonGroup;
