{"size": 1615, "ext": "js", "max_stars_repo_path": "src/components/socialLogins/facebook.js", "max_stars_repo_name": "dejibimbolaAyo/club-manager-app", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/socialLogins/facebook.js", "max_issues_repo_name": "dejibimbolaAyo/club-manager-app", "max_issues_repo_issues_event_min_datetime": "2020-09-07T08:44:50.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-18T11:03:49.000Z", "max_forks_repo_path": "src/components/socialLogins/facebook.js", "max_forks_repo_name": "dejibimbolaAyo/club-manager-app", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 5, "max_forks_count": null, "avg_line_length": 33.6458333333, "max_line_length": 137, "alphanum_fraction": 0.6074303406}
import React from 'react';
import ReactDOM from 'react-dom';
import {Button} from "semantic-ui-react"
import FacebookLogin from 'react-facebook-login/dist/facebook-login-render-props';
import { facebookSignUp } from '../../services/registrationService';

const responseFacebook = (response) => {
//   console.log(response);
  const tokenBlob = new Blob([JSON.stringify({access_token: response.accessToken}, null, 2)], {type : 'application/json'});
        const options = {
            method: 'POST',
            body: tokenBlob,
            mode: 'cors',
            cache: 'default'
        };
        fetch('http://localhost:3000/auth/facebook', options).then(r => {
            const token = r.headers.get('x-auth-token');
            console.log("Token", token)
            r.json().then(user => {
                if (token) {
                    // this.setState({isAuthenticated: true, user, token})
                    console.log({isAuthenticated: true, user, token})
                }
            });
        })
}

const componentClicked = (data) => {
    console.log(data)
}

const FacebookLoginButton = () => {
    return <FacebookLogin
    appId="1404945256322140"
    autoLoad={false}
    fields="name,email,picture"
    onClick={componentClicked()}
    callback={responseFacebook} 
    render={renderProps => {
        console.log("renserfasdfa", renderProps)
        return <Button onClick={renderProps.onClick} label={'Facebook Login'} labelPosition={'right'} icon={'facebook'} primary></Button>
    }}
    />
}

export default function() {
    return <FacebookLoginButton></FacebookLoginButton>
}