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 ( <> - -
Your Trusted Platform Guide
-Your Trusted Platform Guide
+- Already have an account?{' '} - -
-+ Already have an account?{' '} + +
+