import React from 'react'; import PropTypes from 'prop-types'; import { Meteor } from 'meteor/meteor'; import { Bert } from 'meteor/themeteorchef:bert'; import Icon from '../Icon/Icon'; import { withTranslation, Trans } from 'react-i18next'; import { T9n } from 'meteor-accounts-t9n'; import './OAuthLoginButton.scss'; const handleLogin = (service, callback) => { const options = { facebook: { requestPermissions: ['email'], loginStyle: 'popup', }, github: { requestPermissions: ['user:email'], loginStyle: 'popup', }, google: { requestPermissions: ['email', 'profile'], requestOfflineToken: true, loginStyle: 'popup', }, }[service]; return { facebook: Meteor.loginWithFacebook, github: Meteor.loginWithGithub, google: Meteor.loginWithGoogle, }[service](options, callback); }; const serviceLabel = { facebook: Log In with Facebook, github: Log In with GitHub, google: Iniciar sesión con Google, }; const defaultCallback = (error) => { if (error) Bert.alert(T9n.get(`error.accounts.${error.message}`), 'danger'); // Bert.alert(error.message, 'danger'); }; const OAuthLoginButton = ({ service, callback = defaultCallback }) => ( ); OAuthLoginButton.propTypes = { service: PropTypes.string.isRequired, callback: PropTypes.func, }; export default withTranslation()(OAuthLoginButton);