import algoliasearch from 'algoliasearch/lite';
import {
InstantSearch,
ClearRefinements,
SearchBox,
Pagination,
Highlight,
Configure,
connectHits,
connectNumericMenu,
connectRefinementList,
connectRange,
} from 'react-instantsearch-dom';
import {
GoogleMapsLoader,
GeoSearch,
Marker,
} from 'react-instantsearch-dom-maps';
import PropTypes from 'prop-types';
import React, { Component, Fragment } from 'react';
import Rheostat from 'rheostat';
import withURLSync from './URLSync';
import './App.css';
const searchClient = algoliasearch(
'latency',
'6be0576ff61c053d5f9a3225e2a90f76'
);
const App = (props) => (
);
function Header() {
return (
);
}
function Filters() {
return (
{(google) => (
{({ hits }) => (
{hits.map((hit) => (
))}
items.filter((item) => item.id === 'boundingBox')
}
translations={{
reset: 'Clear the map refinement',
}}
/>
)}
)}
);
}
function Capacity() {
return (
);
}
function OptionCapacity({ label, value }) {
return ;
}
OptionCapacity.propTypes = {
label: PropTypes.string,
value: PropTypes.string,
};
const CapacitySelector = connectNumericMenu(
({ items, currentRefinement, refine }) => {
const selectValue = (e) => refine(e.target.value);
const options = items.map((item) => (
));
return (
);
}
);
function DatesAndGuest() {
return (
);
}
const RoomType = connectRefinementList(({ items, refine }) => {
const sortedItems = items.sort((i1, i2) => i1.label.localeCompare(i2.label));
const hitComponents = sortedItems.map((item) => {
const selectedClassName = item.isRefined
? ' ais-refinement-list--item__active'
: '';
const itemClassName = `ais-refinement-list--item col-sm-3 ${selectedClassName}`;
return (
);
});
return (
Room Type
{hitComponents}
);
});
function Price() {
return (
);
}
const MyHits = connectHits(({ hits }) => {
const hs = hits.map((hit) => );
return {hs}
;
});
function HitComponent({ hit }) {
return (
);
}
function HitDescription({ hit }) {
return (
{hit.room_type} - ,{' '}
);
}
HitComponent.propTypes = {
hit: PropTypes.object,
};
function Results() {
return (
);
}
class Range extends Component {
static propTypes = {
min: PropTypes.number,
max: PropTypes.number,
currentRefinement: PropTypes.object,
refine: PropTypes.func.isRequired,
canRefine: PropTypes.bool.isRequired,
};
state = { currentValues: { min: this.props.min, max: this.props.max } };
componentDidUpdate(prevProps) {
if (
this.props.canRefine &&
(prevProps.currentRefinement.min !== this.props.currentRefinement.min ||
prevProps.currentRefinement.max !== this.props.currentRefinement.max)
) {
this.setState({
currentValues: {
min: this.props.currentRefinement.min,
max: this.props.currentRefinement.max,
},
});
}
}
onValuesUpdated = (sliderState) => {
this.setState({
currentValues: { min: sliderState.values[0], max: sliderState.values[1] },
});
};
onChange = (sliderState) => {
if (
this.props.currentRefinement.min !== sliderState.values[0] ||
this.props.currentRefinement.max !== sliderState.values[1]
) {
this.props.refine({
min: sliderState.values[0],
max: sliderState.values[1],
});
}
};
render() {
const { min, max, currentRefinement } = this.props;
const { currentValues } = this.state;
return min !== max ? (
{currentValues.min}
{currentValues.max}
) : null;
}
}
const ConnectedRange = connectRange(Range);
export default withURLSync(App);