Commit 940d4cab authored by Gijs Hendriksen's avatar Gijs Hendriksen
Browse files

Merge branch 'feature/partner-events' into 'master'

Add ability to show partner events

See merge request !69
parents 8577c76a e9fcecf2
......@@ -162,6 +162,8 @@ Calendar.propTypes = {
price: PropTypes.string,
registered: PropTypes.bool,
pizza: PropTypes.bool,
partner: PropTypes.bool,
url: PropTypes.string,
})).isRequired,
loading: PropTypes.bool.isRequired,
refresh: PropTypes.func.isRequired,
......
import React from 'react';
import PropTypes from 'prop-types';
import { View, Text, TouchableHighlight } from 'react-native';
import { View, Text, TouchableHighlight, Linking } from 'react-native';
import { connect } from 'react-redux';
import Moment from 'moment';
import 'moment/locale/nl';
......@@ -23,12 +23,22 @@ const getEventInfo = (event) => {
const EventCard = props => (
<TouchableHighlight
onPress={() => props.loadEvent(props.event.pk, props.token)}
onPress={() => props.loadEvent(props.event, props.token)}
style={styles.button}
>
<View style={[styles.card, props.event.registered ? styles.registered : styles.unregistered]}>
<Text style={styles.eventTitle}>{props.event.title}</Text>
<Text style={styles.eventInfo}>{getEventInfo(props.event)}</Text>
<View
style={[
styles.card,
props.event.registered ? styles.registered : null,
props.event.partner ? styles.partner : null,
]}
>
<Text style={[styles.eventTitle, props.event.partner ? styles.partnerEventTitle : null]}>
{props.event.title}
</Text>
<Text style={[styles.eventInfo, props.event.partner ? styles.partnerEventInfo : null]}>
{getEventInfo(props.event)}
</Text>
</View>
</TouchableHighlight>
);
......@@ -44,6 +54,8 @@ EventCard.propTypes = {
pk: PropTypes.number,
registered: PropTypes.bool,
pizza: PropTypes.bool,
partner: PropTypes.bool,
url: PropTypes.string,
}).isRequired,
loadEvent: PropTypes.func.isRequired,
token: PropTypes.string.isRequired,
......@@ -54,7 +66,13 @@ const mapStateToProps = state => ({
});
const mapDispatchToProps = dispatch => ({
loadEvent: (pk, token) => dispatch(eventActions.event(pk, token)),
loadEvent: (event, token) => {
if (event.partner) {
Linking.openURL(event.url);
} else {
dispatch(eventActions.event(event.pk, token));
}
},
});
export default connect(mapStateToProps, mapDispatchToProps)(EventCard);
......@@ -13,22 +13,29 @@ const styles = StyleSheet.create({
card: {
padding: 16,
borderRadius: 2,
backgroundColor: colors.gray,
},
registered: {
backgroundColor: colors.magenta,
},
unregistered: {
backgroundColor: colors.gray,
partner: {
backgroundColor: colors.black,
},
eventTitle: {
fontFamily: 'sans-serif-medium',
color: colors.white,
},
partnerEventTitle: {
color: colors.magenta,
},
eventInfo: {
fontFamily: 'sans-serif-medium',
color: colors.white,
opacity: 0.8,
},
partnerEventInfo: {
color: colors.magenta,
},
});
export default styles;
......@@ -17,7 +17,18 @@ const calendar = function* calendar() {
try {
const events = yield call(apiRequest, 'events', data);
yield put(calendarActions.success(events));
let partnerEvents = [];
try {
partnerEvents = yield call(apiRequest, 'partners/events', data);
partnerEvents = partnerEvents.map(event => ({
...event,
pk: -event.pk,
partner: true,
}));
} catch (error) {
// Swallow the error
}
yield put(calendarActions.success(events.concat(partnerEvents)));
} catch (error) {
yield put(calendarActions.failure());
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment