Commit 124b653c authored by Denis Sedura's avatar Denis Sedura

[RNA-761] Fix after rebase

parent 16869631
This diff is collapsed.
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { createSelector } from 'reselect'
import { Router } from 'tipsi-router'
import {
loginEmail,
loginTwitter,
loginFacebook,
loadUserProfile,
register,
linkSocialAccount,
} from 'tipsi_api/actions'
import { authSelector, userSelector } from 'tipsi_api/selectors'
function enhanceLogin(ComposedComponent) {
class Wrapper extends Component {
static propTypes = {
loginEmail: PropTypes.func.isRequired,
loginTwitter: PropTypes.func.isRequired,
loginFacebook: PropTypes.func.isRequired,
loadUserProfile: PropTypes.func.isRequired,
navigation: PropTypes.object.isRequired,
isLoading: PropTypes.bool.isRequired,
isTwitterLoading: PropTypes.bool.isRequired,
isFacebookLoading: PropTypes.bool.isRequired,
route: PropTypes.object.isRequired,
user: PropTypes.object,
}
static defaultProps = {
user: null,
}
state = {
username: '',
password: '',
}
componentWillReceiveProps(nextProps) {
const { route, user } = nextProps
if (!this.props.user && user && user.username) {
Router.dismissModal()
if (route.params.redirect) {
// navigation.getNavigator('app').push(route.params.redirect, { user })
console.log('Redirect to');
}
}
}
handleDismissLogin = () => {
export default function enhanceLogin(ComposedComponent) {
return class Wrapper extends Component {
dismissModal = () => (
Router.dismissModal()
}
handleChangeUsername = (username) => {
this.setState({ username })
}
handleChangePassword = (password) => {
this.setState({ password: password.replace(/\s+/g, '') })
}
)
render() {
return (
<ComposedComponent
{...this.props}
{...this.state}
handleDismissLogin={this.handleDismissLogin}
handleChangeUsername={this.handleChangeUsername}
handleChangePassword={this.handleChangePassword}
/>
<ComposedComponent {...this.props} dismissModal={this.dismissModal} />
)
}
}
const mapStateToProps = createSelector(
[authSelector, userSelector],
({ isLoading, isTwitterLoading, isFacebookLoading }, user) => ({
...user,
isLoading,
isTwitterLoading,
isFacebookLoading,
})
)
const mapDispatchToProps = {
loginEmail,
loginTwitter,
loginFacebook,
loadUserProfile,
register,
linkSocialAccount,
}
return connect(mapStateToProps, mapDispatchToProps)(Wrapper)
}
export default enhanceLogin
......@@ -27,6 +27,7 @@
"tipsi-stripe": "4.0.0"
},
"peerDependencies": {
"redux-form": "^7.1.2",
"normalizr": "^3.2.2",
"@expo/ex-navigation": "3.1.0",
"react-native-firebase-analytics": "3.0.2",
......
import { createStore, applyMiddleware, combineReducers, compose } from 'redux'
import { AsyncStorage, Platform } from 'react-native'
import { persistStore, autoRehydrate } from 'redux-persist'
import { reducer as form } from 'redux-form'
import createFilter from 'redux-persist-transform-filter'
import thunk from 'redux-thunk'
import uuidv4 from 'uuid/v4'
......@@ -27,7 +28,7 @@ const tipsiMiddleware = createApiMiddleware({
}),
})
const middleware = [tipsiMiddleware, thunk, analyticsMiddleware]//, logger]
const middleware = [tipsiMiddleware, thunk, analyticsMiddleware] // ,logger]
// if (__DEV__) {
// middleware.push(require('redux-logger')())
......@@ -47,6 +48,7 @@ const combinedReducers = combineReducers({
meta,
paginations,
navigation,
form,
...reducers,
})
......
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