"use client";
import { useState } from "react";
import { Loader2 } from "lucide-react";
import { toast } from "sonner";
import { authClient } from "@/lib/auth-client";
import { Button } from "@/components/ui/button";
// Microsoft logo SVG component
function MicrosoftLogo({ className }: { className?: string }) {
return (
);
}
interface MicrosoftButtonProps {
callbackURL?: string;
}
export function MicrosoftButton({ callbackURL = "/" }: MicrosoftButtonProps) {
const [isLoading, setIsLoading] = useState(false);
async function handleMicrosoftSignIn() {
setIsLoading(true);
try {
const result = await authClient.signIn.social({
provider: "microsoft",
callbackURL,
});
if (result.error) {
toast.error(result.error.message || "Failed to sign in with Microsoft");
setIsLoading(false);
}
// If successful, the user will be redirected to Microsoft's OAuth page
} catch (error) {
toast.error("An unexpected error occurred");
console.error("Microsoft sign-in error:", error);
setIsLoading(false);
}
}
return (
);
}