import React from 'react';
import { Button, Row } from 'antd';

export interface IFilterProps {
  value: (string | number)[];
  options?: string[];
  map?: any;
  onClick: (value: string) => void;
}

export default ({value, options, map, onClick}: IFilterProps) => {
  if (!Array.isArray(options)) return null;
  return (
    <Row style={{
      marginBottom: 10
    }}>
      {
        options.map(item => {
          return (
            <Button key={item} type={value.includes(item) ? 'primary' : 'default'} onClick={() => {
              onClick(item);
            }} style={{
              marginRight: 10,
              marginBottom: 10
            }}>{map?.[item] || item}</Button>
          )
        })
      }
    </Row>
  )
}