homeflowjs 1.0.32 → 1.0.34
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/package.json +1 -1
- package/properties/back-to-search-button/back-to-search-button.component.jsx +9 -6
- package/properties/index.js +2 -0
- package/properties/properties-display/properties-display.component.jsx +1 -1
- package/properties/property-results-pagination/property-results-pagination-item.component.jsx +73 -0
- package/properties/property-results-pagination/property-results-pagination.component.jsx +151 -0
- package/properties/property-results-pagination/property-results-pagination.styles.scss +68 -0
- package/search/property-search/property-search.js +2 -1
- package/shared/chevron-left-icon.jsx +23 -0
- package/shared/chevron-right-icon.jsx +23 -0
package/package.json
CHANGED
@@ -9,19 +9,22 @@ const BackToSearchButton = ({ children, ...otherProps }) => {
|
|
9
9
|
const lastSearch = JSON.parse(searchHistory)?.[0];
|
10
10
|
const secondToLastSearch = JSON.parse(searchHistory)?.[1] || null;
|
11
11
|
|
12
|
-
|
13
12
|
let validSearch = lastSearch;
|
14
13
|
|
15
14
|
if (secondToLastSearch) {
|
16
|
-
const property =
|
15
|
+
const property = Homeflow.get('property');
|
17
16
|
const currentPropertyID = property?.propertyId || property?.property_id;
|
18
17
|
|
19
|
-
if (currentPropertyID === secondToLastSearch?.clickedProperty)
|
18
|
+
if (currentPropertyID === secondToLastSearch?.clickedProperty) {
|
19
|
+
if ('expandedPolygon' in secondToLastSearch) {
|
20
|
+
const thirdToLastSearch = JSON.parse(searchHistory)?.[2] || null;
|
21
|
+
validSearch = thirdToLastSearch;
|
22
|
+
} else {
|
23
|
+
validSearch = secondToLastSearch;
|
24
|
+
}
|
25
|
+
}
|
20
26
|
}
|
21
27
|
|
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
28
|
const href = `/search?${buildQueryString(validSearch)}`;
|
26
29
|
|
27
30
|
return (
|
package/properties/index.js
CHANGED
@@ -10,6 +10,7 @@ import PreviousPropertyLink from './previous-property-link/previous-property-lin
|
|
10
10
|
import BackToSearchButton from './back-to-search-button/back-to-search-button.component';
|
11
11
|
import StampDutyCalculator from './stamp-duty-calculator/stamp-duty-calculator.component';
|
12
12
|
import RemoveSavedPropertyButton from './remove-saved-property-button/remove-saved-property-button.component';
|
13
|
+
import PropertyResultsPagination from './property-results-pagination/property-results-pagination.component';
|
13
14
|
|
14
15
|
export {
|
15
16
|
SavePropertyButton,
|
@@ -24,4 +25,5 @@ export {
|
|
24
25
|
BackToSearchButton,
|
25
26
|
StampDutyCalculator,
|
26
27
|
RemoveSavedPropertyButton,
|
28
|
+
PropertyResultsPagination,
|
27
29
|
};
|
@@ -140,7 +140,7 @@ const PropertiesDisplay = ({
|
|
140
140
|
key={property.property_id}
|
141
141
|
onClick={() => visitPropertyUpdate(property.property_id)}
|
142
142
|
property={property}
|
143
|
-
data-page-marker={!
|
143
|
+
data-page-marker={!infiniteScroll && index === 0 ? page[0].resultPage : null}
|
144
144
|
{...other}
|
145
145
|
/>
|
146
146
|
);
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import ChevronLeftIcon from '../../shared/chevron-left-icon';
|
4
|
+
import ChevronRightIcon from '../../shared/chevron-right-icon';
|
5
|
+
|
6
|
+
export default function PropertyResultsPaginationItem({
|
7
|
+
pageNumber,
|
8
|
+
currentPage,
|
9
|
+
next,
|
10
|
+
previous,
|
11
|
+
noChevrons,
|
12
|
+
noPrevOrNextText,
|
13
|
+
LeftChevron,
|
14
|
+
RightChevron,
|
15
|
+
}) {
|
16
|
+
const activeClassName = (className) => (
|
17
|
+
currentPage === pageNumber ? `${className}--active` : ''
|
18
|
+
);
|
19
|
+
return (
|
20
|
+
<li className={`property-results-pagination__item ${activeClassName('property-results-pagination__item')}`}>
|
21
|
+
<a href={`${window.location.pathname}/page-${pageNumber}`} className={`property-results-pagination__link ${activeClassName('property-results-pagination__link')}`}>
|
22
|
+
{previous && (
|
23
|
+
<>
|
24
|
+
{!noChevrons && <LeftChevron />}
|
25
|
+
{!noPrevOrNextText && <span className="property-results-pagination__link-prev-text">Previous</span>}
|
26
|
+
</>
|
27
|
+
)}
|
28
|
+
{next && (
|
29
|
+
<>
|
30
|
+
{!noPrevOrNextText && <span className="property-results-pagination__link-next-text">Next</span>}
|
31
|
+
{!noChevrons && <RightChevron />}
|
32
|
+
</>
|
33
|
+
)}
|
34
|
+
{!previous && !next && pageNumber}
|
35
|
+
</a>
|
36
|
+
</li>
|
37
|
+
);
|
38
|
+
}
|
39
|
+
|
40
|
+
PropertyResultsPaginationItem.propTypes = {
|
41
|
+
pageNumber: PropTypes.number.isRequired,
|
42
|
+
currentPage: PropTypes.number,
|
43
|
+
LeftChevron: PropTypes.elementType,
|
44
|
+
RightChevron: PropTypes.elementType,
|
45
|
+
previous: PropTypes.bool,
|
46
|
+
next: PropTypes.bool,
|
47
|
+
noChevrons: PropTypes.bool,
|
48
|
+
noPrevOrNextText: PropTypes.bool,
|
49
|
+
};
|
50
|
+
|
51
|
+
PropertyResultsPaginationItem.defaultProps = {
|
52
|
+
currentPage: null,
|
53
|
+
previous: false,
|
54
|
+
next: false,
|
55
|
+
noChevrons: false,
|
56
|
+
noPrevOrNextText: false,
|
57
|
+
LeftChevron: () => (
|
58
|
+
<ChevronLeftIcon
|
59
|
+
stroke="#000000"
|
60
|
+
width="16"
|
61
|
+
height="16"
|
62
|
+
className="property-results-pagination__chevron property-results-pagination__chevron--left"
|
63
|
+
/>
|
64
|
+
),
|
65
|
+
RightChevron: () => (
|
66
|
+
<ChevronRightIcon
|
67
|
+
stroke="#000000"
|
68
|
+
width="16"
|
69
|
+
height="16"
|
70
|
+
className="property-results-pagination__chevron property-results-pagination__chevron--right"
|
71
|
+
/>
|
72
|
+
),
|
73
|
+
};
|
@@ -0,0 +1,151 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { useSelector } from 'react-redux';
|
3
|
+
import PropTypes from 'prop-types';
|
4
|
+
import PropertyResultsPaginationItem from './property-results-pagination-item.component';
|
5
|
+
|
6
|
+
import './property-results-pagination.styles.scss';
|
7
|
+
|
8
|
+
export default function PropertyResultsPagination({
|
9
|
+
noChevrons,
|
10
|
+
noPrevOrNextText,
|
11
|
+
showIfPageCountIsOne,
|
12
|
+
paginationIncrements,
|
13
|
+
LeftChevron,
|
14
|
+
RightChevron,
|
15
|
+
...otherProps
|
16
|
+
}) {
|
17
|
+
const pagination = useSelector((state) => state.properties?.pagination);
|
18
|
+
|
19
|
+
if (!pagination) return null;
|
20
|
+
|
21
|
+
const {
|
22
|
+
current_page: currentPage,
|
23
|
+
has_next_page: hasNextPage,
|
24
|
+
has_prev_page: hasPrevPage,
|
25
|
+
total_count: totalCount,
|
26
|
+
page_count: pageCount,
|
27
|
+
} = pagination;
|
28
|
+
|
29
|
+
/**
|
30
|
+
* Generates an array of pagination increments (the middle numbers in the pagination)
|
31
|
+
* based on the current page and total page count.
|
32
|
+
* For example the 2,3,4 and 5 in < 1 ... 2 - 3 - 4 - 5 ... 29 >
|
33
|
+
*
|
34
|
+
* @example
|
35
|
+
* currentPage = 1;
|
36
|
+
* pageCount = 100;
|
37
|
+
* 'Should output: [2, 3, 4, 5]'
|
38
|
+
*
|
39
|
+
* currentPage = 1;
|
40
|
+
* pageCount = 5;
|
41
|
+
*'Should output: [2, 3, 4]'
|
42
|
+
*
|
43
|
+
* currentPage = 2;
|
44
|
+
* pageCount = 100;
|
45
|
+
*'Should output: [2, 3, 4, 5]'
|
46
|
+
*
|
47
|
+
* currentPage = 3;
|
48
|
+
* pageCount = 100;
|
49
|
+
*'Should output: [ 3, 4, 5, 6]'
|
50
|
+
* @returns {number[]} An array of page numbers for pagination.
|
51
|
+
*/
|
52
|
+
const getPaginationIncrements = () => {
|
53
|
+
if (pageCount === 1) return [];
|
54
|
+
|
55
|
+
const pagination = [];
|
56
|
+
let startIncrement = currentPage;
|
57
|
+
let endIncrement = currentPage + paginationIncrements;
|
58
|
+
if (currentPage === 1) {
|
59
|
+
startIncrement++;
|
60
|
+
endIncrement++;
|
61
|
+
}
|
62
|
+
if (endIncrement >= pageCount) {
|
63
|
+
endIncrement = pageCount;
|
64
|
+
}
|
65
|
+
|
66
|
+
for (let i = startIncrement; i < endIncrement; i++) {
|
67
|
+
pagination.push(i);
|
68
|
+
}
|
69
|
+
return pagination;
|
70
|
+
};
|
71
|
+
|
72
|
+
return (
|
73
|
+
<div className="property-results-pagination" {...otherProps}>
|
74
|
+
<ul className="property-results-pagination__links">
|
75
|
+
{/* Previous page */}
|
76
|
+
{hasPrevPage && (!noChevrons && !noPrevOrNextText) && (
|
77
|
+
<PropertyResultsPaginationItem
|
78
|
+
previous
|
79
|
+
pageNumber={currentPage - 1}
|
80
|
+
currentPage={currentPage}
|
81
|
+
{...(LeftChevron && { LeftChevron: <LeftChevron /> })}
|
82
|
+
/>
|
83
|
+
)}
|
84
|
+
|
85
|
+
{/* First page */}
|
86
|
+
{pageCount > 1 && (
|
87
|
+
<PropertyResultsPaginationItem pageNumber={1} currentPage={currentPage} />
|
88
|
+
)}
|
89
|
+
|
90
|
+
{/* Ellipsis */}
|
91
|
+
{totalCount > paginationIncrements && (
|
92
|
+
<li className="property-results-pagination__item property-results-pagination__item--ellipsis">
|
93
|
+
<span className="property-results-pagination__ellipsis">…</span>
|
94
|
+
</li>
|
95
|
+
)}
|
96
|
+
|
97
|
+
{/* Pagination increments */}
|
98
|
+
{getPaginationIncrements().map((pageNumber) => (
|
99
|
+
<PropertyResultsPaginationItem
|
100
|
+
key={pageNumber}
|
101
|
+
pageNumber={pageNumber}
|
102
|
+
currentPage={currentPage}
|
103
|
+
/>
|
104
|
+
))}
|
105
|
+
|
106
|
+
{/* Ellipsis */}
|
107
|
+
{totalCount > paginationIncrements && (
|
108
|
+
<li className="property-results-pagination__item property-results-pagination__item--ellipsis">
|
109
|
+
<span className="property-results-pagination__ellipsis">…</span>
|
110
|
+
</li>
|
111
|
+
)}
|
112
|
+
|
113
|
+
{/* Total page count */}
|
114
|
+
{showIfPageCountIsOne && pageCount !== 0 ? (
|
115
|
+
<PropertyResultsPaginationItem pageNumber={pageCount} currentPage={currentPage} />
|
116
|
+
) : (
|
117
|
+
pageCount > 1 && (
|
118
|
+
<PropertyResultsPaginationItem pageNumber={pageCount} currentPage={currentPage} />
|
119
|
+
)
|
120
|
+
)}
|
121
|
+
|
122
|
+
{/* Previous page */}
|
123
|
+
{hasNextPage && (!noChevrons && !noPrevOrNextText) && (
|
124
|
+
<PropertyResultsPaginationItem
|
125
|
+
next
|
126
|
+
pageNumber={currentPage + 1}
|
127
|
+
{...(RightChevron && { RightChevron: <RightChevron /> })}
|
128
|
+
/>
|
129
|
+
)}
|
130
|
+
</ul>
|
131
|
+
</div>
|
132
|
+
);
|
133
|
+
}
|
134
|
+
|
135
|
+
PropertyResultsPagination.propTypes = {
|
136
|
+
noChevrons: PropTypes.bool,
|
137
|
+
noPrevOrNextText: PropTypes.bool,
|
138
|
+
showIfPageCountIsOne: PropTypes.bool,
|
139
|
+
paginationIncrements: PropTypes.number,
|
140
|
+
LeftChevron: PropTypes.elementType,
|
141
|
+
RightChevron: PropTypes.elementType,
|
142
|
+
};
|
143
|
+
|
144
|
+
PropertyResultsPagination.defaultProps = {
|
145
|
+
noChevrons: false,
|
146
|
+
noPrevOrNextText: false,
|
147
|
+
showIfPageCountIsOne: true,
|
148
|
+
paginationIncrements: 4,
|
149
|
+
LeftChevron: null,
|
150
|
+
RightChevron: null,
|
151
|
+
};
|
@@ -0,0 +1,68 @@
|
|
1
|
+
.property-results-pagination {
|
2
|
+
display: flex;
|
3
|
+
justify-content: center;
|
4
|
+
|
5
|
+
&__links {
|
6
|
+
display: flex;
|
7
|
+
list-style: none;
|
8
|
+
margin: 0;
|
9
|
+
padding: 0;
|
10
|
+
gap: 8px;
|
11
|
+
}
|
12
|
+
|
13
|
+
&__item {
|
14
|
+
&--ellipsis {
|
15
|
+
display: flex;
|
16
|
+
align-items: flex-end;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
&__link {
|
21
|
+
display: flex;
|
22
|
+
align-items: center;
|
23
|
+
color: inherit;
|
24
|
+
padding: 4px 8px;
|
25
|
+
border-radius: 4px;
|
26
|
+
height: 100%;
|
27
|
+
|
28
|
+
&:hover {
|
29
|
+
background-color: rgba(118, 118, 118, .25);
|
30
|
+
}
|
31
|
+
|
32
|
+
&:focus {
|
33
|
+
background-color: #ffffff;
|
34
|
+
border: 1px solid #767676;
|
35
|
+
}
|
36
|
+
|
37
|
+
&:visited, &:hover, &:active {
|
38
|
+
color: inherit;
|
39
|
+
text-decoration: none;
|
40
|
+
}
|
41
|
+
|
42
|
+
@media only screen and (min-width: 425px) {
|
43
|
+
gap: 4px;
|
44
|
+
padding: 8px 12px;
|
45
|
+
}
|
46
|
+
|
47
|
+
&--active {
|
48
|
+
background-color: #ffffff;
|
49
|
+
border: 1px solid #767676;
|
50
|
+
|
51
|
+
&:hover {
|
52
|
+
background-color: #ffffff;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
&__link-prev-text, &__link-next-text {
|
58
|
+
display: none;
|
59
|
+
|
60
|
+
@media only screen and (min-width: 768px) {
|
61
|
+
display: block;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
&__ellipsis {
|
66
|
+
padding-bottom: 8px;
|
67
|
+
}
|
68
|
+
}
|
@@ -41,9 +41,10 @@ export const buildQueryString = (search) => {
|
|
41
41
|
// only include either q or place ID
|
42
42
|
if ((key === 'q' && !search.isQuerySearch)
|
43
43
|
|| (key === 'placeId' && search.isQuerySearch)
|
44
|
-
|| (key === 'place')
|
45
44
|
|| (key === 'poly' && search.isQuerySearch)) return;
|
46
45
|
|
46
|
+
if (key === 'place') return queryParams.push(`place_id=${value?.place_id}`);
|
47
|
+
|
47
48
|
// Don't include branch_id if a search term has been entered
|
48
49
|
if (key === 'branch_id' && search.isQuerySearch) return;
|
49
50
|
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
const ChevronLeftIcon = ({ ...otherProps }) => (
|
4
|
+
<svg
|
5
|
+
className="hf-chevron-left-icon"
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
7
|
+
width="24"
|
8
|
+
height="24"
|
9
|
+
viewBox="0 0 24 24"
|
10
|
+
fill="none"
|
11
|
+
stroke="inherit"
|
12
|
+
strokeWidth="2"
|
13
|
+
strokeLinecap="round"
|
14
|
+
strokeLinejoin="round"
|
15
|
+
role="img"
|
16
|
+
{...otherProps}
|
17
|
+
>
|
18
|
+
<title>Chevron left icon</title>
|
19
|
+
<path d="m15 18-6-6 6-6" />
|
20
|
+
</svg>
|
21
|
+
);
|
22
|
+
|
23
|
+
export default ChevronLeftIcon;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
|
3
|
+
const ChevronRightIcon = ({ ...otherProps }) => (
|
4
|
+
<svg
|
5
|
+
className="hf-chevron-right-icon"
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
7
|
+
width="24"
|
8
|
+
height="24"
|
9
|
+
viewBox="0 0 24 24"
|
10
|
+
fill="none"
|
11
|
+
stroke="inherit"
|
12
|
+
strokeWidth="2"
|
13
|
+
strokeLinecap="round"
|
14
|
+
strokeLinejoin="round"
|
15
|
+
role="img"
|
16
|
+
{...otherProps}
|
17
|
+
>
|
18
|
+
<title>Chevron right icon</title>
|
19
|
+
<path d="m9 18 6-6-6-6" />
|
20
|
+
</svg>
|
21
|
+
);
|
22
|
+
|
23
|
+
export default ChevronRightIcon;
|