CropFilter.tsx 690 Bytes
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1 2 3
import * as React from 'react';
import { connect } from 'react-redux';

4
import Crop from 'model/genesys/Crop';
Matija Obreza's avatar
Matija Obreza committed
5 6 7 8 9 10 11 12 13 14

import StringArrFilter from 'ui/common/filter/StringArrFilter';

interface IProps extends React.ClassAttributes<any> {
  crops: Crop[];
}

class CropFilter extends React.Component<IProps, any> {

  public render() {
15
    const {crops} = this.props;
Matija Obreza's avatar
Matija Obreza committed
16
    return (
17
      <StringArrFilter name="crop" options={ crops && crops.sort((a, b) => a.name.localeCompare(b.name)) } valueField="shortName" labelField="name" { ...this.props }/>
Matija Obreza's avatar
Matija Obreza committed
18 19 20 21 22
    );
  }
}

export default connect((state) => ({
Viacheslav Pavlov's avatar
Viacheslav Pavlov committed
23
  crops: state.crop.public.list ? state.crop.public.list.data : undefined,
Matija Obreza's avatar
Matija Obreza committed
24
}), null)(CropFilter);