1- "use client" ;
1+ import { getEmailDeliveryConfigured } from "@/lib/email-delivery" ;
2+ import ResetPasswordForm from "./form" ;
23
3- import { Button } from "@/components/ui/button" ;
4- import { Input } from "@/components/ui/input" ;
5- import Client from "@blink.so/api" ;
6- import { useMemo , useState } from "react" ;
4+ export const dynamic = "force-dynamic" ;
75
86export default function ResetPasswordPage ( ) {
9- const client = useMemo ( ( ) => new Client ( ) , [ ] ) ;
10- const [ error , setError ] = useState < string | undefined > ( ) ;
11- const [ isSubmitting , setIsSubmitting ] = useState ( false ) ;
7+ const isEmailConfigured = getEmailDeliveryConfigured ( ) ;
128
13- const handleSubmit = async ( e : React . FormEvent < HTMLFormElement > ) => {
14- e . preventDefault ( ) ;
15- setError ( undefined ) ;
16-
17- const formData = new FormData ( e . currentTarget ) ;
18- const email = formData . get ( "email" ) as string ;
19-
20- if ( ! email ) {
21- setError ( "Please enter your email address" ) ;
22- return ;
23- }
24-
25- setIsSubmitting ( true ) ;
26- try {
27- const result = await client . auth . requestPasswordReset ( { email } ) ;
28- if ( result . ok && result . redirect_url ) {
29- window . location . href = result . redirect_url ;
30- }
31- } catch ( err ) {
32- setError (
33- err instanceof Error ? err . message : "Failed to request password reset"
34- ) ;
35- setIsSubmitting ( false ) ;
36- }
37- } ;
9+ if ( ! isEmailConfigured ) {
10+ return (
11+ < div className = "flex min-h-[60vh] items-center justify-center p-4" >
12+ < div className = "text-center" >
13+ < h1 className = "text-2xl font-semibold text-zinc-900 dark:text-white mb-2" >
14+ Contact this instance's admin to reset your password
15+ </ h1 >
16+ < p className = "text-sm text-neutral-600 dark:text-neutral-400" >
17+ Remember your password?{ " " }
18+ < a
19+ href = "/login"
20+ className = "text-blue-600 dark:text-blue-400 hover:underline font-medium"
21+ >
22+ Sign in
23+ </ a >
24+ </ p >
25+ </ div >
26+ </ div >
27+ ) ;
28+ }
3829
3930 return (
4031 < div className = "flex items-center justify-center p-4" >
4132 < div className = "w-full max-w-md" >
42- { /* Header */ }
4333 < div className = "text-center mb-8" >
4434 < h1 className = "text-3xl font-bold text-zinc-900 dark:text-white mb-2" >
4535 Reset your password
@@ -50,51 +40,9 @@ export default function ResetPasswordPage() {
5040 </ p >
5141 </ div >
5242
53- { /* Reset Password Card */ }
5443 < div className = "bg-white dark:bg-zinc-900 rounded-2xl border border-zinc-200 dark:border-zinc-700 shadow-lg p-8" >
55- < div className = "space-y-4" >
56- { /* Error Display */ }
57- { error && (
58- < div className = "bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4" >
59- < p className = "text-sm text-red-800 dark:text-red-200" >
60- { error }
61- </ p >
62- </ div >
63- ) }
64-
65- { /* Reset Password Form */ }
66- < form className = "space-y-4" onSubmit = { handleSubmit } >
67- < div >
68- < label
69- htmlFor = "email"
70- className = "block text-sm font-medium text-zinc-900 dark:text-white mb-2"
71- >
72- Email
73- </ label >
74- < Input
75- id = "email"
76- name = "email"
77- type = "email"
78- required
79- placeholder = "Enter your email address"
80- className = "w-full"
81- data-testid = "reset-email-input"
82- />
83- </ div >
84-
85- < Button
86- type = "submit"
87- size = "lg"
88- className = "w-full h-12 text-base font-medium"
89- data-testid = "reset-email-submit"
90- disabled = { isSubmitting }
91- >
92- { isSubmitting ? "Sending..." : "Send Reset Code" }
93- </ Button >
94- </ form >
95- </ div >
44+ < ResetPasswordForm />
9645
97- { /* Footer */ }
9846 < div className = "mt-6 text-center" >
9947 < p className = "text-sm text-neutral-600 dark:text-neutral-400" >
10048 Remember your password?{ " " }
@@ -108,7 +56,6 @@ export default function ResetPasswordPage() {
10856 </ div >
10957 </ div >
11058
111- { /* Terms */ }
11259 < div className = "mt-6 text-center" >
11360 < p className = "text-xs text-neutral-500" >
11461 Need help? Contact our{ " " }
0 commit comments