homeflowjs 1.0.21 → 1.0.23

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.
@@ -187,7 +187,6 @@ const hfInitialize = () => {
187
187
  place,
188
188
  };
189
189
  }
190
-
191
190
  store.dispatch(setInitialSearch(searchFromFragment));
192
191
  store.dispatch(setSearch(searchFromFragment));
193
192
  }
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "1.0.21",
3
+ "version": "1.0.23",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -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
- // remove the place so we don't get [object Object] in URL
11
- const { place, ...restOfSearch } = lastSearch;
12
- const href = `/search?${buildQueryString(restOfSearch)}`;
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}
@@ -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));
@@ -7,7 +7,16 @@ import { setCurrentUser } from '../../actions/user.actions';
7
7
  import notify from '../../app/notify';
8
8
 
9
9
  const ResetPasswordForm = ({
10
- user, setCurrentUser, inputClass, buttonClass, buttonSpanClass, pattern, patternTitle, redirect,
10
+ user,
11
+ setCurrentUser,
12
+ inputClass,
13
+ buttonClass,
14
+ buttonSpanClass,
15
+ pattern,
16
+ patternTitle,
17
+ redirect,
18
+ newPasswordInputProps,
19
+ confirmPasswordInputProps,
11
20
  }) => {
12
21
  const [password, setPassword] = useState('');
13
22
  const [passwordConfirmation, setPasswordConfirmation] = useState('');
@@ -47,6 +56,7 @@ const ResetPasswordForm = ({
47
56
  className={inputClass}
48
57
  pattern={pattern}
49
58
  title={patternTitle}
59
+ {...newPasswordInputProps}
50
60
  />
51
61
  <input
52
62
  name="password_confirmation"
@@ -57,6 +67,7 @@ const ResetPasswordForm = ({
57
67
  className={inputClass}
58
68
  pattern={pattern}
59
69
  title={patternTitle}
70
+ {...confirmPasswordInputProps}
60
71
  />
61
72
 
62
73
  <button
@@ -87,6 +98,8 @@ ResetPasswordForm.defaultProps = {
87
98
  pattern: null,
88
99
  patternTitle: null,
89
100
  redirect: '/user',
101
+ newPasswordInputProps: {},
102
+ confirmPasswordInputProps: {},
90
103
  };
91
104
 
92
105
  const mapStateToProps = (state) => ({