homeflowjs 0.10.22 → 0.10.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.
@@ -23,7 +23,7 @@ export const fetchUser = () => (dispatch) => {
23
23
  fetch('/user.ljson')
24
24
  .then((response) => response.json())
25
25
  .then((json) => {
26
- if (json) {
26
+ if (json?.user) {
27
27
  dispatch(setCurrentUser(json.user));
28
28
  dispatch(setLocalUser(json.user));
29
29
 
@@ -14,6 +14,7 @@ const BranchesSearchInput = ({
14
14
  setIsSelected,
15
15
  label,
16
16
  isRequired,
17
+ submitOnSelect,
17
18
  }) => {
18
19
  const { branchesSearch } = useSelector((state) => state?.branches);
19
20
  const dispatch = useDispatch();
@@ -107,6 +108,10 @@ const BranchesSearchInput = ({
107
108
  * Check is setIsSelect exists as its is only passed as a prop on
108
109
  * countrywide themes, other themes will not use this.
109
110
  */
111
+ if (submitOnSelect) {
112
+ const form = document.querySelector('form[action="/branches"]');
113
+ form.submit();
114
+ }
110
115
  if (setIsSelected) setIsSelected(false);
111
116
  if (label) setInputFocused(true);
112
117
  return (
@@ -144,6 +149,7 @@ BranchesSearchInput.propTypes = {
144
149
  PropTypes.func,
145
150
  PropTypes.string,
146
151
  ]),
152
+ submitOnSelect: PropTypes.bool,
147
153
  };
148
154
 
149
155
  BranchesSearchInput.defaultProps = {
@@ -152,6 +158,7 @@ BranchesSearchInput.defaultProps = {
152
158
  isSelected: '',
153
159
  setIsSelected: '',
154
160
  isRequired: false,
161
+ submitOnSelect: false,
155
162
  };
156
163
 
157
164
  export default BranchesSearchInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "0.10.22",
3
+ "version": "0.10.24",
4
4
  "description": "JavaScript toolkit for Homeflow themes",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,7 +7,7 @@ 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,
10
+ user, setCurrentUser, inputClass, buttonClass, buttonSpanClass, pattern, patternTitle, redirect,
11
11
  }) => {
12
12
  const [password, setPassword] = useState('');
13
13
  const [passwordConfirmation, setPasswordConfirmation] = useState('');
@@ -31,7 +31,7 @@ const ResetPasswordForm = ({
31
31
  .then(({ user }) => {
32
32
  setCurrentUser(user);
33
33
  notify('You have successfully changed your password.', 'success');
34
- history.push('/user');
34
+ history.push(redirect);
35
35
  })
36
36
  .catch((err) => console.error('Something went wrong.', err));
37
37
  };
@@ -77,6 +77,7 @@ ResetPasswordForm.propTypes = {
77
77
  buttonSpanClass: PropTypes.string,
78
78
  pattern: PropTypes.string,
79
79
  patternTitle: PropTypes.string,
80
+ redirect: PropTypes.string,
80
81
  };
81
82
 
82
83
  ResetPasswordForm.defaultProps = {
@@ -85,6 +86,7 @@ ResetPasswordForm.defaultProps = {
85
86
  buttonSpanClass: '',
86
87
  pattern: null,
87
88
  patternTitle: null,
89
+ redirect: '/user',
88
90
  };
89
91
 
90
92
  const mapStateToProps = (state) => ({