Skip to content

Commit

Permalink
Merge pull request #83 from AppBakerZ/UpdatePersonelInformation
Browse files Browse the repository at this point in the history
update username/Email  issue #78
  • Loading branch information
Furqankhanzada authored Apr 10, 2017
2 parents 0dba7e1 + 470e7fa commit b6ff4b5
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
13 changes: 10 additions & 3 deletions imports/api/settings/methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ export const updateProfile = new ValidatedMethod({
type: String
},
'users.username': {
type: String
type: String,
optional: true
},
'users.number': {
type: String
},
'users.email': {
type: String
type: String,
optional: true
},
'users.address': {
type: String
Expand All @@ -80,7 +82,12 @@ export const updateProfile = new ValidatedMethod({
throw new Meteor.Error(500, 'You cannot empty the username/email.');
}
let update = {'profile.fullName': users.name, 'profile.address': users.address , 'profile.contactNumber': users.number};
users.username ? update['username'] = users.username : update['emails.0.address'] = users.email;
if(users.username) {
update['username'] = users.username;
}
if(users.email) {
update['emails.0.address'] = users.email;
}
Meteor.users.update({_id: Meteor.userId()} , {$set: update});
}
});
Expand Down
26 changes: 22 additions & 4 deletions imports/ui/components/settings/Settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,19 +273,36 @@ class SettingsPage extends Component {
/>
{Meteor.user().username ?

<Input type='text' label='Username'
name= 'username'
(<span><Input type='text' label='Username'
name='username'
value={this.state.username}
onChange={this.onChange.bind(this)}
required
/>

<Input type='email' label='Email'
name='email'
value={this.state.email}
onChange={this.onChange.bind(this)}
/>
</span>
)
:

(<span><Input type='text' label='Username'
name='username'
value={this.state.username}
onChange={this.onChange.bind(this)}
/>

<Input type='email' label='Email'
name= 'email'
name='email'
value={this.state.email}
onChange={this.onChange.bind(this)}
required
/>
</span>
)
}
<Input type='text' label='Address'
name='address'
Expand Down Expand Up @@ -416,7 +433,8 @@ class SettingsPage extends Component {
<div className={theme.cardContent}>
<h6>name: <span>{Meteor.user().profile.fullName || 'Not Available'}</span></h6>
<h6>Contact Number: <span> {Meteor.user().profile.contactNumber || 'Not Available'}</span></h6>
<h6> <span> {Meteor.user().username ? 'Username:' : 'Email:' } </span> {Meteor.user().username ? Meteor.user().username : Meteor.user().emails[0].address }</h6>
<h6>Username:<span> { Meteor.user().username ? Meteor.user().username :'Not Available'} </span> </h6>
<h6>Email: <span> {Meteor.user().emails ? Meteor.user().emails[0].address :'Not Available'}</span></h6>
<h6>Address: <span> {Meteor.user().profile.address || 'Not Available'}</span></h6>
<div className={theme.settingBtn}>
<Button label='EDIT INFO' raised accent onClick={this.openPopup.bind(this, 'personalInformation')} />
Expand Down
6 changes: 6 additions & 0 deletions imports/ui/components/settings/theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
width: 80%;
display: inline-block;
}
&:nth-child(3){
text-transform: initial;
}
&:nth-child(4){
text-transform: initial;
}
span{
label{
display: inline-block;
Expand Down

0 comments on commit b6ff4b5

Please sign in to comment.