homeflowjs 1.0.89 → 1.0.90

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homeflowjs",
3
- "version": "1.0.89",
3
+ "version": "1.0.90",
4
4
  "sideEffects": [
5
5
  "modal/**/*",
6
6
  "user/default-profile/**/*",
@@ -114,7 +114,7 @@ const ChangePasswordForm = ({
114
114
  }`,
115
115
  };
116
116
 
117
- function resetForm({ errors, callBack }) {
117
+ function resetForm(errors = null, callbackFor = '') {
118
118
  if (errors) {
119
119
  dispatch({
120
120
  type: 'RESET_WITH_ERROR',
@@ -124,9 +124,8 @@ const ChangePasswordForm = ({
124
124
  dispatch({ type: 'RESET' });
125
125
  }
126
126
 
127
- if (callBack) {
128
- callBack();
129
- }
127
+ if (callbackFor === 'success' && onSuccessCallback) onSuccessCallback();
128
+ if (callbackFor === 'error' && onErrorCallback) onErrorCallback();
130
129
  }
131
130
 
132
131
  function updateUser() {
@@ -149,15 +148,12 @@ const ChangePasswordForm = ({
149
148
 
150
149
  if (response.ok) {
151
150
  // password changed sucessfully
152
- resetForm({ callback: onSuccessCallback });
151
+ resetForm(null, 'success');
153
152
  notify('You have successfully changed your password.', 'success');
154
153
  }
155
154
  else if (responseData.errors && Array.isArray(responseData.errors) && statusCode === 422) {
156
155
  // new validation erorrs for form from Users API
157
- resetForm({
158
- errors: responseData.errors,
159
- callback: onErrorCallback,
160
- });
156
+ resetForm(responseData.errors, 'error');
161
157
  }
162
158
  else if (responseData.message) {
163
159
  // attis just single message response
@@ -169,7 +165,7 @@ const ChangePasswordForm = ({
169
165
  }
170
166
  })
171
167
  .catch((err) => {
172
- resetForm({ callback: onErrorCallback });
168
+ resetForm( null, 'error');
173
169
  const errMessage = err instanceof SyntaxError
174
170
  ? ERROR_MESSAGE
175
171
  : err.message || ERROR_MESSAGE;