Skip to content
This repository was archived by the owner on Aug 29, 2025. It is now read-only.

Commit 33c1a33

Browse files
authored
Made user registration page responsive (#428)
1 parent 5d2f7dd commit 33c1a33

File tree

1 file changed

+185
-14
lines changed

1 file changed

+185
-14
lines changed

src/pages/user/UserRegistration.jsx

Lines changed: 185 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,64 @@ import React, { useEffect, useState } from "react";
22
import { useLocation } from "react-router-dom";
33
import InputField from "../../Components/shared/InputField";
44
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+
=======
512
import custBackgroundImage from "../user/imgs/pngtree-blue-pastel-background-picture-image_1599663.jpg"; // Import your background image
613
import { FaEye, FaEyeSlash } from "react-icons/fa6";
714
import i1 from "../user/imgs/white-dog-pastel-blue-background-3d_89917-269.jpg";
815
import { login, registration } from "../../utils/Functions/userAuthService";
916
import LoginTextLink from "../../Components/shared/LoginTextLink";
1017
import AlertDialog from "../../Components/shared/AlertDialog";
1118

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-
};
2419

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+
);
2627
}
2728

2829
function LoginRegisterForm() {
2930
const location = useLocation();
31+
32+
const [isPassVisible, setIsPassVisible] = useState(false);
33+
const [userTypingPassword, setUserTypingPassword] = useState(false);
34+
let isLogin = location.pathname !== "/register";
35+
=======
3036
const [userTypingPassword, setUserTypingPassword] = useState(false);
3137
const isLogin = location.pathname !== "/register";
3238

39+
3340
const customButtonStyle = {
3441
borderRadius: "20px",
3542
background: "linear-gradient(to bottom, #b3d9ff, #3399ff)",
43+
44+
padding: "16px 32px",
45+
marginTop: "1rem",
46+
fontSize: "18px",
47+
3648
padding: "20px 40px",
3749
marginTop: "0.675rem",
3850
fontSize: "22px",
51+
3952
fontWeight: "800",
4053
boxShadow: "rgb(38, 57, 77) 0px 15px 30px -10px",
41-
letterSpacing: "0.2rem",
54+
letterSpacing: "0.1rem",
4255
width: "fit-content",
4356
margin: "auto",
4457
};
4558

59+
60+
const [name, setname] = useState("");
61+
const [phone_number, setPhone_number] = useState("");
62+
4663
const [name, setName] = useState("");
4764
const [phone_number, setPhoneNumber] = useState("");
4865
const [email, setEmail] = useState("");
@@ -71,6 +88,158 @@ function LoginRegisterForm() {
7188
setHasSymbol(/[^A-Za-z0-9]/.test(value));
7289
};
7390

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+
=======
74243
const handleRegistration = async () => {
75244
const res = await registration(
76245
name,
@@ -271,13 +440,15 @@ function LoginRegisterForm() {
271440
</div>
272441
</div>
273442
</div>
443+
274444
</div>
275445
<AlertDialog
276446
open={isOpenConfirmBox}
277447
handleClose={closeConfirmationDialog}
278448
/>
279449
</div>
280450
);
451+
281452
}
282453

283454
export default LoginRegisterForm;

0 commit comments

Comments
 (0)