From 31f8300570a812716fe209913feb1c1c33f1ee60 Mon Sep 17 00:00:00 2001 From: mohit Date: Mon, 20 Jun 2016 18:28:39 -0700 Subject: [PATCH] make parent-auth changes for native * still need to actually tie in the auth loop --- app/native/components/common/Menu.js | 18 ++++++++++++++++-- app/native/components/time/AddTimeScreen.js | 4 ++-- app/web/components/time/AddTimePage.jsx | 4 +++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/app/native/components/common/Menu.js b/app/native/components/common/Menu.js index c6898b5..31a2cf2 100644 --- a/app/native/components/common/Menu.js +++ b/app/native/components/common/Menu.js @@ -1,4 +1,5 @@ import React from 'react'; +import {connect} from "react-redux"; import { Dimensions, StyleSheet, @@ -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 ( - Pamela Martinez + {this.props.user ? + {this.props.user.displayName} : + null + } this.props.onItemSelected('Homepage', 'Charm City Readers', this.props.navigator)} style={styles.item} @@ -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); diff --git a/app/native/components/time/AddTimeScreen.js b/app/native/components/time/AddTimeScreen.js index 166cc50..846fa88 100644 --- a/app/native/components/time/AddTimeScreen.js +++ b/app/native/components/time/AddTimeScreen.js @@ -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', @@ -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], diff --git a/app/web/components/time/AddTimePage.jsx b/app/web/components/time/AddTimePage.jsx index 8240de1..d31aafa 100644 --- a/app/web/components/time/AddTimePage.jsx +++ b/app/web/components/time/AddTimePage.jsx @@ -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("/"); @@ -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({ @@ -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,