Skip to content

Commit

Permalink
CourseList: enabled onwed by, showing me when owner is the user who i…
Browse files Browse the repository at this point in the history
…s currently logged in.
  • Loading branch information
lincolnneu committed Jun 4, 2018
1 parent 97348f8 commit 486eb47
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/containers/CourseList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ class CourseList extends React.Component{
super();
this.state = {
course: { title: '' },
courses:[]
courses:[],
curUser:{ username: ''}
}
this.courseService = CourseServiceClient.instance;
this.titleChanged = this.titleChanged.bind(this); // bind these methods to this component in constructor.
Expand All @@ -18,9 +19,19 @@ class CourseList extends React.Component{
}

componentDidMount(){ // data is ready to render. Before rendering, what's your last word?
this.getCurUser();
this.findAllCourses();
}

getCurUser(){
let me = this;
this.courseService
.getCurUser()
.then((data)=>{
this.setState({curUser:{username: data.username}});
})
}

findAllCourses(){
this.courseService
.findAllCourses()
Expand All @@ -35,7 +46,7 @@ class CourseList extends React.Component{
if(this.state){
courses = this.state.courses.map(
function(course){
return <CourseRow key={course.id} course={course} deleteCourse={me.deleteCourse}/>
return <CourseRow key={course.id} curU={me.state.curUser.username} course={course} deleteCourse={me.deleteCourse}/>
}
);
}
Expand Down

0 comments on commit 486eb47

Please sign in to comment.