Commit 23d03d29 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg

Refactor some stuff

parent 40a59f7d
......@@ -46,7 +46,8 @@
"prefer-destructuring": 0,
"react/jsx-filename-extension": 0,
"react/prefer-stateless-function": 1,
"import/prefer-default-export": 1
"import/prefer-default-export": 1,
"no-multi-str": 0
},
"settings": {
"import/resolver": {
......
......@@ -49,11 +49,9 @@ build android:
- $CI_PROJECT_DIR/.gradle/wrapper/
- $CI_PROJECT_DIR/.gradle/caches/
before_script:
- sysctl fs.inotify.max_user_watches=524288
- set +o pipefail
- yes | /opt/android-sdk-linux/tools/bin/sdkmanager --licenses
- set -o pipefail
- apk update && apk add git
- yarn install
script:
- echo $SENTRY_PROPS | base64 -d > ./android/sentry.properties
......
......@@ -3,10 +3,6 @@
exports[`translations should expose the translations 1`] = `
Object {
"nl": Object {
"app/App": Object {
"Dismiss": "Sluiten",
"Open": "Openen",
},
"components/errorScreen/ErrorScreen": Object {
"Try again later.": "Probeer het later opnieuw.",
},
......@@ -61,7 +57,7 @@ Object {
"Cancel registration": "Afmelden",
"Cancel registration?": "Afmelden?",
"Cancellation deadline": "Afmelddeadline",
"Cancellation isn't possible anymore without having to pay the full costs of €{{fine}}. Also note that you will be unable to re-register.": "Afmelden is niet meer mogelijk zonder de volledige kosten van €{{fine}} te betalen. Let op: je kunt je hierna niet meer aanmelden. ",
"Cancellation isn't possible anymore without having to pay the full costs of €{{fine}}. Also note that you will be unable to re-register.": "Afmelden is niet meer mogelijk zonder de volledige kosten van €{{fine}} te betalen. Let op: je kunt je hierna niet meer aanmelden.",
"Could not load the event...": "Kan het evenement niet laden...",
"From": "Van",
"Location": "Locatie",
......@@ -118,21 +114,27 @@ Object {
"There is currently no event for which you can order food.": "Er is geen evenement waarvoor je eten kunt bestellen.",
"You did not place an order.": "Je hebt nog geen bestelling geplaatst.",
},
"screens/profile/ProfileScreen": Object {
"About": "Over",
"screens/profile/AchievementSection": Object {
"Achievements for Thalia": "Verdiensten voor Thalia",
"Birthday": "Verjaardag",
"Chair": "Voorzitter",
"Societies": "Gezelschappen",
"today": "heden",
},
"screens/profile/DescriptionSection": Object {
"About": "Over",
"This member has not written a description yet.": "Dit lid heeft nog geen beschrijving geschreven.",
},
"screens/profile/PersonalInfoSection": Object {
"Birthday": "Verjaardag",
"Cohort": "Cohort",
"Computing science": "Informatica",
"Information sciences": "Informatiekunde",
"Personal information": "Persoonlijke gegevens",
"Societies": "Gezelschappen",
"Sorry! We couldn't load any data.": "Sorry! We konden geen gegevens laden.",
"Study programme": "Studie",
"This member has not written a description yet.": "Dit lid heeft nog geen beschrijving geschreven.",
"Website": "Website",
"today": "heden",
},
"screens/profile/ProfileScreen": Object {
"Sorry! We couldn't load any data.": "Sorry! We konden geen gegevens laden.",
},
"screens/settings/NotificationsSection": Object {
"(required)": "(verplicht)",
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thaliapp">
package="com.thaliapp"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<uses-permission tools:node="remove" android:name="android.permission.READ_PHONE_STATE" />
<uses-permission tools:node="remove" android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission tools:node="remove" android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:name=".MainApplication"
......
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.thaliapp"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission tools:node="remove" android:name="android.permission.SYSTEM_ALERT_WINDOW" />
</manifest>
export const BACK = 'NAVIGATE_BACK';
export const TOGGLE_DRAWER = 'NAVIGATE_TOGGLE_DRAWER';
export const OPEN_WEBSITE = 'NAVIGATE_OPEN_WEBSITE';
export function goBack() {
return {
......@@ -12,3 +13,10 @@ export function toggleDrawer() {
type: TOGGLE_DRAWER,
};
}
export function openWebsite(url) {
return {
type: OPEN_WEBSITE,
payload: url,
};
}
const files = {};
files['app/ui/screens/profile/ProfileScreenNL'] = require('./nl/app/ui/screens/profile/ProfileScreen.json');
files['app/ui/screens/login/LoginScreenNL'] = require('./nl/app/ui/screens/login/LoginScreen.json');
files['app/ui/screens/memberList/MemberListScreenNL'] = require('./nl/app/ui/screens/memberList/MemberListScreen.json');
files['app/ui/screens/welcome/WelcomeScreenNL'] = require('./nl/app/ui/screens/welcome/WelcomeScreen.json');
files['app/ui/screens/welcome/EventDetailCardNL'] = require('./nl/app/ui/screens/welcome/EventDetailCard.json');
files['app/ui/screens/pizza/PizzaScreenNL'] = require('./nl/app/ui/screens/pizza/PizzaScreen.json');
files['app/ui/screens/settings/NotificationsSectionNL'] = require('./nl/app/ui/screens/settings/NotificationsSection.json');
files['app/ui/screens/events/CalendarScreenNL'] = require('./nl/app/ui/screens/events/CalendarScreen.json');
files['app/ui/screens/welcome/EventDetailCardNL'] = require('./nl/app/ui/screens/welcome/EventDetailCard.json');
files['app/ui/screens/welcome/WelcomeScreenNL'] = require('./nl/app/ui/screens/welcome/WelcomeScreen.json');
files['app/ui/screens/memberList/MemberListScreenNL'] = require('./nl/app/ui/screens/memberList/MemberListScreen.json');
files['app/ui/screens/profile/ProfileScreenNL'] = require('./nl/app/ui/screens/profile/ProfileScreen.json');
files['app/ui/screens/profile/AchievementSectionNL'] = require('./nl/app/ui/screens/profile/AchievementSection.json');
files['app/ui/screens/profile/DescriptionSectionNL'] = require('./nl/app/ui/screens/profile/DescriptionSection.json');
files['app/ui/screens/profile/PersonalInfoSectionNL'] = require('./nl/app/ui/screens/profile/PersonalInfoSection.json');
files['app/ui/screens/events/CalendarItemNL'] = require('./nl/app/ui/screens/events/CalendarItem.json');
files['app/ui/screens/events/RegistrationScreenNL'] = require('./nl/app/ui/screens/events/RegistrationScreen.json');
files['app/ui/screens/events/EventAdminScreenNL'] = require('./nl/app/ui/screens/events/EventAdminScreen.json');
files['app/ui/screens/events/CalendarItemNL'] = require('./nl/app/ui/screens/events/CalendarItem.json');
files['app/ui/screens/events/CalendarScreenNL'] = require('./nl/app/ui/screens/events/CalendarScreen.json');
files['app/ui/screens/events/EventScreenNL'] = require('./nl/app/ui/screens/events/EventScreen.json');
files['app/ui/screens/pizza/PizzaScreenNL'] = require('./nl/app/ui/screens/pizza/PizzaScreen.json');
files['app/ui/screens/login/LoginScreenNL'] = require('./nl/app/ui/screens/login/LoginScreen.json');
files['app/ui/components/sidebar/SidebarNL'] = require('./nl/app/ui/components/sidebar/Sidebar.json');
files['app/ui/components/standardHeader/StandardHeaderNL'] = require('./nl/app/ui/components/standardHeader/StandardHeader.json');
files['app/ui/components/errorScreen/ErrorScreenNL'] = require('./nl/app/ui/components/errorScreen/ErrorScreen.json');
files['app/ui/components/sidebar/SidebarNL'] = require('./nl/app/ui/components/sidebar/Sidebar.json');
files['app/AppNL'] = require('./nl/app.json');
export default {
nl: {
'screens/profile/ProfileScreen': files['app/ui/screens/profile/ProfileScreenNL'],
'screens/login/LoginScreen': files['app/ui/screens/login/LoginScreenNL'],
'screens/memberList/MemberListScreen': files['app/ui/screens/memberList/MemberListScreenNL'],
'screens/welcome/WelcomeScreen': files['app/ui/screens/welcome/WelcomeScreenNL'],
'screens/welcome/EventDetailCard': files['app/ui/screens/welcome/EventDetailCardNL'],
'screens/pizza/PizzaScreen': files['app/ui/screens/pizza/PizzaScreenNL'],
'screens/settings/NotificationsSection': files['app/ui/screens/settings/NotificationsSectionNL'],
'screens/events/CalendarScreen': files['app/ui/screens/events/CalendarScreenNL'],
'screens/welcome/EventDetailCard': files['app/ui/screens/welcome/EventDetailCardNL'],
'screens/welcome/WelcomeScreen': files['app/ui/screens/welcome/WelcomeScreenNL'],
'screens/memberList/MemberListScreen': files['app/ui/screens/memberList/MemberListScreenNL'],
'screens/profile/ProfileScreen': files['app/ui/screens/profile/ProfileScreenNL'],
'screens/profile/AchievementSection': files['app/ui/screens/profile/AchievementSectionNL'],
'screens/profile/DescriptionSection': files['app/ui/screens/profile/DescriptionSectionNL'],
'screens/profile/PersonalInfoSection': files['app/ui/screens/profile/PersonalInfoSectionNL'],
'screens/events/CalendarItem': files['app/ui/screens/events/CalendarItemNL'],
'screens/events/RegistrationScreen': files['app/ui/screens/events/RegistrationScreenNL'],
'screens/events/EventAdminScreen': files['app/ui/screens/events/EventAdminScreenNL'],
'screens/events/CalendarItem': files['app/ui/screens/events/CalendarItemNL'],
'screens/events/CalendarScreen': files['app/ui/screens/events/CalendarScreenNL'],
'screens/events/EventScreen': files['app/ui/screens/events/EventScreenNL'],
'screens/pizza/PizzaScreen': files['app/ui/screens/pizza/PizzaScreenNL'],
'screens/login/LoginScreen': files['app/ui/screens/login/LoginScreenNL'],
'components/sidebar/Sidebar': files['app/ui/components/sidebar/SidebarNL'],
'components/standardHeader/StandardHeader': files['app/ui/components/standardHeader/StandardHeaderNL'],
'components/errorScreen/ErrorScreen': files['app/ui/components/errorScreen/ErrorScreenNL'],
'components/sidebar/Sidebar': files['app/ui/components/sidebar/SidebarNL'],
'app/App': files['app/AppNL'],
},
};
{
"Are you sure you want to cancel your registration?": "Weet je je zeker dat je je wilt afmelden?",
"The deadline has passed, are you sure you want to cancel your registration and pay the full costs of €{{ fine }}? You will not be able to undo this!": "De deadline is verstreken, weet je zeker dat je je wilt afmelden? Dit betekent dat je de volledige kosten van €{{ fine }} zult moeten betalen. Je kunt dit niet ongedaan maken!",
"Cancel registration?": "Afmelden?",
"No": "Nee",
"Yes": "Ja",
......@@ -21,7 +20,6 @@
"No registration required.": "Aanmelden niet vereist.",
"Registration will open {{start}}": "Aanmelden opent {{start}}",
"Registration is not possible anymore.": "Aanmelden is niet meer mogelijk.",
"Cancellation isn't possible anymore without having to pay the full costs of €{{fine}}. Also note that you will be unable to re-register.": "Afmelden is niet meer mogelijk zonder de volledige kosten van €{{fine}} te betalen. Let op: je kunt je hierna niet meer aanmelden. ",
"Put me on the waiting list": "Zet me op de wachtlijst",
"Register": "Aanmelden",
"By registering, you confirm that you have read the": "Door te registreren, bevestig je dat je de",
......@@ -31,5 +29,7 @@
"Cancel registration": "Afmelden",
"Registrations": "Aanmeldingen",
"Could not load the event...": "Kan het evenement niet laden...",
"Registration is not allowed anymore, as you cancelled your registration after the deadline.": "Aanmelden is niet meer toegestaan omdat je bent afgemeld na de afmelddeadline."
"Registration is not allowed anymore, as you cancelled your registration after the deadline.": "Aanmelden is niet meer toegestaan omdat je bent afgemeld na de afmelddeadline.",
"The deadline has passed, are you sure you want to cancel your registration and pay the full costs of €{{ fine }}? You will not be able to undo this!": "De deadline is verstreken, weet je zeker dat je je wilt afmelden? Dit betekent dat je de volledige kosten van €{{ fine }} zult moeten betalen. Je kunt dit niet ongedaan maken!",
"Cancellation isn't possible anymore without having to pay the full costs of €{{fine}}. Also note that you will be unable to re-register.": "Afmelden is niet meer mogelijk zonder de volledige kosten van €{{fine}} te betalen. Let op: je kunt je hierna niet meer aanmelden."
}
{
"Achievements for Thalia": "Verdiensten voor Thalia",
"today": "heden",
"Chair": "Voorzitter",
"Societies": "Gezelschappen"
}
{
"About": "Over",
"This member has not written a description yet.": "Dit lid heeft nog geen beschrijving geschreven."
}
{
"Cohort": "Cohort",
"Study programme": "Studie",
"Computing science": "Informatica",
"Information sciences": "Informatiekunde",
"Website": "Website",
"Birthday": "Verjaardag",
"Personal information": "Persoonlijke gegevens"
}
{
"About": "Over",
"This member has not written a description yet.": "Dit lid heeft nog geen beschrijving geschreven.",
"Cohort": "Cohort",
"Study programme": "Studie",
"Computing science": "Informatica",
"Information sciences": "Informatiekunde",
"Website": "Website",
"Birthday": "Verjaardag",
"Personal information": "Persoonlijke gegevens",
"Achievements for Thalia": "Verdiensten voor Thalia",
"today": "heden",
"Chair": "Voorzitter",
"Sorry! We couldn't load any data.": "Sorry! We konden geen gegevens laden.",
"Societies": "Gezelschappen"
"Sorry! We couldn't load any data.": "Sorry! We konden geen gegevens laden."
}
......@@ -6,18 +6,18 @@ import {
DrawerActions,
} from 'react-navigation';
import Login from './ui/screens/login/LoginScreenContainer';
import Welcome from './ui/screens/welcome/WelcomeScreenContainer';
import Event from './ui/screens/events/EventScreenContainer';
import Calendar from './ui/screens/events/CalendarScreenContainer';
import Profile from './ui/screens/profile/ProfileScreenContainer';
import Pizza from './ui/screens/pizza/PizzaScreenContainer';
import Registration from './ui/screens/events/RegistrationScreenContainer';
import MemberList from './ui/screens/memberList/MemberListScreenContainer';
import Login from './ui/screens/login/LoginScreenConnector';
import Welcome from './ui/screens/welcome/WelcomeScreenConnector';
import Event from './ui/screens/events/EventScreenConnector';
import Calendar from './ui/screens/events/CalendarScreenConnector';
import Profile from './ui/screens/profile/ProfileScreenConnector';
import Pizza from './ui/screens/pizza/PizzaScreenConnector';
import Registration from './ui/screens/events/RegistrationScreenConnector';
import MemberList from './ui/screens/memberList/MemberListScreenConnector';
import SplashScreen from './ui/screens/splash/SplashScreen';
import Settings from './ui/screens/settings/SettingsScreenContainer';
import EventAdmin from './ui/screens/events/EventAdminScreenContainer';
import Sidebar from './ui/components/sidebar/SidebarContainer';
import Settings from './ui/screens/settings/SettingsScreenConnector';
import EventAdmin from './ui/screens/events/EventAdminScreenConnector';
import Sidebar from './ui/components/sidebar/SidebarConnector';
const MainNavigator = createDrawerNavigator({
Welcome,
......
import { Linking } from 'react-native';
import { takeEvery, call } from 'redux-saga/effects';
import * as navigationActions from '../actions/navigation';
import * as eventActions from '../actions/event';
......@@ -23,9 +24,14 @@ function* toggleDrawer() {
yield call(NavigationService.toggleDrawer);
}
function openWebsite({ payload: url }) {
Linking.openURL(url);
}
const routerSaga = function* eventSaga() {
yield takeEvery(navigationActions.BACK, back);
yield takeEvery(navigationActions.TOGGLE_DRAWER, toggleDrawer);
yield takeEvery(navigationActions.OPEN_WEBSITE, openWebsite);
yield takeEvery(welcomeActions.OPEN, navigate, 'Welcome');
yield takeEvery(settingsActions.OPEN, navigate, 'Settings');
yield takeEvery(calendarActions.OPEN, navigate, 'Calendar');
......
......@@ -2,8 +2,8 @@ import { connect } from 'react-redux';
import * as profileActions from '../../../actions/profile';
import MemberView from './MemberView';
const mapDispatchToProps = dispatch => ({
loadProfile: pk => dispatch(profileActions.profile(pk)),
});
const mapDispatchToProps = {
loadProfile: profileActions.profile,
};
export default connect(() => ({}), mapDispatchToProps)(MemberView);
......@@ -12,13 +12,13 @@ const mapStateToProps = state => ({
photo: state.session.photo,
});
const mapDispatchToProps = dispatch => ({
loadProfile: () => dispatch(profileActions.profile()),
openCalendar: () => dispatch(calendarActions.open()),
openMemberList: () => dispatch(membersActions.members()),
openWelcome: () => dispatch(welcomeActions.open()),
openSettings: () => dispatch(settingsActions.open()),
signOut: () => dispatch(loginActions.signOut()),
});
const mapDispatchToProps = {
loadProfile: profileActions.profile,
openCalendar: calendarActions.open,
openMemberList: membersActions.members,
openWelcome: welcomeActions.open,
openSettings: settingsActions.open,
signOut: loginActions.signOut,
};
export default connect(mapStateToProps, mapDispatchToProps)(Sidebar);
import { Linking } from 'react-native';
import { connect } from 'react-redux';
import * as eventActions from '../../../actions/event';
import CalendarItem from './CalendarItem';
import * as navigationActions from '../../../actions/navigation';
const mapDispatchToProps = dispatch => ({
const mapDispatchToProps = {
loadEvent: (event) => {
if (event.partner) {
Linking.openURL(event.url);
} else {
dispatch(eventActions.event(event.pk));
return navigationActions.openWebsite(event.url);
}
return eventActions.event(event.pk);
},
});
};
export default connect(() => ({}), mapDispatchToProps)(CalendarItem);
......@@ -6,7 +6,7 @@ import {
import { translate } from 'react-i18next';
import Moment from 'moment';
import locale from 'react-native-locale-detector';
import CalendarItem from './CalendarItemContainer';
import CalendarItem from './CalendarItemConnector';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import ErrorScreen from '../../components/errorScreen/ErrorScreen';
......
......@@ -8,8 +8,8 @@ const mapStateToProps = state => ({
status: state.calendar.status,
});
const mapDispatchToProps = dispatch => ({
refresh: () => dispatch(calendarActions.refresh()),
});
const mapDispatchToProps = {
refresh: calendarActions.refresh,
};
export default connect(mapStateToProps, mapDispatchToProps)(CalendarScreen);
......@@ -13,7 +13,7 @@ import Colors from '../../style/Colors';
import StandardHeader from '../../components/standardHeader/StandardHeader';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import ErrorScreen from '../../components/errorScreen/ErrorScreen';
import SearchHeader from '../../components/searchHeader/SearchHeaderContainer';
import SearchHeader from '../../components/searchHeader/SearchHeaderConnector';
import Button from '../../components/button/Button';
const PAYMENT_TYPES = {
......
......@@ -10,12 +10,10 @@ const mapStateToProps = state => ({
loading: state.event.loading,
});
const mapDispatchToProps = dispatch => ({
refresh: pk => dispatch(eventActions.event(pk, false)),
updateRegistration: (pk, present, payment) => dispatch(
eventActions.updateRegistration(pk, present, payment),
),
goBack: () => dispatch(navigationActions.goBack()),
});
const mapDispatchToProps = {
refresh: pk => eventActions.event(pk, false),
updateRegistration: eventActions.updateRegistration,
goBack: navigationActions.goBack,
};
export default connect(mapStateToProps, mapDispatchToProps)(EventAdminScreen);
......@@ -4,7 +4,6 @@ import {
Alert,
FlatList,
Image,
Linking,
RefreshControl,
ScrollView,
Text,
......@@ -19,7 +18,7 @@ import Share from 'react-native-share';
import Icon from 'react-native-vector-icons/MaterialIcons';
import styles, { memberSize } from './style/EventScreen';
import MemberView from '../../components/memberView/MemberViewContainer';
import MemberView from '../../components/memberView/MemberViewConnector';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import ErrorScreen from '../../components/errorScreen/ErrorScreen';
import Colors from '../../style/Colors';
......@@ -34,8 +33,8 @@ class EventScreen extends Component {
const cancelDeadlineDate = new Date(data.cancel_deadline);
let message = t('Are you sure you want to cancel your registration?');
if (data.cancel_deadline !== null && cancelDeadlineDate <= new Date()) {
message = t('The deadline has passed, are you sure you want to cancel your '
+ 'registration and pay the full costs of €{{ fine }}? You will not be able to undo this!',
message = t('The deadline has passed, are you sure you want to cancel your \
registration and pay the full costs of €{{ fine }}? You will not be able to undo this!',
{ fine: data.fine });
}
return Alert.alert(
......@@ -256,8 +255,8 @@ class EventScreen extends Component {
text += ' ';
}
text += t(
'Cancellation isn\'t possible anymore without having to pay the full '
+ 'costs of €{{fine}}. Also note that you will be unable to re-register.',
'Cancellation isn\'t possible anymore without having to pay the full \
costs of €{{fine}}. Also note that you will be unable to re-register.',
{ fine: data.fine },
);
}
......@@ -274,7 +273,7 @@ class EventScreen extends Component {
eventActions = () => {
const {
data, register, t,
data, register, t, openUrl,
} = this.props;
const {
......@@ -293,7 +292,7 @@ class EventScreen extends Component {
{t('By registering, you confirm that you have read the')}
<Text
style={styles.termsUrl}
onPress={() => Linking.openURL(termsAndConditionsUrl)}
onPress={() => openUrl(termsAndConditionsUrl)}
>
{' '}
{t('terms and conditions')}
......@@ -380,7 +379,7 @@ class EventScreen extends Component {
render() {
const {
status, loading, openMaps, data, t, openAdmin,
status, loading, openMaps, data, t, openAdmin, openUrl,
} = this.props;
const shareButton = (
......@@ -471,7 +470,7 @@ class EventScreen extends Component {
<View style={styles.divider} />
<HTML
html={data.description}
onLinkPress={(event, href) => Linking.openURL(href)}
onLinkPress={(event, href) => openUrl(href)}
baseFontStyle={fontStyles}
tagsStyles={{
a: linkStyles,
......@@ -553,6 +552,7 @@ EventScreen.propTypes = {
openMaps: PropTypes.func.isRequired,
retrievePizzaInfo: PropTypes.func.isRequired,
openAdmin: PropTypes.func.isRequired,
openUrl: PropTypes.func.isRequired,
t: PropTypes.func.isRequired,
};
......
import { Linking, Platform } from 'react-native';
import { Platform } from 'react-native';
import { connect } from 'react-redux';
import * as pizzaActions from '../../../actions/pizza';
import * as registrationActions from '../../../actions/registration';
import * as eventActions from '../../../actions/event';
import EventScreen from './EventScreen';
import * as navigationActions from '../../../actions/navigation';
const mapStateToProps = state => ({
data: state.event.data,
......@@ -12,14 +13,15 @@ const mapStateToProps = state => ({
loading: state.event.loading,
});
const mapDispatchToProps = dispatch => ({
refresh: pk => dispatch(eventActions.event(pk)),
register: event => dispatch(registrationActions.register(event)),
cancel: registration => dispatch(registrationActions.cancel(registration)),
fields: registration => dispatch(registrationActions.retrieveFields(registration)),
openMaps: location => Linking.openURL(`https://maps.${Platform.OS === 'ios' ? 'apple' : 'google'}.com/maps?daddr=${location}`),
retrievePizzaInfo: () => dispatch(pizzaActions.retrievePizzaInfo()),
openAdmin: () => (dispatch(eventActions.admin())),
});
const mapDispatchToProps = {
refresh: eventActions.event,
register: registrationActions.register,
cancel: registrationActions.cancel,
fields: registrationActions.retrieveFields,
openMaps: location => this.openUrl(`https://maps.${Platform.OS === 'ios' ? 'apple' : 'google'}.com/maps?daddr=${location}`),
openUrl: navigationActions.openWebsite,
retrievePizzaInfo: pizzaActions.retrievePizzaInfo,
openAdmin: eventActions.admin,
};
export default connect(mapStateToProps, mapDispatchToProps)(EventScreen);
......@@ -2,7 +2,6 @@ import React, { Component } from 'react';
import {
ActivityIndicator,
KeyboardAvoidingView,
Linking,
Modal,
ScrollView,
Switch,
......@@ -90,11 +89,15 @@ class RegistrationScreen extends Component {
};
render() {
if (this.props.status === 'failure') {
return <ErrorScreen message={this.props.t('Sorry! We couldn\'t load any data.')} />;
const {
status, fields, openUrl, update, t, registration,
} = this.props;
if (status === 'failure') {
return <ErrorScreen message={t('Sorry! We couldn\'t load any data.')} />;
}
const keys = Object.keys(this.props.fields);
const keys = Object.keys(fields);
const linkStyles = {
color: Colors.magenta,
......@@ -111,7 +114,7 @@ class RegistrationScreen extends Component {
keyboardShouldPersistTaps="handled"
>
<Modal
visible={this.props.status === 'loading'}
visible={status === 'loading'}
transparent
onRequestClose={() => ({})}
>
......@@ -124,7 +127,7 @@ class RegistrationScreen extends Component {
</View>
</Modal>
{keys.map((key) => {
const field = this.props.fields[key];
const field = fields[key];
const validity = this.getFieldValidity(key);
if (field.type === 'boolean') {
return (
......@@ -145,7 +148,7 @@ class RegistrationScreen extends Component {
</View>
<HTML
html={field.description}
onLinkPress={(event, href) => Linking.openURL(href)}
onLinkPress={(event, href) => openUrl(href)}
baseFontStyle={styles.description}
tagsStyles={{
a: linkStyles,
......@@ -166,7 +169,7 @@ class RegistrationScreen extends Component {
</Text>
<HTML
html={field.description}
onLinkPress={(event, href) => Linking.openURL(href)}
onLinkPress={(event, href) => openUrl(href)}
baseFontStyle={styles.description}
tagsStyles={{
a: linkStyles,
......@@ -190,12 +193,12 @@ class RegistrationScreen extends Component {
}
return <View />;
})}
{this.props.status !== 'loading' && (
{status !== 'loading' && (
<View style={styles.buttonView}>
<Button
title={this.props.t('Save')}
title={t('Save')}
color={Colors.magenta}
onPress={() => this.props.update(this.props.registration, this.state)}