From 3aebbcd1ef600fc2724befdf2af9a8008ef935af Mon Sep 17 00:00:00 2001 From: Ishika Gupta <118624573+Ishika-Gupta06@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:53:41 +0000 Subject: [PATCH] Confirmation msg upon registering --- frontend/src/Pages/Register.jsx | 220 +++++++++++++++++--------------- 1 file changed, 117 insertions(+), 103 deletions(-) diff --git a/frontend/src/Pages/Register.jsx b/frontend/src/Pages/Register.jsx index d1f19c6..1f64225 100644 --- a/frontend/src/Pages/Register.jsx +++ b/frontend/src/Pages/Register.jsx @@ -1,133 +1,147 @@ -import React, { useState } from 'react'; -import logo from '../assets/stationsaarthi.svg'; // Ensure the path is correct +import React, { useState, useEffect } from 'react'; +import logo from '../assets/stationsaarthi.svg'; import { useNavigate } from 'react-router-dom'; import backicon from '../assets/svg/backicon.svg'; -const Register = () => { +const Register = () => { const navigate = useNavigate(); + const LoginClick = () => { - navigate('/Login'); // Navigates to the login page + navigate('/Login'); }; const HomeClick = () => { - navigate('/'); // Navigates to the home page + navigate('/'); }; - + const [name, setName] = useState(''); const [phoneNumber, setPhoneNumber] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); + const [confirmationMessage, setConfirmationMessage] = useState(''); // State for confirmation message const handleRegister = (e) => { e.preventDefault(); - // Handle registration logic here + // Perform registration logic here (e.g., API call) + + // Set confirmation message + setConfirmationMessage("Your account is created successfully. Please login to access the website."); + + // Clear form fields + setName(''); + setPhoneNumber(''); + setEmail(''); + setPassword(''); }; + // Use effect to clear the confirmation message after 3 seconds + useEffect(() => { + if (confirmationMessage) { + const timer = setTimeout(() => setConfirmationMessage(''), 3000); + return () => clearTimeout(timer); // Cleanup timer on component unmount + } + }, [confirmationMessage]); + return ( <> - -
- {/* Logo and Title */} -
-
- Station Saarthi Logo -

Station Saarthi

-

Your Trusted Platform Guide

-
+
+ {/* Top Positioned Translucent Confirmation Message */} + {confirmationMessage && ( +
+ {confirmationMessage} +
+ )} + +
+ +
+
+ Station Saarthi Logo +

Station Saarthi

+

Your Trusted Platform Guide

+
- {/* Registration Form */} -
- {/* Register Heading */} -

- Register -

+ +

+ Register +

- {/* Name Input */} -
- - setName(e.target.value)} - placeholder="Enter your name" - className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" - required - /> -
+
+ + setName(e.target.value)} + placeholder="Enter your name" + className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + required + /> +
- {/* Phone Number Input */} -
- - setPhoneNumber(e.target.value)} - placeholder="Enter your phone number" - pattern="\d{10}" - maxLength="10" - className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" - required - /> - {phoneNumber && phoneNumber.length !== 10 && ( -

- Please enter a valid 10-digit phone number. -

- )} -
+
+ + setPhoneNumber(e.target.value)} + placeholder="Enter your phone number" + pattern="\d{10}" + maxLength="10" + className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + required + /> + {phoneNumber && phoneNumber.length !== 10 && ( +

Please enter a valid 10-digit phone number.

+ )} +
- {/* Email Input */} -
- - setEmail(e.target.value)} - placeholder="Enter your email" - className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" - required - /> -
+
+ + setEmail(e.target.value)} + placeholder="Enter your email" + className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + required + /> +
- {/* Password Input */} -
- - setPassword(e.target.value)} - placeholder="Create a password" - className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" - required - /> -
+
+ + setPassword(e.target.value)} + placeholder="Create a password" + className="w-full px-3 py-2 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" + required + /> +
- {/* Register Button */} - -
+ + - {/* Already have an account link */} -

- Already have an account?{' '} - -

-
+

+ Already have an account?{' '} + +

+
); }; -export default Register; \ No newline at end of file +export default Register;