Verified Commit 58565aa3 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Move Redux connect to wrapping Container components and relocate several screen

parent 4641c5b3
import React, { Component } from 'react';
import { View, FlatList } from 'react-native';
import { connect } from 'react-redux';
import { FlatList, View } from 'react-native';
import { translate } from 'react-i18next';
import PropTypes from 'prop-types';
import MemberView from '../../components/memberView/MemberView';
import MemberView from '../../components/memberView/MemberViewContainer';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import ErrorScreen from '../../components/errorScreen/ErrorScreen';
import SearchBar from './SearchHeader';
import * as memberActions from '../../../actions/members';
import SearchHeader from './SearchHeaderContainer';
import styles, { memberSize } from './style/MemberList';
import DismissKeyboardView from '../../components/dismissKeyboardView/DismissKeyboardView';
class MemberList extends Component {
class MemberListScreen extends Component {
componentDidMount = () => {
const { searchKey } = this.props;
this.props.loadMembers(searchKey);
......@@ -33,7 +31,7 @@ class MemberList extends Component {
render() {
const header = (
<SearchBar
<SearchHeader
title={this.props.t('Member List')}
searchText={this.props.t('Find a member')}
search={key => this.props.loadMembers(key)}
......@@ -86,11 +84,11 @@ class MemberList extends Component {
}
}
MemberList.defaultProps = {
MemberListScreen.defaultProps = {
more: null,
};
MemberList.propTypes = {
MemberListScreen.propTypes = {
memberList: PropTypes.arrayOf(PropTypes.shape({
pk: PropTypes.number.isRequired,
display_name: PropTypes.string.isRequired,
......@@ -105,17 +103,4 @@ MemberList.propTypes = {
t: PropTypes.func.isRequired,
};
const mapStateToProps = state => ({
memberList: state.members.memberList,
status: state.members.status,
loading: state.members.loading,
more: state.members.more,
searchKey: state.members.searchKey,
});
const mapDispatchToProps = dispatch => ({
loadMembers: (keywords = null) => dispatch(memberActions.members(keywords)),
loadMoreMembers: url => dispatch(memberActions.more(url)),
});
export default connect(mapStateToProps, mapDispatchToProps)(translate('screens/memberList/MemberList')(MemberList));
export default translate('screens/memberList/MemberList')(MemberListScreen);
import { connect } from 'react-redux';
import * as memberActions from '../../../actions/members';
import MemberList from './MemberListScreen';
const mapStateToProps = state => ({
memberList: state.members.memberList,
status: state.members.status,
loading: state.members.loading,
more: state.members.more,
searchKey: state.members.searchKey,
});
const mapDispatchToProps = dispatch => ({
loadMembers: (keywords = null) => dispatch(memberActions.members(keywords)),
loadMoreMembers: url => dispatch(memberActions.more(url)),
});
export default connect(mapStateToProps, mapDispatchToProps)(MemberList);
......@@ -11,15 +11,13 @@ import {
View,
} from 'react-native';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import Icon from 'react-native-vector-icons/MaterialIcons';
import styles from './style/SearchHeader';
import Colors from '../../style/Colors';
import * as navigationActions from '../../../actions/navigation';
class SearchBar extends Component {
class SearchHeader extends Component {
constructor(props) {
super(props);
......@@ -174,7 +172,7 @@ class SearchBar extends Component {
}
}
SearchBar.propTypes = {
SearchHeader.propTypes = {
title: PropTypes.string.isRequired,
searchText: PropTypes.string.isRequired,
search: PropTypes.func.isRequired,
......@@ -182,8 +180,4 @@ SearchBar.propTypes = {
toggleDrawer: PropTypes.func.isRequired,
};
const mapDispatchToProps = dispatch => ({
toggleDrawer: () => dispatch(navigationActions.toggleDrawer()),
});
export default connect(() => ({}), mapDispatchToProps)(SearchBar);
export default SearchHeader;
import { connect } from 'react-redux';
import * as navigationActions from '../../../actions/navigation';
import SearchHeader from './SearchHeader';
const mapDispatchToProps = dispatch => ({
toggleDrawer: () => dispatch(navigationActions.toggleDrawer()),
});
export default connect(() => ({}), mapDispatchToProps)(SearchHeader);
......@@ -3,20 +3,17 @@ import PropTypes from 'prop-types';
import {
RefreshControl, ScrollView, Text, TouchableHighlight, View,
} from 'react-native';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import Icon from 'react-native-vector-icons/MaterialIcons';
import Moment from 'moment';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import ErrorScreen from '../../components/errorScreen/ErrorScreen';
import { retrievePizzaInfo, cancelOrder, orderPizza } from '../../../actions/pizza';
import styles from './style/Pizza';
import styles from './style/PizzaScreen';
import Colors from '../../style/Colors';
import { withStandardHeader } from '../../components/standardHeader/StandardHeader';
import CardSection from '../../components/cardSection/CardSection';
class Pizza extends Component {
class PizzaScreen extends Component {
getProductFromList = (pk, pizzaList) => {
for (let i = 0; i < pizzaList.length; i += 1) {
if (pizzaList[i].pk === pk) {
......@@ -242,7 +239,7 @@ class Pizza extends Component {
}
}
Pizza.propTypes = {
PizzaScreen.propTypes = {
success: PropTypes.bool.isRequired,
loading: PropTypes.bool.isRequired,
hasLoaded: PropTypes.bool.isRequired,
......@@ -272,24 +269,9 @@ Pizza.propTypes = {
t: PropTypes.func.isRequired,
};
Pizza.defaultProps = {
PizzaScreen.defaultProps = {
event: null,
order: null,
};
const mapStateToProps = state => ({
success: state.pizza.success,
loading: state.pizza.loading,
hasLoaded: state.pizza.hasLoaded,
event: state.pizza.event,
order: state.pizza.order,
pizzaList: state.pizza.pizzaList,
});
const mapDispatchToProps = dispatch => ({
loadPizzas: () => dispatch(retrievePizzaInfo()),
cancelPizza: () => dispatch(cancelOrder()),
orderPizza: (pk, hasOrder) => dispatch(orderPizza(pk, hasOrder)),
});
export default connect(mapStateToProps, mapDispatchToProps)(translate('screens/pizza/Pizza')(withStandardHeader(Pizza)));
export default translate('screens/pizza/Pizza')(withStandardHeader(PizzaScreen));
import { connect } from 'react-redux';
import { cancelOrder, orderPizza, retrievePizzaInfo } from '../../../actions/pizza';
import PizzaScreen from './PizzaScreen';
const mapStateToProps = state => ({
success: state.pizza.success,
loading: state.pizza.loading,
hasLoaded: state.pizza.hasLoaded,
event: state.pizza.event,
order: state.pizza.order,
pizzaList: state.pizza.pizzaList,
});
const mapDispatchToProps = dispatch => ({
loadPizzas: () => dispatch(retrievePizzaInfo()),
cancelPizza: () => dispatch(cancelOrder()),
orderPizza: (pk, hasOrder) => dispatch(orderPizza(pk, hasOrder)),
});
export default connect(mapStateToProps, mapDispatchToProps)(PizzaScreen);
......@@ -11,7 +11,6 @@ import {
TouchableOpacity,
View,
} from 'react-native';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import Icon from 'react-native-vector-icons/MaterialIcons';
import LinearGradient from 'react-native-linear-gradient';
......@@ -21,8 +20,6 @@ import StandardHeader from '../../components/standardHeader/StandardHeader';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import ErrorScreen from '../../components/errorScreen/ErrorScreen';
import * as navigationActions from '../../../actions/navigation';
import Colors from '../../style/Colors';
import { STATUSBAR_HEIGHT } from '../../components/standardHeader/style/StandardHeader';
......@@ -139,7 +136,7 @@ const getAchievements = (profile, t) => {
return <View />;
};
class Profile extends Component {
class ProfileScreen extends Component {
constructor(props) {
super(props);
this.scrollY = new Animated.Value(0);
......@@ -290,7 +287,7 @@ class Profile extends Component {
}
}
Profile.propTypes = {
ProfileScreen.propTypes = {
profile: PropTypes.shape({
pk: PropTypes.number.isRequired,
display_name: PropTypes.string.isRequired,
......@@ -324,14 +321,4 @@ Profile.propTypes = {
goBack: PropTypes.func.isRequired,
};
const mapStateToProps = state => ({
profile: state.profile.profile,
success: state.profile.success,
hasLoaded: state.profile.hasLoaded,
});
const mapDispatchToProps = dispatch => ({
goBack: () => dispatch(navigationActions.goBack()),
});
export default connect(mapStateToProps, mapDispatchToProps)(translate('screens/user/Profile')(Profile));
export default translate('screens/user/Profile')(ProfileScreen);
import { connect } from 'react-redux';
import * as navigationActions from '../../../actions/navigation';
import ProfileScreen from './ProfileScreen';
const mapStateToProps = state => ({
profile: state.profile.profile,
success: state.profile.success,
hasLoaded: state.profile.hasLoaded,
});
const mapDispatchToProps = dispatch => ({
goBack: () => dispatch(navigationActions.goBack()),
});
export default connect(mapStateToProps, mapDispatchToProps)(ProfileScreen);
import React, { Component } from 'react';
import { Switch, Text, View } from 'react-native';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import { translate } from 'react-i18next';
import styles from './style/NotificationsSection';
import Colors from '../../style/Colors';
import { notificationsSettingsActions } from '../../../actions/settings';
import CardSection from '../../components/cardSection/CardSection';
const GENERAL_KEY = 'general';
......@@ -95,13 +92,4 @@ NotificationsSection.propTypes = {
t: PropTypes.func.isRequired,
};
const mapStateToProps = state => ({
categoryList: state.settings.pushNotifications.categoryList,
status: state.settings.pushNotifications.status,
});
const mapDispatchToProps = dispatch => ({
saveCategories: catList => dispatch(notificationsSettingsActions.saveCategories(catList)),
});
export default connect(mapStateToProps, mapDispatchToProps)(translate('screens/settings/PushNotifications')(NotificationsSection));
export default translate('screens/settings/PushNotifications')(NotificationsSection);
import { connect } from 'react-redux';
import { notificationsSettingsActions } from '../../../actions/settings';
import NotificationsSection from './NotificationsSection';
const mapStateToProps = state => ({
categoryList: state.settings.pushNotifications.categoryList,
status: state.settings.pushNotifications.status,
});
const mapDispatchToProps = dispatch => ({
saveCategories: catList => dispatch(notificationsSettingsActions.saveCategories(catList)),
});
export default connect(mapStateToProps, mapDispatchToProps)(NotificationsSection);
import React from 'react';
import { ScrollView, View } from 'react-native';
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import styles from './style/Settings';
import { settingsActions } from '../../../actions/settings';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import NotificationsSection from './NotificationsSection';
import NotificationsSection from './NotificationsSectionContainer';
import { withStandardHeader } from '../../components/standardHeader/StandardHeader';
class Settings extends React.Component {
class SettingsScreen extends React.Component {
componentDidMount() {
this.props.init();
}
......@@ -36,17 +33,9 @@ class Settings extends React.Component {
}
}
Settings.propTypes = {
SettingsScreen.propTypes = {
init: PropTypes.func.isRequired,
loading: PropTypes.bool.isRequired,
};
const mapStateToProps = state => ({
loading: state.settings.loading,
});
const mapDispatchToProps = dispatch => ({
init: () => dispatch(settingsActions.initStart()),
});
export default connect(mapStateToProps, mapDispatchToProps)(withStandardHeader(Settings, true));
export default withStandardHeader(SettingsScreen, true);
import { connect } from 'react-redux';
import { settingsActions } from '../../../actions/settings';
import SettingsScreen from './SettingsScreen';
const mapStateToProps = state => ({
loading: state.settings.loading,
});
const mapDispatchToProps = dispatch => ({
init: () => dispatch(settingsActions.initStart()),
});
export default connect(mapStateToProps, mapDispatchToProps)(SettingsScreen);
......@@ -3,13 +3,9 @@ import PropTypes from 'prop-types';
import {
Text, TouchableHighlight, TouchableOpacity, View,
} from 'react-native';
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import Moment from 'moment';
import * as actions from '../../../actions/event';
import { retrievePizzaInfo } from '../../../actions/pizza';
import styles from './style/EventDetailCard';
import Colors from '../../style/Colors';
......@@ -100,9 +96,4 @@ EventDetailCard.propTypes = {
t: PropTypes.func.isRequired,
};
const mapDispatchToProps = dispatch => ({
loadEvent: pk => dispatch(actions.event(pk)),
retrievePizzaInfo: () => dispatch(retrievePizzaInfo()),
});
export default connect(() => ({}), mapDispatchToProps)(translate(['screens/welcome/EventDetailCard'])(EventDetailCard));
export default translate(['screens/welcome/EventDetailCard'])(EventDetailCard);
import { connect } from 'react-redux';
import { retrievePizzaInfo } from '../../../actions/pizza';
import * as actions from '../../../actions/event';
import EventDetailCard from './EventDetailCard';
const mapDispatchToProps = dispatch => ({
loadEvent: pk => dispatch(actions.event(pk)),
retrievePizzaInfo: () => dispatch(retrievePizzaInfo()),
});
export default connect(() => ({}), mapDispatchToProps)(EventDetailCard);
......@@ -11,11 +11,9 @@ import {
import { connect } from 'react-redux';
import { translate } from 'react-i18next';
import Moment from 'moment';
import EventDetailCard from './EventDetailCard';
import EventDetailCard from './EventDetailCardContainer';
import LoadingScreen from '../../components/loadingScreen/LoadingScreen';
import ErrorScreen from '../../components/errorScreen/ErrorScreen';
import * as welcomeActions from '../../../actions/welcome';
import styles from './style/Welcome';
import { withStandardHeader } from '../../components/standardHeader/StandardHeader';
import * as calendarActions from '../../../actions/calendar';
......@@ -73,7 +71,7 @@ const mapDispatchToFooterProps = dispatch => ({
const FooterComponent = connect(() => ({}), mapDispatchToFooterProps)(translate('screens/welcome/Welcome')(Footer));
class Welcome extends Component {
class WelcomeScreen extends Component {
handleRefresh = () => {
const { refresh } = this.props;
refresh();
......@@ -144,7 +142,7 @@ class Welcome extends Component {
}
}
Welcome.propTypes = {
WelcomeScreen.propTypes = {
eventList: PropTypes.arrayOf(PropTypes.shape({
title: PropTypes.string,
description: PropTypes.string,
......@@ -162,14 +160,4 @@ Welcome.propTypes = {
t: PropTypes.func.isRequired,
};
const mapStateToProps = state => ({
eventList: state.welcome.eventList,
loading: state.welcome.loading,
status: state.welcome.status,
});
const mapDispatchToProps = dispatch => ({
refresh: () => dispatch(welcomeActions.refresh()),
});
export default connect(mapStateToProps, mapDispatchToProps)(translate('screens/welcome/Welcome')(withStandardHeader(Welcome, true)));
export default translate('screens/welcome/Welcome')(withStandardHeader(WelcomeScreen, true));
import { connect } from 'react-redux';
import * as welcomeActions from '../../../actions/welcome';
import WelcomeScreen from './WelcomeScreen';
const mapStateToProps = state => ({
eventList: state.welcome.eventList,
loading: state.welcome.loading,
status: state.welcome.status,
});
const mapDispatchToProps = dispatch => ({
refresh: () => dispatch(welcomeActions.refresh()),
});
export default connect(mapStateToProps, mapDispatchToProps)(WelcomeScreen);
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