mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-06-27 17:25:43 -04:00
36 lines
967 B
TypeScript
36 lines
967 B
TypeScript
"use client";
|
|
|
|
import { env } from "@/lib/env";
|
|
import { useState } from "react";
|
|
import { Loader2Icon } from "lucide-react";
|
|
import Button from "@/components/ui/button";
|
|
import { GitHubIcon } from "@/components/icons";
|
|
import { signIn } from "@/lib/auth-client";
|
|
|
|
const SignIn = ({ callbackPath }: { callbackPath?: string }) => {
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
const handleSignIn = async () => {
|
|
setIsLoading(true);
|
|
|
|
try {
|
|
await signIn.social({
|
|
provider: "github",
|
|
callbackURL: `${env.NEXT_PUBLIC_BASE_URL}${callbackPath ? callbackPath : "/"}`,
|
|
});
|
|
} catch (error) {
|
|
console.error("Error signing in:", error);
|
|
setIsLoading(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Button onClick={handleSignIn} disabled={isLoading} size="lg" variant="outline">
|
|
{isLoading ? <Loader2Icon className="animate-spin" /> : <GitHubIcon />}
|
|
Sign in with GitHub
|
|
</Button>
|
|
);
|
|
};
|
|
|
|
export default SignIn;
|