Merge branch 'master' of honey.fitz.guru:eventment-app
# Conflicts: # app/actions/profile.js # app/router.js
This commit is contained in:
19
app/components/FacebookLogin/FacebookLogin.container.js
Normal file
19
app/components/FacebookLogin/FacebookLogin.container.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import {
|
||||
facebookLoginSuccess,
|
||||
logout,
|
||||
registrationServiceError,
|
||||
userCanceledRegistration,
|
||||
} from '../actions/profile.js';
|
||||
|
||||
import FacebookLogin from './FacebookLogin.js';
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
doCancelAction: () => dispatch(userCanceledRegistration()),
|
||||
doErrorAction: (error) => dispatch(registrationServiceError(error)),
|
||||
doLogoutAction: () => dispatch(logout()),
|
||||
doSuccessAction: (result) => dispatch(facebookLoginSuccess(result)),
|
||||
});
|
||||
|
||||
export default connect(null, mapDispatchToProps)(FacebookLogin);
|
||||
41
app/components/FacebookLogin/FacebookLogin.js
Normal file
41
app/components/FacebookLogin/FacebookLogin.js
Normal file
@@ -0,0 +1,41 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { View } from 'react-native';
|
||||
import { LoginButton } from 'react-native-fbsdk';
|
||||
|
||||
import { PERMISSIONS } from '../../constants/constants.js';
|
||||
|
||||
export default function FacebookLogin({
|
||||
doCancelAction,
|
||||
doErrorAction,
|
||||
doLogoutAction,
|
||||
doSuccessAction,
|
||||
}) {
|
||||
|
||||
return (
|
||||
<View>
|
||||
<LoginButton
|
||||
publishPermissions={PERMISSIONS.FACEBOOK}
|
||||
onLoginFinished={
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
doErrorAction(error);
|
||||
} else if (result.isCancelled) {
|
||||
doCancelAction();
|
||||
} else {
|
||||
doSuccessAction(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
onLogoutFinished={doLogoutAction}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
FacebookLogin.propTypes = {
|
||||
doCancelAction: PropTypes.func.isRequired,
|
||||
doErrorAction: PropTypes.func.isRequired,
|
||||
doLogoutAction: PropTypes.func.isRequired,
|
||||
doSuccessAction: PropTypes.func.isRequired,
|
||||
};
|
||||
Reference in New Issue
Block a user