homeflowjs 1.0.22 → 1.0.24
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/app/hf-initialize.jsx +0 -1
- package/app/user-history.js +13 -1
- package/package.json +1 -1
- package/properties/back-to-search-button/back-to-search-button.component.jsx +17 -4
- package/properties/properties-display/properties-display.component.jsx +6 -2
- package/search/property-search/parse-fragment.js +10 -2
- package/search/property-search/property-search.js +2 -0
package/app/hf-initialize.jsx
CHANGED
package/app/user-history.js
CHANGED
@@ -40,4 +40,16 @@ export const updateLastSearchPageInLocalStorage = (change) => {
|
|
40
40
|
searchHistory = searchHistory ? JSON.parse(searchHistory) : [];
|
41
41
|
searchHistory[0].page = (searchHistory[0].page ? +searchHistory[0].page : 1) + change;
|
42
42
|
localStorage.setItem('searchHistory', JSON.stringify(searchHistory));
|
43
|
-
};
|
43
|
+
};
|
44
|
+
|
45
|
+
export const updateLastSearchOnPropertyCardClick = (propertyID) => {
|
46
|
+
// Get search history from local storage
|
47
|
+
let searchHistory = localStorage.getItem('searchHistory');
|
48
|
+
searchHistory = searchHistory ? JSON.parse(searchHistory) : [];
|
49
|
+
|
50
|
+
if (searchHistory?.length === 0) return null;
|
51
|
+
|
52
|
+
// Add property about to be visited to the search object in local storage
|
53
|
+
const newSearchHistory = searchHistory.map((search, index) => index === 0 ? {...search, clickedProperty: propertyID } : search);
|
54
|
+
localStorage.setItem('searchHistory', JSON.stringify(newSearchHistory));
|
55
|
+
}
|
package/package.json
CHANGED
@@ -6,10 +6,23 @@ const BackToSearchButton = ({ children, ...otherProps }) => {
|
|
6
6
|
const searchHistory = localStorage.getItem('searchHistory');
|
7
7
|
if (!searchHistory) return null;
|
8
8
|
|
9
|
-
const lastSearch = JSON.parse(searchHistory)[0];
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
const lastSearch = JSON.parse(searchHistory)?.[0];
|
10
|
+
const secondToLastSearch = JSON.parse(searchHistory)?.[1] || null;
|
11
|
+
|
12
|
+
|
13
|
+
let validSearch = lastSearch;
|
14
|
+
|
15
|
+
if (secondToLastSearch) {
|
16
|
+
const property = Homeflow.get('property');
|
17
|
+
const currentPropertyID = property?.propertyId || property?.property_id;
|
18
|
+
|
19
|
+
if (currentPropertyID === secondToLastSearch?.clickedProperty) validSearch = secondToLastSearch;
|
20
|
+
}
|
21
|
+
|
22
|
+
// delete the 'place' so we don't get [object Object] in URL if place is found in object.
|
23
|
+
if (validSearch?.place) delete validSearch.place;
|
24
|
+
|
25
|
+
const href = `/search?${buildQueryString(validSearch)}`;
|
13
26
|
|
14
27
|
return (
|
15
28
|
<a href={href} {...otherProps}>
|
@@ -4,6 +4,7 @@ import PropTypes from 'prop-types';
|
|
4
4
|
|
5
5
|
import { propertiesByPage, updatePageInURL } from '../property-utils/property-utils';
|
6
6
|
import { usePropertyInfiniteScroll, useLoadPreviousProperties } from '../../hooks';
|
7
|
+
import { updateLastSearchOnPropertyCardClick } from '../../app/user-history.js';
|
7
8
|
|
8
9
|
const ConditionalWrapper = ({ condition, wrapper, children }) => (
|
9
10
|
condition ? wrapper(children) : children
|
@@ -37,6 +38,8 @@ const PropertiesDisplay = ({
|
|
37
38
|
loadingProperties: loadingPreviousProperties,
|
38
39
|
} = useLoadPreviousProperties();
|
39
40
|
|
41
|
+
const visitPropertyUpdate = (id) => updateLastSearchOnPropertyCardClick(id);
|
42
|
+
|
40
43
|
useEffect(() => {
|
41
44
|
const pageMarkers = document.querySelectorAll('[data-page-marker]');
|
42
45
|
|
@@ -114,7 +117,7 @@ const PropertiesDisplay = ({
|
|
114
117
|
return (
|
115
118
|
<React.Fragment key={property.property_id}>
|
116
119
|
{inserts[0].component}
|
117
|
-
<Item property={property} {...other} />
|
120
|
+
<Item property={property} onClick={() => visitPropertyUpdate(property.property_id)} {...other} />
|
118
121
|
</React.Fragment>
|
119
122
|
);
|
120
123
|
} else if (
|
@@ -126,7 +129,7 @@ const PropertiesDisplay = ({
|
|
126
129
|
return (
|
127
130
|
<React.Fragment key={property.property_id}>
|
128
131
|
{findResult.component}
|
129
|
-
<Item property={property} {...other} />
|
132
|
+
<Item property={property} onClick={() => visitPropertyUpdate(property.property_id)} {...other} />
|
130
133
|
</React.Fragment>
|
131
134
|
);
|
132
135
|
}
|
@@ -135,6 +138,7 @@ const PropertiesDisplay = ({
|
|
135
138
|
return (
|
136
139
|
<Item
|
137
140
|
key={property.property_id}
|
141
|
+
onClick={() => visitPropertyUpdate(property.property_id)}
|
138
142
|
property={property}
|
139
143
|
data-page-marker={!addWrapper && index === 0 ? page[0].resultPage : null}
|
140
144
|
{...other}
|
@@ -21,12 +21,20 @@ export default (fragment) => {
|
|
21
21
|
parts.forEach((part) => {
|
22
22
|
if (!part) return;
|
23
23
|
|
24
|
-
if (part === 'sales'
|
24
|
+
if (part === 'sales'
|
25
|
+
|| part === 'all-property-for-sale'
|
26
|
+
|| part === 'property-for-sale'
|
27
|
+
|| part === 'properties-for-sale'
|
28
|
+
) {
|
25
29
|
search.channel = 'sales';
|
26
30
|
return;
|
27
31
|
}
|
28
32
|
|
29
|
-
if (part === 'lettings'
|
33
|
+
if (part === 'lettings'
|
34
|
+
|| part === 'all-property-for-rent'
|
35
|
+
|| part === 'property-for-rent'
|
36
|
+
|| part === 'properties-to-rent'
|
37
|
+
) {
|
30
38
|
search.channel = 'lettings';
|
31
39
|
return;
|
32
40
|
}
|
@@ -28,6 +28,8 @@ export const buildQueryString = (search) => {
|
|
28
28
|
Object.keys(search).forEach((key) => {
|
29
29
|
const value = search[key];
|
30
30
|
|
31
|
+
if (key === 'clickedProperty') return;
|
32
|
+
|
31
33
|
if (key === 'pets' && value) return fragmentParams.push('pets');
|
32
34
|
|
33
35
|
if (minOrMaxBedZero(key, value)) return fragmentParams.push(fragmentize(key, value));
|