homeflowjs 0.9.34 → 0.9.35
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/.eslintrc.js
CHANGED
package/actions/user.actions.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* eslint-disable import/no-cycle */
|
|
1
2
|
import UserActionTypes from './user.types';
|
|
2
3
|
import { fetchSavedProperties, setSavedProperties } from './properties.actions';
|
|
3
4
|
import { fetchSavedSearches, setSavedSearches } from './search.actions';
|
|
@@ -153,11 +154,15 @@ export const signOutUser = () => (dispatch) => (
|
|
|
153
154
|
fetch('/session', {
|
|
154
155
|
method: 'DELETE',
|
|
155
156
|
})
|
|
156
|
-
.then(() => {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
157
|
+
.then((response) => {
|
|
158
|
+
if (response.ok) {
|
|
159
|
+
dispatch(setCurrentUser(INITIAL_USER_DATA));
|
|
160
|
+
dispatch(setLocalUser(INITIAL_USER_DATA));
|
|
161
|
+
dispatch(setUserCredentials({ email: '', password: '' }));
|
|
162
|
+
dispatch(setSavedProperties([]));
|
|
163
|
+
dispatch(setSavedSearches([]));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return response.ok;
|
|
162
167
|
})
|
|
163
168
|
);
|
package/package.json
CHANGED
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { useHistory } from 'react-router-dom';
|
|
2
3
|
import { connect } from 'react-redux';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
4
5
|
|
|
5
6
|
import { signOutUser } from '../../actions/user.actions';
|
|
6
7
|
import notify from '../../app/notify';
|
|
7
8
|
|
|
8
|
-
const SignOutButton = ({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
const SignOutButton = ({
|
|
10
|
+
signOutUser, pushHistory, reload, children, ...otherProps
|
|
11
|
+
}) => {
|
|
12
|
+
const history = useHistory();
|
|
13
|
+
const handleClick = (e) => {
|
|
14
|
+
e.preventDefault();
|
|
15
|
+
signOutUser()
|
|
16
|
+
.then((success) => {
|
|
17
|
+
if (success) {
|
|
18
|
+
notify('You have been signed out', 'success');
|
|
19
|
+
if (pushHistory) history.push('/');
|
|
20
|
+
if (reload) location.reload(false);
|
|
21
|
+
} else {
|
|
22
|
+
notify('There was an error signing out', 'error');
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
onClick={(e) => handleClick(e)}
|
|
31
|
+
{...otherProps}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</button>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
21
37
|
|
|
22
38
|
SignOutButton.propTypes = {
|
|
23
39
|
signOutUser: PropTypes.func.isRequired,
|
|
@@ -25,6 +41,13 @@ SignOutButton.propTypes = {
|
|
|
25
41
|
PropTypes.element,
|
|
26
42
|
PropTypes.string,
|
|
27
43
|
]).isRequired,
|
|
44
|
+
pushHistory: PropTypes.bool,
|
|
45
|
+
reload: PropTypes.bool,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
SignOutButton.defaultProps = {
|
|
49
|
+
pushHistory: false,
|
|
50
|
+
reload: false,
|
|
28
51
|
};
|
|
29
52
|
|
|
30
53
|
const mapDispatchToProps = {
|