import { Input, Button } from 'antd'

import type { GetExamplesParams, PagingRequest } from 'api'

type ListHeaderProps = {
  onBeforeCreate?: () => void,
  onSearch: (params: (GetExamplesParams extends PagingRequest<infer T> ? T: never)) => void
}

export const ExampleHeader = ({ onSearch, onBeforeCreate }: ListHeaderProps) => {
  return (
    <div className='content-header'>
      <Button type="primary" children="创建案件" onClick={onBeforeCreate} />
      <Input.Search
        allowClear
        className='content-header-search'
        placeholder="输入名称搜索" 
        onSearch={caseTitle => onSearch({ caseTitle }) }
        style={{ width: 264 }} 
      />
    </div>
  )
}