1
1
import { useForm } from 'react-hook-form' ;
2
- import { useRecoilValue } from 'recoil' ;
3
- import store from '~/store' ;
4
- import { localize } from '~/localization/Translation' ;
2
+ import { useLocalize } from '~/hooks' ;
5
3
import { TLoginUser } from 'librechat-data-provider' ;
6
4
7
5
type TLoginFormProps = {
8
6
onSubmit : ( data : TLoginUser ) => void ;
9
7
} ;
10
8
11
9
function LoginForm ( { onSubmit } : TLoginFormProps ) {
12
- const lang = useRecoilValue ( store . lang ) ;
10
+ const localize = useLocalize ( ) ;
13
11
14
12
const {
15
13
register,
@@ -30,20 +28,20 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
30
28
type = "text"
31
29
id = "email"
32
30
autoComplete = "email"
33
- aria-label = { localize ( lang , 'com_auth_email' ) }
31
+ aria-label = { localize ( 'com_auth_email' ) }
34
32
{ ...register ( 'email' , {
35
- required : localize ( lang , 'com_auth_email_required' ) ,
33
+ required : localize ( 'com_auth_email_required' ) ,
36
34
minLength : {
37
35
value : 3 ,
38
- message : localize ( lang , 'com_auth_email_min_length' ) ,
36
+ message : localize ( 'com_auth_email_min_length' ) ,
39
37
} ,
40
38
maxLength : {
41
39
value : 120 ,
42
- message : localize ( lang , 'com_auth_email_max_length' ) ,
40
+ message : localize ( 'com_auth_email_max_length' ) ,
43
41
} ,
44
42
pattern : {
45
43
value : / \S + @ \S + \. \S + / ,
46
- message : localize ( lang , 'com_auth_email_pattern' ) ,
44
+ message : localize ( 'com_auth_email_pattern' ) ,
47
45
} ,
48
46
} ) }
49
47
aria-invalid = { ! ! errors . email }
@@ -54,7 +52,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
54
52
htmlFor = "email"
55
53
className = "absolute left-2.5 top-4 z-10 origin-[0] -translate-y-4 scale-75 transform text-gray-500 duration-300 peer-placeholder-shown:translate-y-0 peer-placeholder-shown:scale-100 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:text-green-500"
56
54
>
57
- { localize ( lang , 'com_auth_email_address' ) }
55
+ { localize ( 'com_auth_email_address' ) }
58
56
</ label >
59
57
</ div >
60
58
{ errors . email && (
@@ -70,16 +68,16 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
70
68
type = "password"
71
69
id = "password"
72
70
autoComplete = "current-password"
73
- aria-label = { localize ( lang , 'com_auth_password' ) }
71
+ aria-label = { localize ( 'com_auth_password' ) }
74
72
{ ...register ( 'password' , {
75
- required : localize ( lang , 'com_auth_password_required' ) ,
73
+ required : localize ( 'com_auth_password_required' ) ,
76
74
minLength : {
77
75
value : 8 ,
78
- message : localize ( lang , 'com_auth_password_min_length' ) ,
76
+ message : localize ( 'com_auth_password_min_length' ) ,
79
77
} ,
80
78
maxLength : {
81
79
value : 40 ,
82
- message : localize ( lang , 'com_auth_password_max_length' ) ,
80
+ message : localize ( 'com_auth_password_max_length' ) ,
83
81
} ,
84
82
} ) }
85
83
aria-invalid = { ! ! errors . password }
@@ -90,7 +88,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
90
88
htmlFor = "password"
91
89
className = "absolute left-2.5 top-4 z-10 origin-[0] -translate-y-4 scale-75 transform text-gray-500 duration-300 peer-placeholder-shown:translate-y-0 peer-placeholder-shown:scale-100 peer-focus:-translate-y-4 peer-focus:scale-75 peer-focus:text-green-500"
92
90
>
93
- { localize ( lang , 'com_auth_password' ) }
91
+ { localize ( 'com_auth_password' ) }
94
92
</ label >
95
93
</ div >
96
94
@@ -102,7 +100,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
102
100
) }
103
101
</ div >
104
102
< a href = "/forgot-password" className = "text-sm text-green-500 hover:underline" >
105
- { localize ( lang , 'com_auth_password_forgot' ) }
103
+ { localize ( 'com_auth_password_forgot' ) }
106
104
</ a >
107
105
< div className = "mt-6" >
108
106
< button
@@ -111,7 +109,7 @@ function LoginForm({ onSubmit }: TLoginFormProps) {
111
109
type = "submit"
112
110
className = "w-full transform rounded-sm bg-green-500 px-4 py-3 tracking-wide text-white transition-colors duration-200 hover:bg-green-600 focus:bg-green-600 focus:outline-none"
113
111
>
114
- { localize ( lang , 'com_auth_continue' ) }
112
+ { localize ( 'com_auth_continue' ) }
115
113
</ button >
116
114
</ div >
117
115
</ form >
0 commit comments