SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react';
  2. import { Select } from 'components/Select';
  3. import { IFiltersProps, IFilters } from './type';
  4. // import { FiltersContainer } from './FiltersContainer';
  5.  
  6. import { clear, active } from 'data/filters';
  7.  
  8. import { connect } from 'react-redux';
  9. import { RootState } from 'store';
  10. import { selectors } from 'data/filters';
  11.  
  12. import './Filters.scss';
  13.  
  14. // type Props = IFiltersProps;
  15.  
  16. class FiltersComponent extends Component<IFiltersProps> {
  17.   render() {
  18.     const filters =
  19.       this.props.data &&
  20.       this.props.data.map((item: IFilters, i: number) => {
  21.         return (
  22.           <div className="Filters__content--single" key={i}>
  23.             <label className=" Filters__content--label" htmlFor={`filter${i}`}>
  24.               {item.placeholder}
  25.             </label>
  26.             <Select
  27.               id={i.toString()}
  28.               selectPlaceholder={item.placeholder}
  29.               selectData={item.values}
  30.               // selectActive={this.props.setActive}
  31.             />
  32.           </div>
  33.         );
  34.       });
  35.  
  36.     return (
  37.       <div className="Filters">
  38.         <h3 className="Filters__title">
  39.           Filters
  40.           <span className="Filters__divider" />
  41.           {/* <a onClick={this.props.clearFilters} className="Filters__clear">
  42.             Clear filters
  43.           </a> */}
  44.         </h3>
  45.         <div className="Filters__content">{filters}</div>
  46.       </div>
  47.     );
  48.   }
  49. }
  50.  
  51. // export const Filters = FiltersContainer(FiltersComponent);
  52. const mapDispatchToProps = { clear, active };
  53.  
  54. const mapStateToProps = (state: RootState) => {
  55.   const { data } = selectors(state);
  56.   return {
  57.     data,
  58.   };
  59. };
  60.  
  61. export const Filters = connect(
  62.   mapStateToProps,
  63.   mapDispatchToProps,
  64. )(FiltersComponent);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top