add loading spinner to auth buttons

This commit is contained in:
knugget
2023-02-21 11:31:50 +01:00
parent 44ac65f076
commit cbef066730
2 changed files with 8 additions and 2 deletions

View File

@@ -4,10 +4,12 @@ import { Button } from "@formbricks/ui";
import { XCircleIcon } from "@heroicons/react/20/solid";
import { signIn } from "next-auth/react";
import Link from "next/dist/client/link";
import { useState } from "react";
import { GithubButton } from "./GithubButton";
export const SigninForm = ({ callbackUrl, error }) => {
const handleSubmit = async (e) => {
setLoggingIn(true);
e.preventDefault();
await signIn("credentials", {
callbackUrl: callbackUrl || "/",
@@ -16,6 +18,8 @@ export const SigninForm = ({ callbackUrl, error }) => {
});
};
const [loggingIn, setLoggingIn] = useState(false);
return (
<>
{error && (
@@ -66,7 +70,7 @@ export const SigninForm = ({ callbackUrl, error }) => {
</div>
<div>
<Button type="submit" className="w-full justify-center">
<Button type="submit" className="w-full justify-center" loading={loggingIn}>
Sign in
</Button>
</div>

View File

@@ -11,8 +11,10 @@ import { GithubButton } from "./GithubButton";
export const SignupForm = () => {
const router = useRouter();
const [error, setError] = useState<string>("");
const [signingUp, setSigningUp] = useState(false);
const handleSubmit = async (e) => {
setSigningUp(true);
e.preventDefault();
try {
await createUser(
@@ -95,7 +97,7 @@ export const SignupForm = () => {
</div>
<div>
<Button type="submit" className="w-full justify-center">
<Button type="submit" className="w-full justify-center" loading={signingUp}>
Sign up
</Button>