Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions app/native/components/common/Menu.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
import {connect} from "react-redux";
import {
Dimensions,
StyleSheet,
Expand Down Expand Up @@ -32,16 +33,20 @@ const styles = StyleSheet.create({
},
});

module.exports = class Menu extends Component {
class Menu extends Component {
static propTypes = {
onItemSelected: React.PropTypes.func.isRequired,
navigator: React.PropTypes.object.isRequired,
user: React.PropTypes.object,
};

render() {
return (
<ScrollView scrollsToTop={false} style={styles.menu}>
<Text style={styles.name}>Pamela Martinez</Text>
{this.props.user ?
<Text style={styles.name}>{this.props.user.displayName}</Text> :
null
}
<Text
onPress={() => this.props.onItemSelected('Homepage', 'Charm City Readers', this.props.navigator)}
style={styles.item}
Expand Down Expand Up @@ -73,3 +78,12 @@ module.exports = class Menu extends Component {
);
}
};

// sets current state for Header as this.prop
function mapStateToProps(state) {
return {
user: state.reducers.user,
};
}

module.exports = connect(mapStateToProps, null)(Menu);
4 changes: 2 additions & 2 deletions app/native/components/time/AddTimeScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class AddTimeScreen extends React.Component {
}

onAddTimePress() {
this.props.setStudentTime(this.state.maxDate.format('YYMMDD'), this.state.minsRead, this.props.studentID, this.props.parentID);
this.props.setStudentTime(this.state.maxDate.format('YYMMDD'), this.state.minsRead, this.props.studentID, this.props.user.uid);
this.props.navigator.push({
name: 'Homepage',
title: 'Charm City Readers',
Expand Down Expand Up @@ -180,7 +180,7 @@ class AddTimeScreen extends React.Component {
function mapStateToProps(state, props) {
const studentID = props.studentID;
return {
parentID: state.reducers.parentID,
user: state.reducers.user,
navigator: props.navigator,
studentID,
student: state.reducers.studentList[studentID],
Expand Down
4 changes: 3 additions & 1 deletion app/web/components/time/AddTimePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AddTimePage extends React.Component {

// trigger add time action
var readDate = this.state.readDate.format('YYMMDD');
this.props.setStudentTime(readDate, this.props.readMinutes, this.props.studentID, this.props.parentID);
this.props.setStudentTime(readDate, this.props.readMinutes, this.props.studentID, this.props.user.uid);
this.setState({readDate: moment()});
toastr.success("Time saved.");
hashHistory.push("/");
Expand Down Expand Up @@ -67,6 +67,7 @@ class AddTimePage extends React.Component {
}

AddTimePage.propTypes = {
user: React.PropTypes.object.isRequired,
setStudentTime: React.PropTypes.func.isRequired,
setMinsReadState: React.PropTypes.func.isRequired,
student: React.PropTypes.shape({
Expand All @@ -83,6 +84,7 @@ function mapStateToProps(state, ownProps) {
return {
parentID: state.reducers.parentID,
studentID,
user: state.reducers.user,
student: state.reducers.studentList[studentID],
timeFormIsValid: state.reducers.timeForm[studentID].formIsValid,
readMinutes: state.reducers.timeForm[studentID].timeRead,
Expand Down