From cc2afb378d0faac579a8682aa9bed2a4778899d8 Mon Sep 17 00:00:00 2001 From: srksumanth Date: Mon, 1 Oct 2018 23:33:57 +0530 Subject: [PATCH 1/2] update --- components/dashboard/BankDetails.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/dashboard/BankDetails.js b/components/dashboard/BankDetails.js index ab9ca05..b40308f 100644 --- a/components/dashboard/BankDetails.js +++ b/components/dashboard/BankDetails.js @@ -126,7 +126,6 @@ class UpdateProfile extends Component {

Date: Mon, 1 Oct 2018 23:34:30 +0530 Subject: [PATCH 2/2] Make profile editable --- components/dashboard/profile/Index.js | 2 +- components/dashboard/profile/Profile.js | 36 +++++++++++++++---- components/dashboard/profile/UpdateProfile.js | 31 +++++++--------- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/components/dashboard/profile/Index.js b/components/dashboard/profile/Index.js index 7878e59..e479ae2 100644 --- a/components/dashboard/profile/Index.js +++ b/components/dashboard/profile/Index.js @@ -70,7 +70,7 @@ export default class extends Component { } else { return ( <> - + ({ paddingBottom: theme.spacing.unit * 2 } }); +function renderOtherFields(profile) { + if (profile.phone) { + return ( + <> +

+ Phone :  + {profile.phone} +

+

+ College :  + {profile.college} +

+ + ); + } + return ( + <> +

+ Phone :  Not provided +

+

+ College :  Not provided +

+ + ); +} export default withStyles(styles)(function({ profile, toggleProfileForm, @@ -63,18 +89,16 @@ export default withStyles(styles)(function({ Gender :  {profile.gender}

-

- College :  - {profile.college} -

- + + {renderOtherFields(profile)} + diff --git a/components/dashboard/profile/UpdateProfile.js b/components/dashboard/profile/UpdateProfile.js index 4497801..3ad5ac1 100644 --- a/components/dashboard/profile/UpdateProfile.js +++ b/components/dashboard/profile/UpdateProfile.js @@ -46,17 +46,10 @@ class UpdateProfile extends Component { colleges: [] }; - static getDerivedStateFromProps(props, state) { - let newState = { ...state }; - if (props.profile) { - newState.name = props.profile.name; - if (props.profile.gender) { - newState.gender = props.profile.gender; - } - } - return newState; - } componentDidMount() { + if (this.props.profile) { + this.setState({ ...this.state, ...this.props.profile }); + } this.fetchAllCities(); } fetchAllCities = () => { @@ -131,9 +124,9 @@ class UpdateProfile extends Component {
-

- * These fields must be filled and can only be updated once * -

+

+ UPDATE PROFILE +

- 1 - 2 - 3 - 4 + 1 + 2 + 3 + 4 -
+ {/*

* These fields must be filled and can only be updated once *

-
+
*/}