-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
70 additions
and
4 deletions.
There are no files selected for viewing
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 +1,2 @@ | ||
export const FETCH_USER = "fetch_user"; | ||
export const FETCH_SURVEYS = "fetch_surveys"; |
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,40 @@ | ||
import React, { Component } from "react"; | ||
import { fetchSurveys } from "../../actions"; | ||
import { connect } from "react-redux"; | ||
|
||
class SurveyList extends Component { | ||
componentDidMount() { | ||
this.props.fetchSurveys(); | ||
} | ||
|
||
renderSurveys() { | ||
return this.props.surveys.reverse().map(survey => { | ||
return ( | ||
<div className="card darken-1" key={survey._id}> | ||
<div className="card-content"> | ||
<span className="card-title">{survey.title}</span> | ||
<p>{survey.body}</p> | ||
<p className="right"> | ||
Sent On: {new Date(survey.dateSent).toLocaleDateString()} | ||
</p> | ||
</div> | ||
<div className="card-action"> | ||
<a>YES: {survey.yes}</a> | ||
<a>NO: {survey.no}</a> | ||
</div> | ||
</div> | ||
); | ||
}); | ||
} | ||
|
||
render() { | ||
return <div>{this.renderSurveys()}</div>; | ||
} | ||
} | ||
|
||
const mapStateToProps = ({ surveys }) => ({ surveys }); | ||
|
||
export default connect( | ||
mapStateToProps, | ||
{ fetchSurveys } | ||
)(SurveyList); |
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_SURVEYS } from "../actions/types"; | ||
|
||
export default (state = [], action) => { | ||
switch (action.type) { | ||
case FETCH_SURVEYS: | ||
return action.payload || state; | ||
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