Filters.tsx 1.78 KB
Newer Older
Matija Obreza's avatar
Subsets  
Matija Obreza committed
1 2 3
import * as React from 'react';
import { reduxForm } from 'redux-form';

4
import { SUBSET_FILTERFORM } from 'subsets/constants';
Matija Obreza's avatar
Subsets  
Matija Obreza committed
5 6 7 8 9

import FiltersBlock from 'ui/common/filter/FiltersBlock';
import CollapsibleComponentSearch from 'ui/common/filter/CollapsibleComponentSearch';
import StringFilter from 'ui/common/filter/StringFilter';
import StringArrFilter from 'ui/common/filter/StringArrFilter';
10
import CropFilter from 'crop/ui/c/CropFilter';
11
import PartnerFilter from 'partners/ui/c/PartnerFilter';
Matija Obreza's avatar
Subsets  
Matija Obreza committed
12

Viacheslav Pavlov's avatar
i18n  
Viacheslav Pavlov committed
13
const SubsetFilters = ({handleSubmit, initialValues, initialize, t, ...other}) => {
Matija Obreza's avatar
Subsets  
Matija Obreza committed
14 15
  // console.log('SubsetFilters', initialValues);
  return (
Viacheslav Pavlov's avatar
i18n  
Viacheslav Pavlov committed
16
    <FiltersBlock title={ t('subsets.public.f.filterTitle') } handleSubmit={ handleSubmit } initialize={ initialize } { ...other }>
17 18 19 20
      <CollapsibleComponentSearch title={ t('subsets.public.f.partner') }>
        <StringArrFilter name="institutes" label={ t('subsets.public.f.institute') } placeholder={ t('subsets.public.f.institutePlaceholder') }/>
        <PartnerFilter name="owner" label="subsets.public.f.partner"/>
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n  
Viacheslav Pavlov committed
21 22 23
      <CollapsibleComponentSearch title={ t('subsets.public.f.textSearch') }>
        <StringFilter name="title" searchType="contains" label={ t('subsets.public.f.title') } placeholder={ t('subsets.public.f.titlePlaceholder') }/>
        <StringFilter name="description" searchType="contains" label={ t('subsets.public.f.description') } placeholder={ t('subsets.public.f.descriptionPlaceholder') }/>
Matija Obreza's avatar
Subsets  
Matija Obreza committed
24
      </CollapsibleComponentSearch>
Viacheslav Pavlov's avatar
i18n  
Viacheslav Pavlov committed
25
      <CollapsibleComponentSearch title={ t('subsets.public.f.crop') }>
26
          <CropFilter name="crops" />
Matija Obreza's avatar
Matija Obreza committed
27
      </CollapsibleComponentSearch>
Matija Obreza's avatar
Subsets  
Matija Obreza committed
28 29 30 31 32 33 34 35
    </FiltersBlock>
  );
};

export default reduxForm({
    enableReinitialize: true,
    form: SUBSET_FILTERFORM,
})(SubsetFilters);