// components/SignInWithGithub.js
import React from 'react';
import { auth } from '@/app/firebase/config';
import { getAuth, GithubAuthProvider,signInWithPopup } from 'firebase/auth';
interface GoogleSignInButtonProps {
    onLoginSuccess?: (user: any) => void; // Callback function when login succeeds
  }
const SignInWithGithub : React.FC<GoogleSignInButtonProps> = ({ onLoginSuccess }) => {
  const provider = new GithubAuthProvider();

  const handleGithubSignIn = async () => {
    try {
      // Sign in with GitHub using Firebase Auth
      const result = await signInWithPopup(auth, provider);

      // Get the signed-in user info
      const user = result.user;
      console.log('GitHub User:', user);
    } catch (error) {
      console.error("Error during GitHub sign-in:", error);
    }
  };

  return (
    <button
      onClick={handleGithubSignIn}
      className="w-full py-3 bg-gray-800 text-white rounded-md hover:bg-gray-700 transition duration-300"
    >
      Sign in with GitHub
    </button>
  );
};

export default SignInWithGithub;