Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.
ui: add loading states in signin buttons
Aashish-Upadhyay-1016eea320c36d7
diff --git a/app/(auth)/login/page.tsx b/app/(auth)/login/page.tsxindex eabc9b00..15ad6316 100644--- a/app/(auth)/login/page.tsx+++ b/app/(auth)/login/page.tsx@@ -10,9 +10,14 @@ import Passkey from "@/components/shared/icons/passkey";import { useState } from "react";import { toast } from "sonner";import LinkedIn from "@/components/shared/icons/linkedin";+import { Loader } from "lucide-react";export default function Login() {const { next } = useParams as { next?: string };+ const [isLoginWithEmail, setIsLoginWithEmail] = useState<boolean>(false);+ const [isLoginWithGoogle, setIsLoginWithGoogle] = useState<boolean>(false);+ const [isLoginWithLinkedIn, setIsLoginWithLinkedIn] =+ useState<boolean>(false);const [email, setEmail] = useState<string>("");@@ -45,6 +50,7 @@ export default function Login() {className="flex flex-col p-4 pt-8 sm:px-16 gap-4"onSubmit={(e) => {e.preventDefault();+ setIsLoginWithEmail(true);signIn("email", {email: email,redirect: false,@@ -56,6 +62,7 @@ export default function Login() {} else {toast.error("Error sending email - try again?");}+ setIsLoginWithEmail(false);});}}>@@ -65,37 +72,63 @@ export default function Login() {value={email}onChange={(e) => setEmail(e.target.value)}/>- <Button type="submit">Continue with Email</Button>+ <Button type="submit" disabled={isLoginWithEmail}>+ {isLoginWithEmail && (+ <Loader className="h-5 w-5 mr-2 animate-spin" />+ )}+ Continue with Email+ </Button></form><p className="text-center">or</p><div className="flex flex-col px-4 py-8 sm:px-16 space-y-2"><ButtononClick={() => {+ setIsLoginWithGoogle(true);signIn("google", {...(next && next.length > 0 ? { callbackUrl: next } : {}),+ }).then((res) => {+ if (res?.status) {+ setIsLoginWithGoogle(false);+ }});}}+ disabled={isLoginWithGoogle}className="flex justify-center items-center space-x-2">- <svg- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 488 512"- fill="currentColor"- className="h-4 w-4"- >- <path d="M488 261.8C488 403.3 391.1 504 248 504 110.8 504 0 393.2 0 256S110.8 8 248 8c66.8 0 123 24.5 166.3 64.9l-67.5 64.9C258.5 52.6 94.3 116.6 94.3 256c0 86.5 69.1 156.6 153.7 156.6 98.2 0 135-70.4 140.8-106.9H248v-85.3h236.1c2.3 12.7 3.9 24.9 3.9 41.4z" />- </svg>+ {isLoginWithGoogle ? (+ <Loader className="w-5 h-5 mr-2 animate-spin" />+ ) : (+ <svg+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 488 512"+ fill="currentColor"+ className="h-4 w-4"+ >+ <path d="M488 261.8C488 403.3 391.1 504 248 504 110.8 504 0 393.2 0 256S110.8 8 248 8c66.8 0 123 24.5 166.3 64.9l-67.5 64.9C258.5 52.6 94.3 116.6 94.3 256c0 86.5 69.1 156.6 153.7 156.6 98.2 0 135-70.4 140.8-106.9H248v-85.3h236.1c2.3 12.7 3.9 24.9 3.9 41.4z" />+ </svg>+ )}+<span>Continue with Google</span></Button><ButtononClick={() => {+ setIsLoginWithLinkedIn(true);signIn("linkedin", {...(next && next.length > 0 ? { callbackUrl: next } : {}),+ }).then((res) => {+ if (res?.status) {+ setIsLoginWithLinkedIn(false);+ }});}}+ disabled={isLoginWithLinkedIn}className="flex justify-center items-center space-x-2">- <LinkedIn />+ {isLoginWithLinkedIn ? (+ <Loader className="w-5 h-5 mr-2 animate-spin" />+ ) : (+ <LinkedIn />+ )}<span>Continue with LinkedIn</span></Button><Button