homeflowjs 0.9.34 → 0.9.36
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/README.md
CHANGED
|
@@ -69,5 +69,5 @@ This is a known issue with peer dependencies, see this comment and containing th
|
|
|
69
69
|
|
|
70
70
|
## Deploy
|
|
71
71
|
|
|
72
|
-
To create a new version of HomeflowJS when merging to master, keep an eye on the Jenkins build, it pauses and waits for publish confirmation where you can enter the new version number and publish
|
|
72
|
+
To create a new version of HomeflowJS when merging to master, keep an eye on the Jenkins build, it pauses and waits for publish confirmation where you can enter the new version number and publish.
|
|
73
73
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { useDispatch, useSelector } from 'react-redux';
|
|
3
3
|
import { Checkbox } from 'pretty-checkbox-react';
|
|
4
4
|
|
|
@@ -37,34 +37,38 @@ const NormalCheckBox = ({
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const StatusCheckbox = (props) => {
|
|
40
|
-
const { pretty, value, uncheckedValue } = props;
|
|
41
|
-
|
|
42
|
-
const dispatch = useDispatch();
|
|
43
|
-
|
|
44
40
|
const defaultSearchStatus = useSelector((state) => state.app.themePreferences.defaultSearchStatus || 'all');
|
|
45
41
|
const currentSearchStatus = useSelector((state) => state.search.currentSearch.status);
|
|
46
42
|
|
|
47
|
-
const
|
|
48
|
-
// if no current status then checked if value matches default
|
|
49
|
-
if (currentSearchStatus && currentSearchStatus === value) return true;
|
|
43
|
+
const { pretty, value: propValue, uncheckedValue: propUncheckedValue } = props;
|
|
50
44
|
|
|
51
|
-
|
|
45
|
+
const calculateValue = (thisValue, otherValue, defaultValue) => {
|
|
46
|
+
if (thisValue) return thisValue;
|
|
47
|
+
if (otherValue !== defaultValue) return defaultValue;
|
|
52
48
|
|
|
53
|
-
//
|
|
54
|
-
return
|
|
55
|
-
}
|
|
49
|
+
// The other option is the default value and this one is not provided so this one is opposite of default
|
|
50
|
+
return defaultValue === 'all' ? 'available' : 'all';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const value = calculateValue(propValue, propUncheckedValue, defaultSearchStatus);
|
|
54
|
+
const uncheckedValue = calculateValue(propUncheckedValue, propValue, defaultSearchStatus);
|
|
56
55
|
|
|
57
|
-
const
|
|
56
|
+
const dispatch = useDispatch();
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
const calculateChecked = () => {
|
|
59
|
+
if (typeof currentSearchStatus !== 'undefined') {
|
|
60
|
+
if (currentSearchStatus === value) return true;
|
|
61
|
+
if (currentSearchStatus === uncheckedValue) return false;
|
|
62
|
+
}
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
return value === defaultSearchStatus; // Unknown search status make checkbox be default
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const checked = calculateChecked();
|
|
65
68
|
|
|
69
|
+
const handleChange = (e) => {
|
|
70
|
+
const newValue = checked ? uncheckedValue : value;
|
|
66
71
|
dispatch(setSearchField({ status: newValue === defaultSearchStatus ? '' : newValue }));
|
|
67
|
-
setChecked(calculateChecked());
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
if (pretty) return <PrettyCheckBox {...props} handleChange={handleChange} checked={checked} />;
|
|
@@ -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 = {
|