-
Notifications
You must be signed in to change notification settings - Fork 468
/
multidropdownrange.js
85 lines (76 loc) · 1.77 KB
/
multidropdownrange.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import React, { Component } from 'react';
import {
ReactiveBase,
MultiDropdownRange,
SelectedFilters,
ReactiveList,
} from '@appbaseio/reactivesearch';
import PropTypes from 'prop-types';
import initReactivesearch from '@appbaseio/reactivesearch/lib/server';
import Layout from '../components/Layout';
import BookCard from '../components/BookCard';
const settings = {
app: 'good-books-ds',
credentials: 'nY6NNTZZ6:27b76b9f-18ea-456c-bc5e-3a5263ebc63d',
};
const multiDropdownRangeProps = {
componentId: 'BookSensor',
dataField: 'average_rating',
data: [
{ start: 0, end: 3, label: 'Rating < 3' },
{ start: 3, end: 4, label: 'Rating 3 to 4' },
{ start: 4, end: 5, label: 'Rating > 4' },
],
defaultValue: ['Rating < 3', 'Rating > 4'],
};
const reactiveListProps = {
componentId: 'SearchResult',
dataField: 'original_title.raw',
from: 0,
size: 10,
renderItem: data => <BookCard key={data._id} data={data} />,
react: {
and: ['BookSensor'],
},
};
export default class Main extends Component {
static async getInitialProps() {
return {
store: await initReactivesearch(
[
{
...multiDropdownRangeProps,
source: MultiDropdownRange,
},
{
...reactiveListProps,
source: ReactiveList,
},
],
null,
settings,
),
};
}
render() {
return (
<Layout title="SSR | MultiDropdownRange">
<ReactiveBase {...settings} initialState={this.props.store}>
<div className="row">
<div className="col">
<MultiDropdownRange {...multiDropdownRangeProps} />
</div>
<div className="col">
<SelectedFilters />
<ReactiveList {...reactiveListProps} />
</div>
</div>
</ReactiveBase>
</Layout>
);
}
}
Main.propTypes = {
// eslint-disable-next-line
store: PropTypes.object,
};