zoapp-front
Advanced tools
Comparing version 0.26.3-SNAPSHOT.1548069199 to 0.26.3-SNAPSHOT.1548070194
@@ -141,3 +141,2 @@ "use strict"; | ||
}), | ||
error: _propTypes2.default.string, | ||
avatarChildren: _propTypes2.default.shape({}) | ||
@@ -144,0 +143,0 @@ }; |
@@ -80,3 +80,3 @@ "use strict"; | ||
_this.props.apiUserProfileRequest(); | ||
_this.setState({ profile: (0, _extends4.default)({}, _this.props.profile) }); | ||
_this.setState({ profile: (0, _extends4.default)({}, _this.props.profile), hasChanged: false }); | ||
}; | ||
@@ -89,3 +89,3 @@ | ||
delete profile.password; | ||
_this.setState({ profile: profile }); | ||
_this.setState({ hasChanged: false }); | ||
}; | ||
@@ -96,3 +96,4 @@ | ||
_this.setState({ | ||
profile: (0, _extends4.default)({}, _this.state.profile, (0, _defineProperty3.default)({}, field, e.target.value)) | ||
profile: (0, _extends4.default)({}, _this.state.profile, (0, _defineProperty3.default)({}, field, e.target.value)), | ||
hasChanged: true | ||
}); | ||
@@ -103,5 +104,3 @@ }; | ||
_this.hasProfileChanged = function () { | ||
var propsProfile = _this.props.profile; | ||
var stateProfile = _this.state.profile; | ||
return !(propsProfile && stateProfile && (propsProfile.username !== stateProfile.username || propsProfile.email !== stateProfile.email || propsProfile.password !== stateProfile.password)); | ||
return _this.state.hasChanged; | ||
}; | ||
@@ -131,4 +130,5 @@ | ||
_this.state = { | ||
profile: props.profile, | ||
error: props.error | ||
profile: {}, | ||
error: props.error, | ||
hasChanged: false | ||
}; | ||
@@ -145,3 +145,3 @@ return _this; | ||
} else { | ||
var shouldDisableButton = this.hasProfileChanged(); | ||
var shouldDisableButton = !this.hasProfileChanged(); | ||
var footerButtons = []; | ||
@@ -213,4 +213,3 @@ if (this.props.downloadData) { | ||
downloadData: this.props.downloadData, | ||
removeAccount: this.props.removeAccount, | ||
error: this.props.error | ||
removeAccount: this.props.removeAccount | ||
}), | ||
@@ -220,3 +219,3 @@ _react2.default.createElement( | ||
{ className: "authenticate_error" }, | ||
this.state.error | ||
this.props.error | ||
), | ||
@@ -249,11 +248,9 @@ footerButtons | ||
key: "getDerivedStateFromProps", | ||
value: function getDerivedStateFromProps(props, state) { | ||
value: function getDerivedStateFromProps(props) { | ||
var error = props.error, | ||
profile = props.profile; | ||
isLoading = props.isLoading; | ||
if (error !== state.error) { | ||
if (error && !isLoading) { | ||
// Since there was an error, reset profile to latest props | ||
return { | ||
profile: profile, | ||
error: error | ||
@@ -260,0 +257,0 @@ }; |
{ | ||
"name": "zoapp-front", | ||
"version": "0.26.3-SNAPSHOT.1548069199", | ||
"version": "0.26.3-SNAPSHOT.1548070194", | ||
"description": "Javascript ES7 React Frontend", | ||
@@ -5,0 +5,0 @@ "author": "Mik BRY <mik@zoapp.com>", |
@@ -74,3 +74,2 @@ /** | ||
}), | ||
error: PropTypes.string, | ||
avatarChildren: PropTypes.shape({}), | ||
@@ -77,0 +76,0 @@ }; |
@@ -31,14 +31,13 @@ /** | ||
this.state = { | ||
profile: props.profile, | ||
profile: {}, | ||
error: props.error, | ||
hasChanged: false, | ||
}; | ||
} | ||
static getDerivedStateFromProps(props, state) { | ||
const { error, profile } = props; | ||
if (error !== state.error) { | ||
static getDerivedStateFromProps(props) { | ||
const { error, isLoading } = props; | ||
if (error && !isLoading) { | ||
// Since there was an error, reset profile to latest props | ||
return { | ||
profile, | ||
error, | ||
@@ -53,3 +52,3 @@ }; | ||
this.props.apiUserProfileRequest(); | ||
this.setState({ profile: { ...this.props.profile } }); | ||
this.setState({ profile: { ...this.props.profile }, hasChanged: false }); | ||
}; | ||
@@ -62,3 +61,3 @@ | ||
delete profile.password; | ||
this.setState({ profile }); | ||
this.setState({ hasChanged: false }); | ||
}; | ||
@@ -69,16 +68,7 @@ | ||
profile: { ...this.state.profile, [field]: e.target.value }, | ||
hasChanged: true, | ||
}); | ||
}; | ||
hasProfileChanged = () => { | ||
const propsProfile = this.props.profile; | ||
const stateProfile = this.state.profile; | ||
return !( | ||
propsProfile && | ||
stateProfile && | ||
(propsProfile.username !== stateProfile.username || | ||
propsProfile.email !== stateProfile.email || | ||
propsProfile.password !== stateProfile.password) | ||
); | ||
}; | ||
hasProfileChanged = () => this.state.hasChanged; | ||
@@ -108,3 +98,3 @@ resetAvatar = () => { | ||
} else { | ||
const shouldDisableButton = this.hasProfileChanged(); | ||
const shouldDisableButton = !this.hasProfileChanged(); | ||
const footerButtons = []; | ||
@@ -160,5 +150,4 @@ if (this.props.downloadData) { | ||
removeAccount={this.props.removeAccount} | ||
error={this.props.error} | ||
/> | ||
<div className="authenticate_error">{this.state.error}</div> | ||
<div className="authenticate_error">{this.props.error}</div> | ||
{footerButtons} | ||
@@ -165,0 +154,0 @@ </form> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1073281
11771