diff --git a/Cargo.toml b/Cargo.toml index c0d6366e..1c926538 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ members = [ ] [workspace.dependencies] -soroban-sdk = "21.0.0" +soroban-sdk = "22" [profile.release] opt-level = "z" diff --git a/app/auth/verify-otp/page.tsx b/app/auth/verify-otp/page.tsx index 16bd97d1..027a9752 100644 --- a/app/auth/verify-otp/page.tsx +++ b/app/auth/verify-otp/page.tsx @@ -94,7 +94,7 @@ export default function VerifyOTP() { if (response.ok) { // const data = await response.json() - router.push("/projects/12"); + router.push("/dashboard"); } else { const data = await response.json(); setError(data.message || "Invalid OTP. Please try again."); diff --git a/components/signin-form.tsx b/components/signin-form.tsx index 90cd9b5c..5d61a09b 100644 --- a/components/signin-form.tsx +++ b/components/signin-form.tsx @@ -1,98 +1,110 @@ -"use client" +"use client"; -import { useState } from "react" -import { signIn } from "next-auth/react" -import { useRouter } from "next/navigation" +import { useState } from "react"; +import { signIn } from "next-auth/react"; +import { useRouter } from "next/navigation"; +import { Button } from "./ui/button"; export default function SignInForm() { - const [email, setEmail] = useState("") - const [password, setPassword] = useState("") - const [error, setError] = useState("") - const router = useRouter() + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [error, setError] = useState(""); + const [isLoading, setIsLoading] = useState(false); + const router = useRouter(); - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault() - setError("") + const handleSubmit = async (e: React.FormEvent) => { + e.preventDefault(); + setError(""); + setIsLoading(true); - const result = await signIn("credentials", { - redirect: false, - email, - password, - }) + const result = await signIn("credentials", { + redirect: false, + email, + password, + }); - if (result?.error === "UNVERIFIED_EMAIL") { - setError("Your email is not verified. Sending verification code...") + if (result?.error === "UNVERIFIED_EMAIL") { + setError("Your email is not verified. Sending verification code..."); - try { - const otpResponse = await fetch("/api/auth/resend-otp", { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ email }), - }) + try { + const otpResponse = await fetch("/api/auth/resend-otp", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ email }), + }); - if (!otpResponse.ok) { - const data = await otpResponse.json() - setError(data.message || "Failed to send verification code") - return - } - router.push(`/auth/verify-otp?email=${encodeURIComponent(email)}`) - } catch (err) { - setError(`Failed to send verification code: ${err instanceof Error ? err.message : String(err)}`) - } - } else if (result?.error) { - setError(result.error) - } else { - router.push("/projects/12") - } - } + if (!otpResponse.ok) { + const data = await otpResponse.json(); + setError(data.message || "Failed to send verification code"); + return; + } + router.push(`/auth/verify-otp?email=${encodeURIComponent(email)}`); + } catch (err) { + setError( + `Failed to send verification code: ${ + err instanceof Error ? err.message : String(err) + }`, + ); + } finally { + setIsLoading(false); + } + } else if (result?.error) { + setError(result.error); + setIsLoading(false); + } else { + setIsLoading(false); + router.push("/dashboard"); + } + }; - return ( -
-
-
- - setEmail(e.target.value)} - /> -
-
- - setPassword(e.target.value)} - /> -
-
+ return ( + +
+
+ + setEmail(e.target.value)} + /> +
+
+ + setPassword(e.target.value)} + /> +
+
- {error &&

{error}

} + {error &&

{error}

} -
- -
-
- ) +
+ +
+ + ); } diff --git a/lib/auth.config.ts b/lib/auth.config.ts index ffa77e20..a2be7241 100644 --- a/lib/auth.config.ts +++ b/lib/auth.config.ts @@ -84,7 +84,7 @@ export const authOptions: NextAuthOptions = { callbacks: { async redirect({ url, baseUrl }) { - return url.startsWith(baseUrl) ? url : `${baseUrl}/projects/12`; + return url.startsWith(baseUrl) ? url : `${baseUrl}/dashboard`; }, async jwt({ token, user }): Promise { if (user) {