homeflowjs 1.0.2 → 1.0.4
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.
- package/actions/properties.actions.js +23 -4
- package/app/hf-initialize.jsx +1 -1
- package/package.json +1 -1
- package/utils/index.js +12 -1
@@ -3,7 +3,7 @@ import PropertiesActionTypes from './properties.types';
|
|
3
3
|
import { buildQueryString } from '../search/property-search/property-search';
|
4
4
|
import { setSearch } from './search.actions';
|
5
5
|
import { setLoading } from './app.actions';
|
6
|
-
import { getOfflineSavedProperties } from '../utils';
|
6
|
+
import { JSON_to_URLEncoded, getOfflineSavedProperties } from '../utils';
|
7
7
|
|
8
8
|
export const setPropertyLinks = (payload) => ({
|
9
9
|
type: PropertiesActionTypes.SET_PROPERTY_LINKS,
|
@@ -127,19 +127,35 @@ export const postPropertyView = (payload) => () => {
|
|
127
127
|
});
|
128
128
|
};
|
129
129
|
|
130
|
-
export const postBulkPropertyExposureCreation = (payload) => () => {
|
130
|
+
export const postBulkPropertyExposureCreation = (payload, { sendAsFormData } = {}) => () => {
|
131
131
|
const domain = location.hostname;
|
132
132
|
const exposuresPublicUrl = Homeflow.get('exposures_public_url');
|
133
133
|
|
134
134
|
if (!exposuresPublicUrl) return;
|
135
135
|
|
136
136
|
const { propertyIds, eventType } = payload;
|
137
|
+
const data = { property_ids: propertyIds, domain, event_type: eventType };
|
138
|
+
let headers = {};
|
139
|
+
let body;
|
140
|
+
let contentType;
|
141
|
+
if (sendAsFormData) {
|
142
|
+
contentType = { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' };
|
143
|
+
body = JSON_to_URLEncoded(data);
|
144
|
+
} else {
|
145
|
+
contentType = { 'Content-Type': 'application/json' };
|
146
|
+
body = JSON.stringify({ property_ids: propertyIds, domain, event_type: eventType });
|
147
|
+
}
|
148
|
+
|
149
|
+
headers = {
|
150
|
+
...headers,
|
151
|
+
...contentType
|
152
|
+
};
|
137
153
|
fetch(`${exposuresPublicUrl}/create_many`,
|
138
154
|
{
|
139
155
|
method: 'POST',
|
140
156
|
mode: 'no-cors',
|
141
|
-
headers
|
142
|
-
body
|
157
|
+
headers,
|
158
|
+
body,
|
143
159
|
});
|
144
160
|
};
|
145
161
|
|
@@ -149,7 +165,10 @@ export const loadNext = () => (dispatch, getState) => {
|
|
149
165
|
let newProperties = [...getState().properties.properties];
|
150
166
|
const nextPageSearch = { ...getState().search.initialSearch };
|
151
167
|
const currentPageNumber = getState()?.properties?.pagination?.current_page;
|
168
|
+
|
169
|
+
if (nextPageSearch?.place?.place_id) nextPageSearch.placeId = nextPageSearch?.place?.place_id;
|
152
170
|
nextPageSearch.page = currentPageNumber ? currentPageNumber + 1 : 2;
|
171
|
+
|
153
172
|
// conduct search ljson
|
154
173
|
return fetch(`/search.ljson?${buildQueryString(nextPageSearch)}`)
|
155
174
|
.then((response) => response.json())
|
package/app/hf-initialize.jsx
CHANGED
package/package.json
CHANGED
package/utils/index.js
CHANGED
@@ -141,4 +141,15 @@ export const getOfflineSavedProperties = () => {
|
|
141
141
|
return Array.isArray(offlineSavedProperties)
|
142
142
|
? offlineSavedProperties
|
143
143
|
: [];
|
144
|
-
}
|
144
|
+
}
|
145
|
+
|
146
|
+
export function JSON_to_URLEncoded(element,key,list){
|
147
|
+
var list = list || [];
|
148
|
+
if(typeof(element)=='object'){
|
149
|
+
for (var idx in element)
|
150
|
+
JSON_to_URLEncoded(element[idx],key?key+'[]':idx,list);
|
151
|
+
} else {
|
152
|
+
list.push(key+'='+encodeURIComponent(element));
|
153
|
+
}
|
154
|
+
return encodeURI(list.join('&'));
|
155
|
+
}
|