@@ -2,47 +2,64 @@ import React, { useEffect, useState } from "react";
2
2
import { useLocation } from "react-router-dom" ;
3
3
import InputField from "../../Components/shared/InputField" ;
4
4
import ReactiveButton from "reactive-button" ;
5
+
6
+ import custBackgroundImage from "../user/imgs/pngtree-blue-pastel-background-picture-image_1599663.jpg" ;
7
+ import { FaEye , FaEyeSlash } from 'react-icons/fa6' ;
8
+ import i1 from '../user/imgs/white-dog-pastel-blue-background-3d_89917-269.jpg' ;
9
+ import { login , registration } from "../../utils/Functions/userAuthService" ;
10
+ import LoginTextLink from "../../Components/shared/LoginTextLink" ;
11
+ = === ===
5
12
import custBackgroundImage from "../user/imgs/pngtree-blue-pastel-background-picture-image_1599663.jpg" ; // Import your background image
6
13
import { FaEye , FaEyeSlash } from "react-icons/fa6" ;
7
14
import i1 from "../user/imgs/white-dog-pastel-blue-background-3d_89917-269.jpg" ;
8
15
import { login , registration } from "../../utils/Functions/userAuthService" ;
9
16
import LoginTextLink from "../../Components/shared/LoginTextLink" ;
10
17
import AlertDialog from "../../Components/shared/AlertDialog" ;
11
18
12
- function CustomBackground ( { image } ) {
13
- const backgroundStyle = {
14
- position : "fixed" ,
15
- top : 0 ,
16
- left : 0 ,
17
- width : "100%" ,
18
- height : "100%" ,
19
- zIndex : - 1 ,
20
- backgroundImage : `url(${ image } )` ,
21
- backgroundSize : "cover" ,
22
- backgroundPosition : "center" ,
23
- } ;
24
19
25
- return < div style = { backgroundStyle } > </ div > ;
20
+ function CustomBackground ( { image } ) {
21
+ return (
22
+ < div
23
+ className = "fixed top-0 left-0 w-full h-full bg-cover bg-center z-[-1]"
24
+ style = { { backgroundImage : `url(${ image } )` } }
25
+ > </ div >
26
+ ) ;
26
27
}
27
28
28
29
function LoginRegisterForm ( ) {
29
30
const location = useLocation ( ) ;
31
+
32
+ const [ isPassVisible , setIsPassVisible ] = useState ( false ) ;
33
+ const [ userTypingPassword , setUserTypingPassword ] = useState ( false ) ;
34
+ let isLogin = location . pathname !== "/register" ;
35
+ = === ===
30
36
const [ userTypingPassword , setUserTypingPassword ] = useState ( false ) ;
31
37
const isLogin = location . pathname !== "/register" ;
32
38
39
+
33
40
const customButtonStyle = {
34
41
borderRadius : "20px" ,
35
42
background : "linear-gradient(to bottom, #b3d9ff, #3399ff)" ,
43
+
44
+ padding : "16px 32px" ,
45
+ marginTop : "1rem" ,
46
+ fontSize : "18px" ,
47
+
36
48
padding : "20px 40px" ,
37
49
marginTop : "0.675rem" ,
38
50
fontSize : "22px" ,
51
+
39
52
fontWeight : "800" ,
40
53
boxShadow : "rgb(38, 57, 77) 0px 15px 30px -10px" ,
41
- letterSpacing : "0.2rem " ,
54
+ letterSpacing : "0.1rem " ,
42
55
width : "fit-content" ,
43
56
margin : "auto" ,
44
57
} ;
45
58
59
+
60
+ const [ name , setname ] = useState ( "" ) ;
61
+ const [ phone_number , setPhone_number ] = useState ( "" ) ;
62
+
46
63
const [ name , setName ] = useState ( "" ) ;
47
64
const [ phone_number , setPhoneNumber ] = useState ( "" ) ;
48
65
const [ email , setEmail ] = useState ( "" ) ;
@@ -71,6 +88,158 @@ function LoginRegisterForm() {
71
88
setHasSymbol ( / [ ^ A - Z a - z 0 - 9 ] / . test ( value ) ) ;
72
89
} ;
73
90
91
+
92
+
93
+ return (
94
+ < div className = "flex flex-col items-center justify-center min-h-screen py-8 px-4 lg:px-8" >
95
+ < CustomBackground image = { custBackgroundImage } />
96
+ < div className = "w-full max-w-6xl flex flex-row sm:flex-col items-center justify-center rounded-xl shadow-2xl p-6 lg:p-12" >
97
+ < div className = "w-full flex justify-center items-center mb-8 lg:mb-0" >
98
+ < form className = "flex flex-col gap-4 w-full max-w-md" >
99
+ { ! isLogin && (
100
+ < >
101
+ < h1 className = "text-center text-indigo-900 font-semibold text-2xl lg:text-3xl" > Create Account</ h1 >
102
+ < InputField
103
+ className = "h-12 px-4 py-2 border-b-2 border-blue-800 text-lg bg-white shadow-md"
104
+ type = "text"
105
+ placeholder = "Full Name"
106
+ value = { name }
107
+ onChange = { ( e ) => {
108
+ setError ( "" ) ;
109
+ setname ( e . target . value ) ;
110
+ } }
111
+ required
112
+ />
113
+ < InputField
114
+ className = "h-12 px-4 py-2 border-b-2 border-blue-800 text-lg bg-white shadow-md"
115
+ type = "tel"
116
+ placeholder = "Phone Number"
117
+ value = { phone_number }
118
+ onChange = { ( e ) => {
119
+ setError ( "" ) ;
120
+ setPhone_number ( e . target . value ) ;
121
+ } }
122
+ required
123
+ />
124
+ </ >
125
+ ) }
126
+ { isLogin && (
127
+ < h1 className = "text-center text-indigo-900 font-bold text-2xl lg:text-3xl underline" > Welcome Back</ h1 >
128
+ ) }
129
+ < InputField
130
+ className = "h-12 px-4 py-2 border-b-2 border-blue-800 text-lg bg-white shadow-md"
131
+ type = "email"
132
+ placeholder = "Email"
133
+ value = { email }
134
+ onChange = { ( e ) => {
135
+ setError ( "" ) ;
136
+ setEmail ( e . target . value ) ;
137
+ } }
138
+ required
139
+ />
140
+ < div className = "relative w-full" >
141
+ < InputField
142
+ className = "w-full h-12 px-4 py-2 border-b-2 border-blue-800 text-lg bg-white shadow-md"
143
+ type = { isPassVisible ? "text" : "password" }
144
+ placeholder = "Password"
145
+ value = { password }
146
+ onChange = { ( e ) => {
147
+ setError ( "" ) ;
148
+ setPassword ( e . target . value ) ;
149
+ validate ( e . target . value ) ;
150
+ setUserTypingPassword ( e . target . value . length > 0 ) ;
151
+ } }
152
+ required
153
+ />
154
+ { isPassVisible ? (
155
+ < FaEye
156
+ className = "absolute right-4 top-3 text-blue-500 cursor-pointer"
157
+ onClick = { ( ) => setIsPassVisible ( false ) }
158
+ />
159
+ ) : (
160
+ < FaEyeSlash
161
+ className = "absolute right-4 top-3 text-blue-500 cursor-pointer"
162
+ onClick = { ( ) => setIsPassVisible ( true ) }
163
+ />
164
+ ) }
165
+ </ div >
166
+
167
+ { userTypingPassword && (
168
+ < div className = "text-left w-full mt-2" >
169
+ < p className = { `text-sm ${ isMinLength ? 'text-green-500' : 'text-red-500' } ` } > • Minimum 8 characters</ p >
170
+ < p className = { `text-sm ${ hasUpperCase ? 'text-green-500' : 'text-red-500' } ` } > • At least one uppercase letter</ p >
171
+ < p className = { `text-sm ${ hasLowerCase ? 'text-green-500' : 'text-red-500' } ` } > • At least one lowercase letter</ p >
172
+ < p className = { `text-sm ${ hasNumber ? 'text-green-500' : 'text-red-500' } ` } > • At least one number</ p >
173
+ < p className = { `text-sm ${ hasSymbol ? 'text-green-500' : 'text-red-500' } ` } > • At least one symbol</ p >
174
+ </ div >
175
+ ) }
176
+ { ! isLogin && (
177
+ < >
178
+ < div className = "w-full relative flex justify-center mt-4" >
179
+ < ReactiveButton
180
+ style = { customButtonStyle }
181
+ buttonState = { state }
182
+ idleText = "Register"
183
+ loadingText = "Wait..."
184
+ successText = "Logged In"
185
+ errorText = "Error"
186
+ messageDuration = { 3000 }
187
+ disabled = { ! ( isMinLength && hasUpperCase && hasLowerCase && hasNumber && hasSymbol ) }
188
+ onClick = { async ( ) =>
189
+ registration (
190
+ name ,
191
+ phone_number ,
192
+ email ,
193
+ password ,
194
+ setError ,
195
+ setButtonState
196
+ )
197
+ }
198
+ />
199
+ { error && (
200
+ < p className = "absolute top-[-20px] w-full text-center text-red-500 font-semibold" >
201
+ { error }
202
+ </ p >
203
+ ) }
204
+ </ div >
205
+ < div className = "w-full flex flex-col mt-8 gap-2 items-center" >
206
+ < LoginTextLink />
207
+ < LoginTextLink
208
+ text = { "Are you an NGO?" }
209
+ link = { "/ngoregister" }
210
+ linkText = { "Register Here!" }
211
+ className = "text-indigo-800 underline"
212
+ />
213
+ </ div >
214
+ </ >
215
+ ) }
216
+ { isLogin && (
217
+ < div className = "w-full relative flex justify-center mt-4" >
218
+ < ReactiveButton
219
+ style = { customButtonStyle }
220
+ buttonState = { state }
221
+ idleText = "Login"
222
+ loadingText = "Wait..."
223
+ successText = "Logged In"
224
+ errorText = "Error"
225
+ onClick = { async ( ) =>
226
+ login ( email , password , setError , setButtonState )
227
+ }
228
+ />
229
+ { error && (
230
+ < p className = "absolute top-[-20px] w-full text-center text-red-500 font-semibold" >
231
+ { error }
232
+ </ p >
233
+ ) }
234
+ </ div >
235
+ ) }
236
+ </ form >
237
+ </ div >
238
+ < div className = "sm:w-full flex justify-center items-center p-4 lg:mt-0 mt-8" >
239
+ < img className = "block sm:hidden rounded-xl w-2/3" src = { i1 } alt = "Cute dog" />
240
+ </ div >
241
+
242
+ =======
74
243
const handleRegistration = async () => {
75
244
const res = await registration (
76
245
name ,
@@ -271,13 +440,15 @@ function LoginRegisterForm() {
271
440
</ div >
272
441
</ div >
273
442
</ div >
443
+
274
444
</ div >
275
445
< AlertDialog
276
446
open = { isOpenConfirmBox }
277
447
handleClose = { closeConfirmationDialog }
278
448
/>
279
449
</ div >
280
450
);
451
+
281
452
}
282
453
283
454
export default LoginRegisterForm ;
0 commit comments