diff --git a/client/package-lock.json b/client/package-lock.json
index f264be2..8acedd3 100644
--- a/client/package-lock.json
+++ b/client/package-lock.json
@@ -19,7 +19,8 @@
"react-icons": "^5.3.0",
"react-phone-number-input": "^3.4.5",
"react-router-dom": "^6.26.1",
- "react-toastify": "^10.0.5"
+ "react-toastify": "^10.0.5",
+ "socket.io-client": "^4.7.5"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
@@ -2019,6 +2020,11 @@
"win32"
]
},
+ "node_modules/@socket.io/component-emitter": {
+ "version": "3.1.2",
+ "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.2.tgz",
+ "integrity": "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA=="
+ },
"node_modules/@swc/helpers": {
"version": "0.5.12",
"resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.12.tgz",
@@ -2988,7 +2994,6 @@
"version": "4.3.6",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.6.tgz",
"integrity": "sha512-O/09Bd4Z1fBrU4VzkhFqVgpPzaGbw6Sm9FEkBT1A/YBXQFGuuSxa1dN2nxgxS34JmKXqYx8CZAwEVoJFImUXIg==",
- "dev": true,
"license": "MIT",
"dependencies": {
"ms": "2.1.2"
@@ -3157,6 +3162,26 @@
"node": ">= 0.8"
}
},
+ "node_modules/engine.io-client": {
+ "version": "6.5.4",
+ "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-6.5.4.tgz",
+ "integrity": "sha512-GeZeeRjpD2qf49cZQ0Wvh/8NJNfeXkXXcoGh+F77oEAgo9gUHwT1fCRxSNU+YEEaysOJTnsFHmM5oAcPy4ntvQ==",
+ "dependencies": {
+ "@socket.io/component-emitter": "~3.1.0",
+ "debug": "~4.3.1",
+ "engine.io-parser": "~5.2.1",
+ "ws": "~8.17.1",
+ "xmlhttprequest-ssl": "~2.0.0"
+ }
+ },
+ "node_modules/engine.io-parser": {
+ "version": "5.2.3",
+ "resolved": "https://registry.npmjs.org/engine.io-parser/-/engine.io-parser-5.2.3.tgz",
+ "integrity": "sha512-HqD3yTBfnBxIrbnM1DoD6Pcq8NECnh8d4As1Qgh0z5Gg3jRRIqijury0CL3ghu/edArpUYiYqQiDUQBIs4np3Q==",
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
"node_modules/es-abstract": {
"version": "1.23.3",
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.23.3.tgz",
@@ -5179,7 +5204,6 @@
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
- "dev": true,
"license": "MIT"
},
"node_modules/mz": {
@@ -6481,6 +6505,32 @@
"url": "https://github.com/sponsors/isaacs"
}
},
+ "node_modules/socket.io-client": {
+ "version": "4.7.5",
+ "resolved": "https://registry.npmjs.org/socket.io-client/-/socket.io-client-4.7.5.tgz",
+ "integrity": "sha512-sJ/tqHOCe7Z50JCBCXrsY3I2k03iOiUe+tj1OmKeD2lXPiGH/RUCdTZFoqVyN7l1MnpIzPrGtLcijffmeouNlQ==",
+ "dependencies": {
+ "@socket.io/component-emitter": "~3.1.0",
+ "debug": "~4.3.2",
+ "engine.io-client": "~6.5.2",
+ "socket.io-parser": "~4.2.4"
+ },
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
+ "node_modules/socket.io-parser": {
+ "version": "4.2.4",
+ "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-4.2.4.tgz",
+ "integrity": "sha512-/GbIKmo8ioc+NIWIhwdecY0ge+qVBSMdgxGygevmdHj24bsfgtCmcUUcQ5ZzcylGFHsN3k4HB4Cgkl96KVnuew==",
+ "dependencies": {
+ "@socket.io/component-emitter": "~3.1.0",
+ "debug": "~4.3.1"
+ },
+ "engines": {
+ "node": ">=10.0.0"
+ }
+ },
"node_modules/source-map-js": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
@@ -7444,6 +7494,34 @@
"url": "https://github.com/chalk/strip-ansi?sponsor=1"
}
},
+ "node_modules/ws": {
+ "version": "8.17.1",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
+ "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
+ "engines": {
+ "node": ">=10.0.0"
+ },
+ "peerDependencies": {
+ "bufferutil": "^4.0.1",
+ "utf-8-validate": ">=5.0.2"
+ },
+ "peerDependenciesMeta": {
+ "bufferutil": {
+ "optional": true
+ },
+ "utf-8-validate": {
+ "optional": true
+ }
+ }
+ },
+ "node_modules/xmlhttprequest-ssl": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/xmlhttprequest-ssl/-/xmlhttprequest-ssl-2.0.0.tgz",
+ "integrity": "sha512-QKxVRxiRACQcVuQEYFsI1hhkrMlrXHPegbbd1yn9UHOmRxY+si12nQYzri3vbzt8VdTTRviqcKxcyllFas5z2A==",
+ "engines": {
+ "node": ">=0.4.0"
+ }
+ },
"node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
diff --git a/client/package.json b/client/package.json
index 2d5ad33..b8cdafb 100644
--- a/client/package.json
+++ b/client/package.json
@@ -25,7 +25,8 @@
"react-icons": "^5.3.0",
"react-phone-number-input": "^3.4.5",
"react-router-dom": "^6.26.1",
- "react-toastify": "^10.0.5"
+ "react-toastify": "^10.0.5",
+ "socket.io-client": "^4.7.5"
},
"devDependencies": {
"@eslint/js": "^9.9.0",
diff --git a/client/src/assets/bgimg.jpeg b/client/src/assets/bgimg.jpeg
new file mode 100644
index 0000000..847179b
Binary files /dev/null and b/client/src/assets/bgimg.jpeg differ
diff --git a/client/src/components/Buyer/Login.jsx b/client/src/components/Buyer/Login.jsx
index 78abf41..40e073b 100644
--- a/client/src/components/Buyer/Login.jsx
+++ b/client/src/components/Buyer/Login.jsx
@@ -3,6 +3,9 @@ import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';
import { app } from '../../../firebase';
import { useNavigate } from 'react-router-dom';
import styles from './signup.module.css'; // Import the CSS Module
+import Navi from './Navi'
+import { toast, ToastContainer } from 'react-toastify';
+import img from '../../assets/bgimg.jpeg';
const auth = getAuth(app);
@@ -15,12 +18,12 @@ const Login = () => {
e.preventDefault();
try {
await signInWithEmailAndPassword(auth, email, password).then(() => {
- alert('success');
+ toast.success('Welcome');
navigate('/buyer');
});
} catch (error) {
// Handle errors here
- alert(`Error: ${error.message}`);
+ toast.error('Error Loging in:', error);
}
};
@@ -30,8 +33,9 @@ const Login = () => {
<>
+
-
{/* Header content */}
+
@@ -64,6 +68,7 @@ const Login = () => {
+
>
);
diff --git a/client/src/components/Buyer/Navi.jsx b/client/src/components/Buyer/Navi.jsx
new file mode 100644
index 0000000..38e9dc9
--- /dev/null
+++ b/client/src/components/Buyer/Navi.jsx
@@ -0,0 +1,26 @@
+import React from 'react'
+import styles from './signup.module.css';
+import { FaHome } from "react-icons/fa";
+import { useNavigate } from 'react-router-dom';
+
+export default function Navi() {
+ const navigate = useNavigate();
+ return(
+
+
navigate('/')}>
+
+
Agri
+
+
+
Connect
+
+
+
+
+
+
+ )
+}
diff --git a/client/src/components/Buyer/Signup.jsx b/client/src/components/Buyer/Signup.jsx
index 0009fa8..ce78633 100644
--- a/client/src/components/Buyer/Signup.jsx
+++ b/client/src/components/Buyer/Signup.jsx
@@ -1,13 +1,17 @@
import { useState } from 'react';
import { auth } from '../../../firebase';
-import { useNavigate } from 'react-router-dom';
+import { Navigate, useNavigate } from 'react-router-dom';
+import Navi from './Navi'
import styles from './signup.module.css'; // Import the CSS Module
+import { FcGoogle } from "react-icons/fc";
+import { toast, ToastContainer } from 'react-toastify';
+import img from '../../assets/bgimg.jpeg';
import {
createUserWithEmailAndPassword,
GoogleAuthProvider,
signInWithPopup,
} from 'firebase/auth';
-import Navbar from '../LandingPage/Navbar';
+
const googleProvider = new GoogleAuthProvider();
@@ -17,20 +21,23 @@ export default function Signup() {
const navigate = useNavigate();
const signupWithGoogle = () => {
- signInWithPopup(auth, googleProvider).then(() => alert('success'));
+ signInWithPopup(auth, googleProvider).then((e) => {
+ toast.success('Welcome')
+ navigate('/buyer');
+ });
};
const create = async (e) => {
e.preventDefault();
try {
await createUserWithEmailAndPassword(auth, email, password).then(() => {
- alert('success');
+ toast.success('Welcome');
navigate('/buyer');
const user = auth.currentUser;
console.log(user);
});
} catch (error) {
- alert(`Error: ${error.message}`);
+ toast.error('Error signing in:', error);
}
};
@@ -38,9 +45,10 @@ export default function Signup() {
return (
+
+
);
}
diff --git a/client/src/components/Buyer/signup.module.css b/client/src/components/Buyer/signup.module.css
index 565c338..285362f 100644
--- a/client/src/components/Buyer/signup.module.css
+++ b/client/src/components/Buyer/signup.module.css
@@ -6,6 +6,7 @@
width: 100%;
height: 100vh;
color: white;
+ overflow: hidden;
}
.headervg{
margin: 0;
@@ -17,18 +18,22 @@
.heading h1{
font-size: 35px;
}
-.bgimg{
+.bgimg>img{
margin: 0px;
padding: 0px;
- height: inherit;
- background-image: url("https://th.bing.com/th/id/R.77dfcc4d3db9d58d263ddfb9424aa74d?rik=9dwG7dUFc8aI9A&riu=http%3a%2f%2fs.wsj.net%2fpublic%2fresources%2fimages%2fBN-BB446_ifarm_P_20140111221144.jpg&ehk=fcYS84qt1uyS6xk2qf7no1vx09cNSjswk8cR4%2bLOSs4%3d&risl=&pid=ImgRaw&r=0");
- background-repeat: no-repeat;
+ height: 98.5vh;
+ width: 100%;
+ /* background-image: url("https://th.bing.com/th/id/R.77dfcc4d3db9d58d263ddfb9424aa74d?rik=9dwG7dUFc8aI9A&riu=http%3a%2f%2fs.wsj.net%2fpublic%2fresources%2fimages%2fBN-BB446_ifarm_P_20140111221144.jpg&ehk=fcYS84qt1uyS6xk2qf7no1vx09cNSjswk8cR4%2bLOSs4%3d&risl=&pid=ImgRaw&r=0"); */
+ /* background-repeat: no-repeat;
background-size: cover;
- background-position:center;
+ background-position:center; */
+ position:absolute;
+ z-index: -1;
+ overflow: hidden;
}
.fade{
- height: 100%;
- background-color: rgba(0, 0, 0, 0.5);
+ height: 98.5vh;
+ background-color: rgba(0, 0, 0, 0.329);
}
.boxvg{
margin:5rem;
@@ -105,18 +110,77 @@ select>option{
box-shadow:none ;
border: none;
font-family: 'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
- font-size: 22px;
+ font-size: 25px;
cursor: pointer;
text-decoration: underline;
+ display: flex;
+ gap: 10px;
+ position: relative;
+ left: 2vw;
}
-#recaptcha-container{
+.google>button>span{
+ font-size: 20px;
+ position: relative;
+ bottom: 5px;
+}
+.captcha{
position: relative;
left: 2vw;
+ bottom: 3vh;
}
.i2{
width: 22vw;
color: black;
-
+
+}
+.navi{
+ display: flex;
+ color: white;
+ margin: 10px;
+ padding: 10px;
+ gap:70vw;
+}
+.first{
+ color: chartreuse;
+}
+.second{
+ color: white;
+}
+.brand{
+ display: flex;
+ cursor: pointer;
+ font-size: 40px;
+}
+.su>select{
+ background-color: transparent;
+ color: white;
+ outline: none;
+ font-size: 20px;
+}
+.bt3{
+ margin: 10px;
+ font-size: 30px;
+ display: flex;
+ gap: 10px;
+ color:white;
+}
+.bt3:hover{
+ color: chartreuse;
+ scale: 1.04;
+}
+.bt3>h2{
+ position: relative;
+ bottom: 7px;
+}
+.i3{
+ width: 22vw;
+ margin-right: 10px;
+ color: black;
+}
+.i4{
+ width: 22vw;
+ margin-left: 2vw;
+ color: black;
+ background-color: transparent;
}
-
diff --git a/client/src/components/Farmer/FLogin.jsx b/client/src/components/Farmer/FLogin.jsx
index 9098a9b..b86204b 100644
--- a/client/src/components/Farmer/FLogin.jsx
+++ b/client/src/components/Farmer/FLogin.jsx
@@ -3,17 +3,37 @@ import 'react-phone-number-input/style.css';
import PhoneInput from 'react-phone-number-input';
import { useNavigate } from 'react-router-dom';
import styles from '../Buyer/signup.module.css'; // Import the CSS Module
+import Navi from '../Buyer/Navi'
+import { toast, ToastContainer } from 'react-toastify';
+import img from '../../assets/bgimg.jpeg';
+import { getAuth } from 'firebase/auth';
+import { app } from '../../../firebase';
+const auth =getAuth(app)
const FLogin = () => {
const [phno, setphno] = useState('');
const navigate = useNavigate();
+ const loginUser = async (e) => {
+ e.preventDefault();
+ try {
+ await signInWithPhoneNumber(auth,phno).then(() => {
+ toast.success('Welcome');
+ navigate('/farmerdashboard');
+ });
+ } catch (error) {
+ // Handle errors here
+ toast.error('Error Loging in:', error);
+ }
+ };
+
return (
<>
+
-
{/* Header content */}
+
@@ -25,12 +45,11 @@ const FLogin = () => {
value={phno}
onChange={setphno}
placeholder="Phone Number"
- className={styles.i2}
- style={{ backgroundColor: 'transparent' }}
+ className={styles.i3}
/>
-
+
Don't have an account?{' '}
@@ -40,6 +59,7 @@ const FLogin = () => {
+
>
);
diff --git a/client/src/components/Farmer/FSignup.jsx b/client/src/components/Farmer/FSignup.jsx
index 264a71f..4e9cbbe 100644
--- a/client/src/components/Farmer/FSignup.jsx
+++ b/client/src/components/Farmer/FSignup.jsx
@@ -1,6 +1,7 @@
import { useState } from 'react';
import 'react-phone-number-input/style.css';
import PhoneInput from 'react-phone-number-input';
+import { toast, ToastContainer } from 'react-toastify';
import {
getAuth,
signInWithPhoneNumber,
@@ -9,28 +10,40 @@ import {
import { app } from '../../../firebase';
import { useNavigate } from 'react-router-dom';
import styles from '../Buyer/signup.module.css'; // Import the CSS Module
+import Navi from '../Buyer/Navi';
+import img from '../../assets/bgimg.jpeg';
const auth = getAuth(app);
const FSignup = () => {
const [phno, setphno] = useState('');
const navigate = useNavigate();
+ const [otp,setOtp]=useState("");
+ const [flag,setflag]=useState(false)
+ const [flagg,setflagg]=useState(false)
+ const [confirmobj,setconfirmobj]=useState("");
const getOtp = async (e) => {
e.preventDefault();
if (phno === '' || phno === undefined) {
- alert('INVALID PHONE NUMBER');
+ toast.error('INVALID PHONE NUMBER');
}
- try {
- const response = await Recaptcha(phno);
- console.log(response);
- } catch (error) {
- alert(`Error: ${error.message}`);
+ else{
+ try {
+ const response = await Recaptcha(phno);
+ console.log(response);
+ setconfirmobj(response)
+ setflag(true)
+ } catch (error) {
+ setflagg(false)
+ toast.error(`Error: ${error.message}`);
+ }
+ console.log(phno);
}
- console.log(phno);
};
function Recaptcha(phno) {
+ setflagg(true)
const recaptchaVerifier = new RecaptchaVerifier(
auth,
'recaptcha-container',
@@ -40,39 +53,66 @@ const FSignup = () => {
return signInWithPhoneNumber(auth, phno, recaptchaVerifier);
}
+ const verifyotp=async(e)=>{
+ e.preventDefault();
+ console.log(otp);
+ if(otp ==="" || opt===null) return;
+ try{
+ await confirmobj.confirm(otp)
+ //navigate here
+ }catch (error) {
+ toast.error(`Error: ${error.message}`);
+ }
+ }
+
return (
<>
+
-
{/* Header content */}
+
+
>
);
diff --git a/client/src/components/LandingPage/AgriConnect.jsx b/client/src/components/LandingPage/AgriConnect.jsx
index 361774c..fa028d7 100644
--- a/client/src/components/LandingPage/AgriConnect.jsx
+++ b/client/src/components/LandingPage/AgriConnect.jsx
@@ -1,4 +1,4 @@
-import 'bootstrap/dist/css/bootstrap.min.css';
+// import 'bootstrap/dist/css/bootstrap.min.css';
import './Landing.css'
import img from '../../assets/buyerPic2.jpeg'
import img1 from '../../assets/farmerPic.jpeg'
diff --git a/client/src/components/Negotiate/Chat.jsx b/client/src/components/Negotiate/Chat.jsx
index 3b14c88..5429e7c 100644
--- a/client/src/components/Negotiate/Chat.jsx
+++ b/client/src/components/Negotiate/Chat.jsx
@@ -1,7 +1,42 @@
import './chat.css';
-import { useState, useRef, useEffect } from 'react';
+import io from 'socket.io-client'
+import { useState, useRef, useEffect, useContext } from 'react';
+import { addDoc, collection, doc, getDoc } from 'firebase/firestore';
+import {db} from '../../../firebase'
+import { AuthContext } from '../context/Authcontext';
export default function Chat() {
+ //current user context
+ const { currentUser } = useContext(AuthContext);
+ const [userType, setUserType] = useState("buyers"); //change depending upon the type of user(buyer or farmer)
+ const [contacts, setContacts] = useState({});
+ // console.log(currentUser);
+ console.log(contacts);
+ //testing values, to be removed later
+ const roomID = 'room1';
+ const SERVER_PORT = import.meta.env.VITE_SERVER_PORT;
+
+ const [socket, setSocket]= useState(null);
+
+ useEffect(()=>{
+ //establish new socket connection
+ const newSocket = io.connect(`http://localhost:${SERVER_PORT}`);
+ setSocket(newSocket);
+
+ //monitor messages
+ newSocket.on("recieve-message", (recieved_message)=>{
+ setMessages(prevMessages => [...prevMessages, recieved_message]);
+ })
+
+ //get all contacts when u load the page
+ getContacts(currentUser.uid, userType).then((result)=>{
+ setContacts(result);
+ });
+ return () => {
+ newSocket.disconnect();
+ };
+ },[])
+
// State for the input text and messages
const [text, setText] = useState('');
const [messages, setMessages] = useState([]);
@@ -15,8 +50,25 @@ export default function Chat() {
}, [messages]);
// Handle the click event to add a new message
- const handleClick = () => {
+ const handleClick = async () => {
+ //send message to server through websocket
if (text.trim()) {
+
+ if (socket) {
+ socket.emit("send-message", { message: text});
+ }
+
+ //add message to database
+ try {
+ await addDoc(collection(db, 'chats', roomID, 'messages'), {
+ message: text,
+ timeStamp: new Date(),
+ user: currentUser.uid,
+ });
+ } catch (error) {
+ console.error("Error uploading message:", error);
+ }
+
setMessages([...messages, text]);
setText('');
}
@@ -56,3 +108,24 @@ export default function Chat() {
);
}
+
+const getContacts = async (userID, userType)=>{
+ try {
+ const userDocRef = doc(db, userType, userID);
+ const userDoc = await getDoc(userDocRef);
+ if (userDoc.exists()) {
+ const userData = userDoc.data();
+ return userData.Contacts
+ // const contacts = userData.contacts || [];
+
+ // console.log("Contacts:", contacts);
+ // return contacts;
+ } else {
+ console.log("No such user!");
+ return [];
+ }
+ } catch (error) {
+ console.error("Error fetching contacts:", error);
+ return [];
+ }
+}
diff --git a/client/src/components/ProfileSetup/Profilesetup.jsx b/client/src/components/ProfileSetup/Profilesetup.jsx
index 64a5be1..e9fbab9 100644
--- a/client/src/components/ProfileSetup/Profilesetup.jsx
+++ b/client/src/components/ProfileSetup/Profilesetup.jsx
@@ -1,11 +1,11 @@
-import { useState,useEffect } from 'react';
-import './profilesetup.css';
+import { useState, useEffect } from 'react';
+import styles from './profilesetup.module.css'; // Import the CSS module
import { db } from '../../../firebase';
import { addDoc, collection } from 'firebase/firestore';
export default function Profilesetup() {
- const port = import.meta.env.VITE_PORT
+ const port = import.meta.env.VITE_PORT;
const [imagePreview1, setImagePreview1] = useState(null);
const [imagePreview2, setImagePreview2] = useState(null);
@@ -34,16 +34,16 @@ export default function Profilesetup() {
useEffect(() => {
fetch(`http://localhost:${port}/states`)
- .then(response => response.json())
- .then(data => setStates(data));
+ .then((response) => response.json())
+ .then((data) => setStates(data));
}, [port]);
const handleStateChange = (e) => {
const state = e.target.value;
setSelectedState(state);
fetch(`http://localhost:${port}/districts/${state}`)
- .then(response => response.json())
- .then(data => {
+ .then((response) => response.json())
+ .then((data) => {
setDistricts(data);
setSubdistricts([]);
setAreas([]);
@@ -54,8 +54,8 @@ export default function Profilesetup() {
const district = e.target.value;
setSelectedDistrict(district);
fetch(`http://localhost:${port}/subdistricts/${selectedState}/${district}`)
- .then(response => response.json())
- .then(data => {
+ .then((response) => response.json())
+ .then((data) => {
setSubdistricts(data);
setAreas([]);
});
@@ -64,9 +64,11 @@ export default function Profilesetup() {
const handleSubdistrictChange = (e) => {
const subdistrict = e.target.value;
setSelectedSubdistrict(subdistrict);
- fetch(`http://localhost:${port}/areas/${selectedState}/${selectedDistrict}/${subdistrict}`)
- .then(response => response.json())
- .then(data => setAreas(data));
+ fetch(
+ `http://localhost:${port}/areas/${selectedState}/${selectedDistrict}/${subdistrict}`
+ )
+ .then((response) => response.json())
+ .then((data) => setAreas(data));
};
const userCollectionRef = collection(db, 'farmerdata');
@@ -115,19 +117,24 @@ export default function Profilesetup() {
// Validate form fields
const validateForm = () => {
let tempErrors = {};
- if (!firstname) tempErrors.firstname = "First name is required.";
- if (!lastname) tempErrors.lastname = "Last name is required.";
- if (!gender) tempErrors.gender = "Gender is required.";
- if (!dob || new Date(dob) >= new Date('2003-01-01')) tempErrors.dob = "DOB must be before 2002.";
- if (!address) tempErrors.address = "Address is required.";
- if (!pincode || pincode.length !== 6) tempErrors.pincode = "Pincode must be 6 digits.";
- if (!photoidtype) tempErrors.photoidtype = "Photo ID type is required.";
- if (!photoidnumber) tempErrors.photoidnumber = "Photo ID number is required.";
- if (!ifsc) tempErrors.ifsc = "IFSC code is required.";
- if (!accountnumber) tempErrors.accountnumber = "Account number is required.";
- if (!bankname) tempErrors.bankname = "Bank name is required.";
- if (!branchname) tempErrors.branchname = "Branch name is required.";
- if (!branchaddress) tempErrors.branchaddress = "Branch address is required.";
+ if (!firstname) tempErrors.firstname = 'First name is required.';
+ if (!lastname) tempErrors.lastname = 'Last name is required.';
+ if (!gender) tempErrors.gender = 'Gender is required.';
+ if (!dob || new Date(dob) >= new Date('2003-01-01'))
+ tempErrors.dob = 'DOB must be before 2002.';
+ if (!address) tempErrors.address = 'Address is required.';
+ if (!pincode || pincode.length !== 6)
+ tempErrors.pincode = 'Pincode must be 6 digits.';
+ if (!photoidtype) tempErrors.photoidtype = 'Photo ID type is required.';
+ if (!photoidnumber)
+ tempErrors.photoidnumber = 'Photo ID number is required.';
+ if (!ifsc) tempErrors.ifsc = 'IFSC code is required.';
+ if (!accountnumber)
+ tempErrors.accountnumber = 'Account number is required.';
+ if (!bankname) tempErrors.bankname = 'Bank name is required.';
+ if (!branchname) tempErrors.branchname = 'Branch name is required.';
+ if (!branchaddress)
+ tempErrors.branchaddress = 'Branch address is required.';
return Object.keys(tempErrors).length === 0;
};
@@ -135,9 +142,9 @@ export default function Profilesetup() {
// Handle form submission
const handleSubmit = async (e) => {
e.preventDefault();
-
+
if (!validateForm()) {
- alert("Please fill all required fields correctly.");
+ alert('Please fill all required fields correctly.');
return;
}
@@ -172,191 +179,466 @@ export default function Profilesetup() {
};
return (
- <>
-