homeflowjs 0.12.19 → 0.12.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -151,6 +151,28 @@ export const loadNext = () => (dispatch, getState) => {
|
|
151
151
|
});
|
152
152
|
};
|
153
153
|
|
154
|
+
export const loadPage = (payload) => (dispatch, getState) => {
|
155
|
+
dispatch(setLoading({ properties: true }));
|
156
|
+
// set page on search to page + 1
|
157
|
+
let newProperties = [...getState().properties.properties];
|
158
|
+
const newSearch = { ...getState().search.currentSearch };
|
159
|
+
newSearch.page = payload;
|
160
|
+
// conduct search ljson
|
161
|
+
return fetch(`/search.ljson?${buildQueryString(newSearch)}`)
|
162
|
+
.then((response) => response.json())
|
163
|
+
.then((json) => {
|
164
|
+
if (json.properties) {
|
165
|
+
// add the page number to each new property for dividing properties into per-page divs
|
166
|
+
const addedProperties = json.properties.map((property) => (
|
167
|
+
{ ...property, resultPage: newSearch.page }
|
168
|
+
));
|
169
|
+
newProperties = [...addedProperties, ...newProperties];
|
170
|
+
dispatch(setProperties(newProperties));
|
171
|
+
dispatch(setLoading({ properties: false }));
|
172
|
+
}
|
173
|
+
});
|
174
|
+
};
|
175
|
+
|
154
176
|
export const toggleSavedProperty = (payload) => ({
|
155
177
|
type: PropertiesActionTypes.TOGGLE_SAVED_PROPERTY,
|
156
178
|
payload,
|
package/package.json
CHANGED
@@ -93,9 +93,20 @@ class LocationInput extends Component {
|
|
93
93
|
return suggestion.label;
|
94
94
|
}
|
95
95
|
|
96
|
+
onClearButtonClick() {
|
97
|
+
const { setSuggestions, setSearchField } = this.props;
|
98
|
+
setSuggestions([]);
|
99
|
+
setSearchField({ q: '' });
|
100
|
+
}
|
101
|
+
|
96
102
|
render() {
|
97
103
|
const {
|
98
|
-
suggestions,
|
104
|
+
suggestions,
|
105
|
+
search: { q = '' },
|
106
|
+
className,
|
107
|
+
placeholder,
|
108
|
+
clearButton,
|
109
|
+
clearButtonClassName,
|
99
110
|
} = this.props;
|
100
111
|
|
101
112
|
const inputProps = {
|
@@ -105,23 +116,34 @@ class LocationInput extends Component {
|
|
105
116
|
};
|
106
117
|
|
107
118
|
return (
|
108
|
-
<
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
119
|
+
<div>
|
120
|
+
<Autosuggest
|
121
|
+
value={q}
|
122
|
+
suggestions={suggestions}
|
123
|
+
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested.bind(this)}
|
124
|
+
onSuggestionsClearRequested={this.onSuggestionsClearRequested.bind(this)}
|
125
|
+
getSuggestionValue={this.getSuggestionValue.bind(this)}
|
126
|
+
renderSuggestion={this.renderSuggestion.bind(this)}
|
127
|
+
inputProps={{
|
128
|
+
...inputProps,
|
129
|
+
className,
|
130
|
+
'data-testid': 'location-input',
|
131
|
+
id: 'search-location-input',
|
132
|
+
name: 'Location search',
|
133
|
+
}}
|
134
|
+
containerProps={{ 'data-testid': 'suggestions' }}
|
135
|
+
theme={autosuggestTheme}
|
136
|
+
/>
|
137
|
+
{(clearButton && q) && (
|
138
|
+
<button
|
139
|
+
className={clearButtonClassName}
|
140
|
+
type="reset"
|
141
|
+
onClick={this.onClearButtonClick.bind(this)}
|
142
|
+
>
|
143
|
+
×
|
144
|
+
</button>
|
145
|
+
)}
|
146
|
+
</div>
|
125
147
|
);
|
126
148
|
}
|
127
149
|
}
|
@@ -134,6 +156,8 @@ LocationInput.propTypes = {
|
|
134
156
|
className: PropTypes.string,
|
135
157
|
search: PropTypes.object.isRequired,
|
136
158
|
searchOnSelection: PropTypes.bool,
|
159
|
+
clearButton: PropTypes.bool,
|
160
|
+
clearButtonClassName: PropTypes.string,
|
137
161
|
};
|
138
162
|
|
139
163
|
LocationInput.defaultProps = {
|
@@ -141,6 +165,8 @@ LocationInput.defaultProps = {
|
|
141
165
|
className: '',
|
142
166
|
suggestions: [],
|
143
167
|
searchOnSelection: false,
|
168
|
+
clearButton: false,
|
169
|
+
clearButtonClassName: '',
|
144
170
|
};
|
145
171
|
|
146
172
|
const mapStateToProps = (state) => ({
|