Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

if a user has updated their profile the add bio button will not be di… #24

Merged
merged 1 commit into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/app/profile/profile.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="content-area">
<div class="row center">
<div class="col l6 m6 s12">
<a class="btn view-btn center teal" routerLink="/dashboard/users/add-profile">add bio</a>
<a class="btn view-btn center teal" routerLink="/dashboard/users/add-profile" *ngIf="displayAddBio">add bio</a>
</div>
<div class="col l6 m6 s12">
<a class="btn view-btn center green lighten-2" (click)="editBio(profile)">edit bio</a>
Expand Down
11 changes: 11 additions & 0 deletions client/src/app/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ import { Router } from '@angular/router';
export class ProfileComponent implements OnInit {

profile;
displayAddBio;

constructor(private userService: UserService, private router: Router) { }

ngOnInit() {
// display add bio button on initialization

this.displayAddBio = true;

// get profile details for the currently logged in user

this.userService.getProfileDetails().subscribe(res => {
this.profile = res;

// check if user has already added a profile, if true, do not display the add bio button

if (this.profile.profile_added === true) {
this.displayAddBio = false;
}
});
}

Expand Down
3 changes: 2 additions & 1 deletion models/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var profileSchema = new mongoose.Schema({
linkedin: String,
facebook: String,
twitter: String,
skype: String
skype: String,
profile_added: Boolean
})

module.exports = mongoose.model('Profile', profileSchema);
6 changes: 4 additions & 2 deletions routes/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ router.post('/create-profile', function(req, res) {
linkedin: req.body.profile.linkedin,
facebook: req.body.profile.facebook,
twitter: req.body.profile.twitter,
skype: req.body.profile.skype
skype: req.body.profile.skype,
profile_added: true
}, function(err, profile) {
// if there is an error return a 500 status
if(err) {
Expand Down Expand Up @@ -75,7 +76,8 @@ router.post('/edit-profile', function(req, res) {
linkedin: req.body.profile.linkedin,
facebook: req.body.profile.facebook,
twitter: req.body.profile.twitter,
skype: req.body.profile.skype
skype: req.body.profile.skype,
profile_added: true
}, function(err, profile) {
// if there is an error return a 500 status
if(err) {
Expand Down