mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-08 02:58:40 -06:00
Co-authored-by: Johannes <johannes@formbricks.com> Co-authored-by: Matti Nannt <mail@matthiasnannt.com>
40 lines
886 B
TypeScript
40 lines
886 B
TypeScript
import { signIn } from "next-auth/react";
|
|
import { useCallback, useEffect } from "react";
|
|
import { Button } from "../../Button";
|
|
import { MicrosoftIcon } from "../../icons";
|
|
|
|
export const AzureButton = ({
|
|
text = "Continue with Azure",
|
|
inviteUrl,
|
|
directRedirect = false,
|
|
}: {
|
|
text?: string;
|
|
inviteUrl?: string | null;
|
|
directRedirect?: boolean;
|
|
}) => {
|
|
const handleLogin = useCallback(async () => {
|
|
await signIn("azure-ad", {
|
|
redirect: true,
|
|
callbackUrl: inviteUrl ? inviteUrl : "/",
|
|
});
|
|
}, [inviteUrl]);
|
|
|
|
useEffect(() => {
|
|
if (directRedirect) {
|
|
handleLogin();
|
|
}
|
|
}, [directRedirect, handleLogin]);
|
|
|
|
return (
|
|
<Button
|
|
type="button"
|
|
EndIcon={MicrosoftIcon}
|
|
startIconClassName="ml-2"
|
|
onClick={handleLogin}
|
|
variant="secondary"
|
|
className="w-full justify-center">
|
|
{text}
|
|
</Button>
|
|
);
|
|
};
|