Commit b86f7974 authored by Shaini Thenuwara's avatar Shaini Thenuwara

View posts (frontend)

parent 6ef5898d
import React, { Component } from 'react'
import axios from 'axios'
import constant from '../service/constant';
const CardPostNav = props =>(
<div>
<div className="card postCard">
<img className="card-img-top" src="..." alt="Card image cap"/>
<div className="card-body">
<h5 className="card-title">Card title</h5>
<p className="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" className="btn btn-primary">Go somewhere</a>
</div>
</div>
<br/>
</div>
);
class Student extends Component {
......@@ -7,18 +22,46 @@ class Student extends Component {
super(pros)
this.state = {
postList:[]
}
}
componentWillMount() {
axios.get(constant()+'/post')
.then(res => {
this.setState({postList: res.data});
}).catch(err => {
console.log(err);
});
}
viewCardList = () => {
return this.state.postList.map(function(value,index){
return <CardPostNav postObj={value} index={index} />;
})
}
render(){
const { postList } = this.state;
return(
<div className="container">
<h2>Student Page</h2>
<div className="panel panel-default">
<div className="panel-heading">
<h3 className="panel-title">
Login
</h3>
</div>
<div className="panel-body">
{this.viewCardList()}
<br/>
</div>
</div>
</div>
)
}
}
export default Student;
......@@ -113,4 +113,8 @@ a:link {
.resultViewBtn {
width: 150px;
margin-right: 20px;
}
.postCard{
width: 18rem;
}
\ No newline at end of file
......@@ -19,8 +19,8 @@ ReactDOM.render(
<a className="navbar-brand " href="#"><h4 className="navBarTitle">E-Learning Platform</h4></a>
</nav>
<br/>
<Route exact path='/' component={CreatePost} />
{/* <Route exact path='/' component={Login} /> */}
{/* <Route exact path='/' component={CreatePost} /> */}
<Route exact path='/' component={Login} />
<Route path='/Register' component={Register} />
<Route path='/App' component={App} />
<Route path='/Student' component={Student} />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment