You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.2 KiB
68 lines
1.2 KiB
7 years ago
|
import React from 'react';
|
||
7 years ago
|
import LeftColumn from './LeftColumn';
|
||
|
import RightContainer from './RightContainer';
|
||
6 years ago
|
const SERVER_URL = 'http://localhost:3000/'
|
||
7 years ago
|
|
||
|
export default class Site extends React.Component {
|
||
7 years ago
|
|
||
6 years ago
|
constructor(props) {
|
||
|
super(props)
|
||
|
this.state = {
|
||
6 years ago
|
classesData: [],
|
||
6 years ago
|
forumPosts: [],
|
||
6 years ago
|
componentMounted: false
|
||
6 years ago
|
}
|
||
6 years ago
|
}
|
||
|
|
||
6 years ago
|
callAPI = (targetUrl) => {
|
||
|
let apiData
|
||
|
fetch(SERVER_URL + 'api/data/'+ targetUrl)
|
||
6 years ago
|
.then(response => response.json())
|
||
6 years ago
|
.then(data => apiData = data)
|
||
|
return apiData
|
||
|
}
|
||
|
|
||
|
componentDidMount() {
|
||
|
|
||
|
object = {
|
||
|
classes:
|
||
|
}
|
||
|
|
||
|
let classesData = callAPI('classes')
|
||
|
let forumPosts = callAPI('psboard')
|
||
|
|
||
|
this.setState({
|
||
|
classesData: classesData,
|
||
|
forumPosts: forumPosts
|
||
|
})
|
||
7 years ago
|
}
|
||
|
|
||
6 years ago
|
// <LeftColumn />}
|
||
|
// <RightContainer />
|
||
|
|
||
7 years ago
|
render() {
|
||
6 years ago
|
|
||
|
console.log(this.state)
|
||
|
|
||
7 years ago
|
return (
|
||
7 years ago
|
<div className="mainContainer">
|
||
6 years ago
|
|
||
|
<div className="left">
|
||
|
<div className="heading">Upcoming Classes</div>
|
||
|
{this.state.classesData.map((item, i) =>
|
||
|
<div className='course-list'>
|
||
|
<div className='subject'>{item.subject}</div>
|
||
|
<div className='date'>{item.date}</div>
|
||
|
</div>)}
|
||
|
</div>
|
||
|
|
||
|
<div className="right">
|
||
|
<div className="heading">Posts</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
7 years ago
|
</div>
|
||
|
);
|
||
|
}
|
||
|
}
|