Skip to content

Commit

Permalink
Merge pull request #22 from olatundeee/development
Browse files Browse the repository at this point in the history
users can view their profile information from the dashboard
  • Loading branch information
olatundeee committed Apr 8, 2019
2 parents 7f5b1cf + 1b43e1c commit 7735d24
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 4 deletions.
1 change: 1 addition & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ app.post('/create-admin', usersRouter);

// routes for user profile api
app.post('/create-profile', profileRouter);
app.post('/get-profile-details', profileRouter);

// routes for tasks api
app.get('/all-tasks', tasksRouter);
Expand Down
4 changes: 1 addition & 3 deletions client/src/app/add-profile/add-profile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@
<p class="center">
<button type="submit" class="waves-effect waves-light btn red add-btn" (click)="addProfile()">add task</button>

<a routerLink="/dashboard/projects" class="waves-effect waves-light btn black add-btn">back to projects</a>

<a routerLink="/dashboard/tasks" class="waves-effect waves-light btn green add-btn">back to tasks</a>
<a routerLink="/dashboard/users/profile" class="waves-effect waves-light btn black add-btn">back to profile</a>
</p>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions client/src/app/profile/profile.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@

.view-btn {
border-radius: 25px;
}

.add-btn-area {
margin: 5%;
}

.add-btn {
border-radius: 25px;
}

.team-info {
margin: 5%;
}

.collection-item-head {
margin: 2% !important;
}
45 changes: 45 additions & 0 deletions client/src/app/profile/profile.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,48 @@
</div>
</div>


<div class="team-info">
<div class="card team-info-card">
<div class="card-action red">
<h6 class="white-text center">Profile Information</h6>
</div>
<div class="card-content center center-align">
<ul class="collection">
<li class="collection-item center-align">
<p class="collection-item-head"><b>Username:</b></p>
<p>{{profile.username}}</p>
</li>

<li class="collection-item center-align">
<p class="collection-item-head"><b>Full Name:</b></p>
<p>{{profile.fullname}}</p>
</li>

<li class="collection-item center-align">
<p class="collection-item-head"><b>Address:</b></p>
<p>{{profile.address}}</p>
</li>

<li class="collection-item center-align">
<p class="collection-item-head"><b>Phone Number:</b></p>
<p>{{profile.phonenumber}}</p>
</li>
<li class="collection-item center-align">
<p class="collection-item-head"><b>Skills:</b></p>
<p>{{profile.skills}}</p>
</li>
<li class="collection-item center-align">
<p class="collection-item-head"><b>Social:</b></p>
<p class="center center-align">
<a href="#">Instagram</a> |
<a href="#">LinkedIn</a> |
<a href="#">Facebook</a> |
<a href="#">Twitter</a> |
<a href="#">Skype</a>
</p>
</li>
</ul>
</div>
</div>
</div>
10 changes: 9 additions & 1 deletion client/src/app/profile/profile.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
import { UserService } from '../services/user.service';

@Component({
selector: 'app-profile',
Expand All @@ -7,9 +8,16 @@ import { Component, OnInit } from '@angular/core';
})
export class ProfileComponent implements OnInit {

constructor() { }
profile;

constructor(private userService: UserService) { }

ngOnInit() {
// get profile details for the currently logged in user

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

}
14 changes: 14 additions & 0 deletions client/src/app/services/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,18 @@ export class UserService {
profile
});
}

// get profile details from backend api/database

getProfileDetails() {
const userId = localStorage.getItem('currentUserId');
const username = localStorage.getItem('currentUser');

// send http request to return profile details for one particular user

return this.http.post('http://localhost:3001/get-profile-details', {
userId,
username
});
}
}
23 changes: 23 additions & 0 deletions routes/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,27 @@ router.post('/create-profile', function(req, res) {
})
})

// get profile details for logged in user

router.post('/get-profile-details', function(req, res) {
console.log(req.body);

// search profile database for document matching the provided userid and username

profile.findOne({
userId: req.body.userId,
username: req.body.username
}, function(err, profile) {
// if there is an error return a 500 status
if(err) {
console.log(err);
return res.sendStatus(500);
}

// if the profile addition is successful return a json object of the profile

res.json(profile)
})
})

module.exports = router;

0 comments on commit 7735d24

Please sign in to comment.