11"use client" ;
22
33import { useState } from "react" ;
4+ import { useTranslations } from "next-intl" ;
45import { Link } from "@/i18n/routing" ;
56import { Button } from "@/components/ui/button" ;
67import { AuthShell } from "@/components/auth/AuthShell" ;
@@ -20,6 +21,7 @@ export function LoginForm({
2021 locale,
2122 returnTo,
2223} : LoginFormProps ) {
24+ const t = useTranslations ( "auth.login" ) ;
2325 const [ loading , setLoading ] = useState ( false ) ;
2426 const [ errorMessage , setErrorMessage ] =
2527 useState < string | null > ( null ) ;
@@ -58,11 +60,9 @@ export function LoginForm({
5860 setErrorCode ( data ?. code ?? null ) ;
5961
6062 if ( data ?. code === "EMAIL_NOT_VERIFIED" ) {
61- setErrorMessage (
62- "Your email address is not verified. Please check your inbox."
63- ) ;
63+ setErrorMessage ( t ( "errors.emailNotVerified" ) ) ;
6464 } else {
65- setErrorMessage ( "Invalid email or password" ) ;
65+ setErrorMessage ( t ( "errors.invalidCredentials" ) ) ;
6666 }
6767 return ;
6868 }
@@ -71,9 +71,7 @@ export function LoginForm({
7171 returnTo || `/${ locale } /dashboard` ;
7272 } catch ( err ) {
7373 console . error ( "Login request failed:" , err ) ;
74- setErrorMessage (
75- "Network error. Please check your connection and try again."
76- ) ;
74+ setErrorMessage ( t ( "errors.networkError" ) ) ;
7775 setErrorCode ( null ) ;
7876 } finally {
7977 setLoading ( false ) ;
@@ -94,10 +92,7 @@ export function LoginForm({
9492
9593 if ( ! res . ok ) {
9694 setErrorCode ( data ?. code ?? "RESEND_FAILED" ) ;
97- setErrorMessage (
98- data ?. error ??
99- "Failed to resend verification email. Please try again."
100- ) ;
95+ setErrorMessage ( data ?. error ?? t ( "errors.resendFailed" ) ) ;
10196 return ;
10297 }
10398
@@ -107,18 +102,16 @@ export function LoginForm({
107102 } catch ( err ) {
108103 console . error ( "Resend verification failed:" , err ) ;
109104 setErrorCode ( "NETWORK_ERROR" ) ;
110- setErrorMessage (
111- "Network error. Please check your connection and try again."
112- ) ;
105+ setErrorMessage ( t ( "errors.networkError" ) ) ;
113106 }
114107 }
115108
116109 return (
117110 < AuthShell
118- title = "Log in"
111+ title = { t ( "title" ) }
119112 footer = {
120113 < p className = "text-sm text-gray-600" >
121- Don’t have an account? { " " }
114+ { t ( "noAccount" ) } { " " }
122115 < Link
123116 href = {
124117 returnTo
@@ -129,7 +122,7 @@ export function LoginForm({
129122 }
130123 className = "underline"
131124 >
132- Sign up
125+ { t ( "signupLink" ) }
133126 </ Link >
134127 </ p >
135128 }
@@ -152,7 +145,7 @@ export function LoginForm({
152145 }
153146 className = "text-sm underline text-gray-600"
154147 >
155- Forgot password?
148+ { t ( "forgotPassword" ) }
156149 </ Link >
157150 </ div >
158151
@@ -161,7 +154,7 @@ export function LoginForm({
161154 message = { errorMessage }
162155 actionLabel = {
163156 errorCode === "EMAIL_NOT_VERIFIED"
164- ? "Resend verification email"
157+ ? t ( "resendVerification" )
165158 : undefined
166159 }
167160 onAction = {
@@ -176,7 +169,7 @@ export function LoginForm({
176169 < AuthSuccessBanner
177170 message = {
178171 < >
179- Verification successfully sent to { " " }
172+ { t ( "verificationSent" ) } { " " }
180173 < strong > { email } </ strong >
181174 </ >
182175 }
@@ -188,7 +181,7 @@ export function LoginForm({
188181 disabled = { loading }
189182 className = "w-full"
190183 >
191- { loading ? "Logging in..." : "Log in" }
184+ { loading ? t ( "submitting" ) : t ( "submit" ) }
192185 </ Button >
193186 </ form >
194187 </ AuthShell >
0 commit comments