import React from 'react'; import PropTypes from 'prop-types'; import { Meteor } from 'meteor/meteor'; import { Bert } from 'meteor/themeteorchef:bert'; import './OAuthLoginButton.scss'; const handleLogin = (service, options, callback) => { const defaultOptions = { facebook: { requestPermissions: ['email'], loginStyle: 'redirect', }, google: { requestPermissions: ['email'], requestOfflineToken: true, loginStyle: 'redirect', }, github: { requestPermissions: ['user:email'], loginStyle: 'redirect', }, }[service]; const defaultCallback = (error) => { if (error) Bert.alert(error.reason, 'danger'); }; return { facebook: Meteor.loginWithFacebook, google: Meteor.loginWithGoogle, github: Meteor.loginWithGithub, }[service](options || defaultOptions, callback || defaultCallback); }; const serviceLabel = { facebook: Log In with Facebook, google: Log In with Google, github: Log In with GitHub, }; const OAuthLoginButton = ({ service, options, callback }) => ( ); OAuthLoginButton.defaultProps = { options: PropTypes.object, callback: PropTypes.func, }; OAuthLoginButton.propTypes = { service: PropTypes.string.isRequired, options: PropTypes.object, // eslint-disable-line react/forbid-prop-types callback: PropTypes.func, }; export default OAuthLoginButton;