-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Event Registration and Checkin #65
Open
jacqueschen1
wants to merge
3
commits into
master
Choose a base branch
from
eventreg
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
@@ -1,41 +1,98 @@ | ||
import React, { Component } from 'react'; | ||
import { View, Dimensions, Image } from 'react-native'; | ||
import { connect } from 'react-redux'; | ||
import { getRegistrations, registerUser } from '../actions/Login'; | ||
|
||
const { width, height } = Dimensions.get('window'); | ||
//styling | ||
import styles from '../styles/Styles'; | ||
import Text from '../components/Text' | ||
|
||
import Button from '../components/Button' | ||
|
||
export default class EventScreen extends Component { | ||
|
||
class EventScreen extends Component { | ||
|
||
componentDidMount() { | ||
this.props.getRegistrations(this.props.userData.id); | ||
}; | ||
|
||
state = { disableButton: false }; | ||
|
||
getDescription(event) { | ||
if (event.description) { | ||
return event.description | ||
return event.description; | ||
} else { | ||
return "It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like)." | ||
} | ||
} | ||
}; | ||
|
||
getRegistrationStatus(eventID) { | ||
const entry = this.props.registration.data.filter(entry => entry.eventID == eventID); | ||
if (entry.length == 1) { | ||
this.state.disableButton = true; | ||
if (entry[0].registrationStatus == 'registered') { | ||
return 'You have registered for this event!'; | ||
} else if (entry[0].registrationStatus == 'waitlist') { | ||
return 'You have been added to the waitlist for this event.'; | ||
} else if (entry[0].registrationStatus == 'checkedin') { | ||
return "You've checked into this event!"; | ||
} | ||
} else { | ||
return 'Click below to register!'; | ||
} | ||
}; | ||
|
||
handleRegistration(eventID) { | ||
if (!this.state.disableButton) { | ||
this.props.registerUser(this.props.userData.id, eventID); | ||
} | ||
}; | ||
|
||
|
||
render() { | ||
if (this.props.isLoading) { | ||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.h1}>Loading Screen</Text> | ||
</View> | ||
) | ||
} | ||
const { navigation } = this.props | ||
const event = navigation.getParam('event') | ||
return ( | ||
<View> | ||
<Image | ||
source={{ uri: event.img }} | ||
source={{ uri: event.imageUrl }} | ||
style={{ width: width, height: 240, marginBottom: 10 }} | ||
resizeMode="cover" | ||
resizeMode='cover' | ||
/> | ||
<View style={styles.widgetContainer}> | ||
<Text style={styles.h1}>{event.ename}</Text> | ||
<Text style={styles.colour} >{event.edate}</Text> | ||
<Text>{this.getDescription(event)}</Text> | ||
<Button title='Sign Up' /> | ||
<Text style={styles.h3}>{this.getRegistrationStatus(event.id)}</Text> | ||
<Button title='Sign Up' | ||
disabled={this.state.disableButton} | ||
onPress={this.handleRegistration.bind(this, event.id)} /> | ||
</View> | ||
</View> | ||
) | ||
} | ||
} | ||
|
||
const mapStateToProps = (state) => { | ||
return { | ||
userData: state.login.user, | ||
registration: state.login.registration, | ||
isLoading: state.login.isLoading | ||
} | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch) => { | ||
return { | ||
getRegistrations: (id) => dispatch(getRegistrations(id)), | ||
registerUser: (id, eventID) => dispatch(registerUser(id, eventID)) | ||
}; | ||
}; | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(EventScreen); |
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will need authentication headers as well