import Button from '@material-ui/core/Button' import Grid from '@material-ui/core/Grid' import Container from '@material-ui/core/Container' import GitHubIcon from '@material-ui/icons/GitHub' import FacebookIcon from '@material-ui/icons/Facebook' import GoogleIcon from '../../assets/GoogleIcon' import { connect } from 'react-redux' import { bindActionCreators, Dispatch } from 'redux' import { loginUserByGithub, loginUserByGoogle, loginUserByFacebook } from '../../../redux/auth/service' import './style.scss' const mapDispatchToProps = (dispatch: Dispatch) => ({ loginUserByGithub: bindActionCreators(loginUserByGithub, dispatch), loginUserByGoogle: bindActionCreators(loginUserByGoogle, dispatch), loginUserByFacebook: bindActionCreators(loginUserByFacebook, dispatch) }) interface Props { auth: any isEnabledFacebook?: boolean isEnabledGithub?: boolean isEnabledGoogle?: boolean loginUserByGithub: typeof loginUserByGithub loginUserByGoogle: typeof loginUserByGoogle loginUserByFacebook: typeof loginUserByFacebook }; const SocialLogin = (props: Props) => { const { isEnabledFacebook, isEnabledGithub, isEnabledGoogle, loginUserByFacebook, loginUserByGoogle, loginUserByGithub } = props const handleGithubLogin = (e: any) => { e.preventDefault() loginUserByGithub() } const handleGoogleLogin = (e: any) => { e.preventDefault() loginUserByGoogle() } const handleFacebookLogin = (e: any) => { e.preventDefault() loginUserByFacebook() } const githubButton = isEnabledGithub ? ( handleGithubLogin(e)} startIcon={} variant="contained" className="github" fullWidth={true} > Login with GitHub ) : ( '' ) const googleButton = isEnabledGoogle ? ( handleGoogleLogin(e)} startIcon={} variant="contained" className="google" fullWidth={true} > Login with Google ) : ( '' ) const facebookButton = isEnabledFacebook ? ( handleFacebookLogin(e)} startIcon={} variant="contained" className="facebook" fullWidth={true} > Login with Facebook ) : ( '' ) return ( {githubButton} {facebookButton} {googleButton} ) } const SocialLoginWrapper = (props: any) => export default connect(mapDispatchToProps)(SocialLoginWrapper)