import React from "react"; import { formatFilterNumber } from "../lib/helpers"; import { CATEGORY_FLAT, CATEGORY_HOUSE, CATEGORY_OFFICE, CATEGORY_LAND } from '../../crawler/enums'; export default class Filters extends React.Component { onCloseClick(e) { if (this.props.onClose) { this.props.onClose(); } } onMaxPriceChange(e) { this.props.dispatch({ type: "SET_MAX_PRICE", action: { maxPrice: e.target.value } }); } onMinPriceChange(e) { this.props.dispatch({ type: "SET_MIN_PRICE", action: { minPrice: e.target.value } }); } onMaxSizeChange(e) { this.props.dispatch({ type: "SET_MAX_SIZE", action: { maxSize: e.target.value } }); } onMinSizeChange(e) { this.props.dispatch({ type: "SET_MIN_SIZE", action: { minSize: e.target.value } }); } onRoomsClick(rooms) { this.props.dispatch({type: 'SET_ROOMS', action: {rooms}}); } onCategoryClick(category) { this.props.dispatch({type: 'SET_CATEGORY', action: {category}}); } onRefreshClick() { this.updateSearch(); } onKeyPress (e) { if (e.key === 'Enter') { this.updateSearch(); } } updateSearch () { this.props.dispatch({ type: "UPDATE_SEARCH" }); } render() { const { filters } = this.props; const selectedRooms = val => filters.rooms[val] ? "selected" : ""; const selectedCategory = val => filters.category[val] ? "selected": ""; return (