Skip to content

Commit

Permalink
Conditionally render save profile and attend event buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
soniasophia committed Sep 21, 2017
1 parent 3329c9b commit e7f3ae0
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 15 deletions.
17 changes: 11 additions & 6 deletions js/scenes/AccountSettings/AccountSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const AccountSettings = ({ updateSettings, currentEmail, currentPassword, getCur
<View style={styles.imageContainer}>
<Image
style={styles.image}
source={getImage ? {uri: getImage} : accountIcon}
source={getImage ? { uri: getImage } : accountIcon}
/>
<Image
style={styles.pencil}
Expand All @@ -38,6 +38,7 @@ const AccountSettings = ({ updateSettings, currentEmail, currentPassword, getCur
style={styles.inputSmall}
onChangeText={(text) => handleFullname(text)}
value={fullnameField}
autoCorrect={false}
placeholder={user.fullName}
/>
</View>
Expand All @@ -48,6 +49,7 @@ const AccountSettings = ({ updateSettings, currentEmail, currentPassword, getCur
style={styles.inputSmall}
onChangeText={(text) => handleEmail(text)}
autoCapitalize="none"
autoCorrect={false}
value={emailField}
placeholder={user.email}
/>
Expand All @@ -59,17 +61,20 @@ const AccountSettings = ({ updateSettings, currentEmail, currentPassword, getCur
style={styles.inputSmall}
onChangeText={handlePassword}
secureTextEntry={true}
autoCorrect={false}
autoCapitalize="none"
value={passwordField}
placeholder={user.password}
/>
</View>
<SurveyButton
text="save settings"
onPress={() => showPopUp()}
/>
{(fullnameField || emailField || passwordField) ?
<SurveyButton
text="save settings"
onPress={() => showPopUp()}
/>
: null}
</View>
<SettingsPopUp
<SettingsPopUp
isVisible={isVisible}
currentEmail={currentEmail}
currentPassword={currentPassword}
Expand Down
36 changes: 32 additions & 4 deletions js/scenes/Event/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ const EventItem = ({ item }) => (
</TouchableOpacity>
);

const SingleEvent = ({ eventData, eventDataSet, attendEvent }) => {
const SingleEvent = ({ eventData, eventDataSet, attendEvent, currentUser }) => {
const attending = eventData.attendees.find(attendee => attendee.user_id === currentUser);
return (
<View style={styles.container}>
<LinearGradient
Expand All @@ -51,7 +52,11 @@ const SingleEvent = ({ eventData, eventDataSet, attendEvent }) => {
</View>
))}
<OutlinedButton
text="attend event"
text={
(attending) ?
"you are attending" :
"attend event"
}
onPress={() => attendEvent()}
/>
</ScrollView>
Expand All @@ -62,7 +67,29 @@ const SingleEvent = ({ eventData, eventDataSet, attendEvent }) => {

SingleEvent.propTypes = {
eventData: PropTypes.shape({
//attendees: PropTypes.arrayOf(PropTypes.string),
attendees: PropTypes.arrayOf(PropTypes.shape({
bio: PropTypes.string,
email: PropTypes.string,
fullName: PropTypes.string,
goals: PropTypes.shape({
goalOne: PropTypes.string,
goalTwo: PropTypes.string,
goalThree: PropTypes.string
}),
imageUrl: PropTypes.string,
myTalks: PropTypes.arrayOf(PropTypes.string),
socialMediaUrls: PropTypes.shape({
facebook: PropTypes.string,
linkedIn: PropTypes.string,
twitter: PropTypes.string
}),
speakerStats: PropTypes.arrayOf(PropTypes.shape({
quality: PropTypes.string,
submitAmnt: PropTypes.number,
value: PropTypes.number
})),
user_id: PropTypes.string
})),
date: PropTypes.number,
startTime: PropTypes.number,
endTime: PropTypes.number,
Expand Down Expand Up @@ -91,7 +118,8 @@ SingleEvent.propTypes = {
talk_id: PropTypes.string,
title: PropTypes.string
})).isRequired,
attendEvent: PropTypes.func.isRequired
attendEvent: PropTypes.func.isRequired,
currentUser: PropTypes.string
}

export default SingleEvent;
28 changes: 24 additions & 4 deletions js/scenes/Event/EventContainer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { Text } from 'react-native';
import Moment from 'moment';
import SingleEvent from './Event';
import '../../redux/modules/actions/eventActions';
import '../../redux/modules/actions/talkActions';
import '../../redux/modules/actions/userActions';
import Loader from '../../components/Loader/';
import { eventDataSet } from '../Lib/helperFunctions';
import Router from '../../navigation/routes';
import store from '../../redux/store';
import { attendEvent } from '../../config/helpers';
import { auth } from '../../config/firebase';

Expand All @@ -36,6 +33,7 @@ class EventContainer extends Component {
return (
<SingleEvent
navigatorUID={'event'}
currentUser={auth.currentUser.uid}
attendEvent={this.attendEvent}
eventData={this.props.eventData.item}
eventDataSet={eventDataSet(
Expand Down Expand Up @@ -108,7 +106,29 @@ EventContainer.propTypes = {
}).isRequired,
eventData: PropTypes.shape({
item: PropTypes.shape({
//attendees: PropTypes.arrayOf(PropTypes.string),
attendees: PropTypes.arrayOf(PropTypes.shape({
bio: PropTypes.string,
email: PropTypes.string,
fullName: PropTypes.string,
goals: PropTypes.shape({
goalOne: PropTypes.string,
goalTwo: PropTypes.string,
goalThree: PropTypes.string
}),
imageUrl: PropTypes.string,
myTalks: PropTypes.arrayOf(PropTypes.string),
socialMediaUrls: PropTypes.shape({
facebook: PropTypes.string,
linkedIn: PropTypes.string,
twitter: PropTypes.string
}),
speakerStats: PropTypes.arrayOf(PropTypes.shape({
quality: PropTypes.string,
submitAmnt: PropTypes.number,
value: PropTypes.number
})),
user_id: PropTypes.string
})),
date: PropTypes.number,
startTime: PropTypes.number,
endTime: PropTypes.number,
Expand Down
1 change: 0 additions & 1 deletion js/scenes/Profile/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const Profile = ({ updateProfile, user, handleImageUpload, imageUrl, handleBio,

const getImage = imageUrl || user.imageUrl

console.log("THIS IS GET IMAGE", getImage)
return (
<ScrollView style={styles.container}>
<View>
Expand Down

0 comments on commit e7f3ae0

Please sign in to comment.