-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
453 additions
and
236 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import axios from 'axios'; | ||
import { FETCH_STUDENTS } from '../constants/actionTypes'; | ||
|
||
export const fetchStudents = classId => { | ||
return async dispatch => { | ||
const res = await axios.get(`/api/classes/${classId}`); | ||
dispatch({ type: FETCH_STUDENTS, payload: res.data }); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
const getFormatedTime = dateTime => { | ||
const getFormattedTime = dateTime => { | ||
return new Date(dateTime).toDateString(); | ||
}; | ||
export default getFormatedTime; | ||
export default getFormattedTime; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import React from 'react'; | ||
import { Switch, Route } from 'react-router-dom'; | ||
import Home from '../../routes/home/Home'; | ||
import Login from '../../routes/login/Login'; | ||
import Register from '../../routes/register/Register'; | ||
import Home from 'app/routes/home/Home'; | ||
import Login from 'app/routes/login/Login'; | ||
import Register from 'app/routes/register/Register'; | ||
import Class from 'app/routes/class/Class'; | ||
const Router = () => ( | ||
<Switch> | ||
<Route exact path="/" component={Home} /> | ||
<Route exact path="/login" component={Login} /> | ||
<Route exact path="/register" component={Register} /> | ||
<Route exact path="/class/:classId" component={Class} /> | ||
</Switch> | ||
); | ||
export default Router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { FETCH_STUDENTS } from '../constants/actionTypes'; | ||
|
||
export default function(state = [], action) { | ||
switch (action.type) { | ||
case FETCH_STUDENTS: | ||
return action.payload.reverse() || []; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, { Component } from 'react'; | ||
import StudentList from './containers/StudentList'; | ||
class Class extends Component { | ||
render() { | ||
debugger; | ||
return ( | ||
<div className="class-page"> | ||
<section className="hero is-primary"> | ||
<div className="hero-body"> | ||
<div className="container"> | ||
<h1 className="title">Primary title</h1> | ||
<h2 className="subtitle">Primary subtitle</h2> | ||
</div> | ||
</div> | ||
</section> | ||
<StudentList classId={this.props.match.params.classId} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default Class; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
|
||
const StudentItem = ({ fullName, email }) => { | ||
return ( | ||
<div className="column is-half"> | ||
<div className="box u-hover-effect "> | ||
<article className="media"> | ||
<div className="media-content"> | ||
<div className="content"> | ||
<p> | ||
<span className="tag is-light is-medium"> | ||
<strong className="is-white">{fullName}</strong>{' '} | ||
</span> | ||
<br /> | ||
|
||
<strong>Email: </strong> | ||
{email} | ||
</p> | ||
</div> | ||
</div> | ||
</article> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default StudentItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React, { Component } from 'react'; | ||
import StudentItem from '../components/StudentItem'; | ||
import { connect } from 'react-redux'; | ||
import { fetchStudents } from 'app/actions/students'; | ||
|
||
class StudentList extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.state = {}; | ||
} | ||
|
||
componentDidMount() { | ||
this.props.fetchStudents(this.props.classId); | ||
} | ||
renderList(students) { | ||
return students.map(({ _id, fullName, email }) => { | ||
return <StudentItem key={_id} fullName={fullName} email={email} />; | ||
}); | ||
} | ||
render() { | ||
return ( | ||
<section className="section"> | ||
<div className="container"> | ||
<div className="columns is-multiline is-desktop ">{this.renderList(this.props.students)}</div> | ||
</div> | ||
</section> | ||
); | ||
} | ||
} | ||
const mapStateToProps = state => ({ | ||
students: state.students, | ||
}); | ||
export default connect( | ||
mapStateToProps, | ||
{ fetchStudents }, | ||
)(StudentList); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters