"use client";

import Image from "next/image";
import "./GoogleButton.scss";
import google from "./icons/google.svg";
import { useSearchParams } from "next/navigation";
import { signIn } from "next-auth/react";

const GoogleButton = () => {
  const searchParams = useSearchParams();
  const callbackUrl =
    searchParams.get("callbackUrl") || "/profile/personal";

  const googleLogin = async () => {
    await signIn("google", { callbackUrl });
  };

  return (
    <button
      type="button"
      className="google-btn"
      onClick={googleLogin}
    >
      <Image src={google} alt="Google Icon" />
      Войти через Google
    </button>
  );
};

export default GoogleButton;
