done
This commit is contained in:
parent
18d967f528
commit
d040974f3f
|
@ -8,7 +8,7 @@ const secret = process.env.SECRET_KEY;
|
|||
|
||||
// This is signup
|
||||
export const signup = async (req, res) => {
|
||||
const { title, email, password, firstName, middleName, lastName, termsconditions } = req.body;
|
||||
const { title, email, password, firstName, middleName, lastName, termsconditions, userType } = req.body;
|
||||
|
||||
try {
|
||||
// Check if user already exists
|
||||
|
@ -29,6 +29,7 @@ export const signup = async (req, res) => {
|
|||
middleName,
|
||||
lastName,
|
||||
termsconditions,
|
||||
userType,
|
||||
});
|
||||
|
||||
// Generate JWT (if needed)
|
||||
|
|
|
@ -8,6 +8,7 @@ const userSchema = new mongoose.Schema({
|
|||
email: { type: String, required: true, unique: true },
|
||||
password: { type: String, required: true },
|
||||
termsconditions:{type: String,},
|
||||
userType:{ type: String, required: true },
|
||||
tokens:[
|
||||
{
|
||||
token:{
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -27,7 +27,7 @@
|
|||
<link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
|
||||
<!-- fonts -->
|
||||
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;800&family=Sen:wght@400;700;800&display=swap" rel="stylesheet">
|
||||
<script type="module" crossorigin src="/assets/index-BVbzGpWG.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-rSI24A6Q.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-CyAHZLBw.css">
|
||||
</head>
|
||||
|
||||
|
|
|
@ -12,35 +12,42 @@ import "primeicons/primeicons.css";
|
|||
const initialState = {
|
||||
title: "None",
|
||||
firstName: "",
|
||||
middleName:"",
|
||||
middleName: "",
|
||||
lastName: "",
|
||||
email: "",
|
||||
password: "",
|
||||
confirmPassword: "",
|
||||
termsconditions: "",
|
||||
userType: "", // New field for radio button selection
|
||||
};
|
||||
|
||||
const Register = () => {
|
||||
const [formValue, setFormValue] = useState(initialState);
|
||||
const [isFormValid, setIsFormValid] = useState(false); // New state variable
|
||||
const { loading, error } = useSelector((state) => ({ ...state.auth }));
|
||||
const { title, email, password, firstName, middleName, lastName, confirmPassword,termsconditions } = formValue;
|
||||
const { title, email, password, firstName, middleName, lastName, confirmPassword, termsconditions, userType } = formValue; // include userType
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
error && toast.error(error);
|
||||
}, [error]);
|
||||
|
||||
useEffect(() => {
|
||||
// Check if all fields are filled and all three checkboxes are selected
|
||||
// Check if all fields are filled and radio button is selected
|
||||
const isValid =
|
||||
title !== "None" && email && password && firstName && middleName && lastName && confirmPassword && termsconditions;
|
||||
title !== "None" &&
|
||||
email &&
|
||||
password &&
|
||||
firstName &&
|
||||
middleName &&
|
||||
lastName &&
|
||||
confirmPassword &&
|
||||
termsconditions &&
|
||||
userType !== ""; // Validate userType selection
|
||||
|
||||
setIsFormValid(isValid);
|
||||
}, [title, email, password, firstName, middleName, lastName, confirmPassword, termsconditions]);
|
||||
}, [title, email, password, firstName, middleName, lastName, confirmPassword, termsconditions, userType]);
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
@ -78,6 +85,14 @@ const Register = () => {
|
|||
}
|
||||
};
|
||||
|
||||
// New handler for radio buttons
|
||||
const handleUserTypeChange = (e) => {
|
||||
setFormValue((prevData) => ({
|
||||
...prevData,
|
||||
userType: e.target.value,
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Navbar />
|
||||
|
@ -92,14 +107,15 @@ const Register = () => {
|
|||
>
|
||||
<div className="container-fluid px-0">
|
||||
<div className="row gy-4 align-items-center justify-content-center">
|
||||
<div className="col-12 col-md-6 col-xl-20 text-center text-md-start">
|
||||
{/* <span className="pi pi-dollar" style={{ fontSize: '5rem', color:"#fda417" }} /> */}
|
||||
<i
|
||||
|
||||
|
||||
<div className="col-12 col-md-0 col-xl-20 text-center text-md-start">
|
||||
{/* <i
|
||||
className="fa fa-dollar"
|
||||
style={{ fontSize: "2.5rem", color: "#fda417" }}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<div className="text-bg-primary">
|
||||
/> */}
|
||||
{/* <div className="text-bg-primary">
|
||||
<div className="px-4">
|
||||
<hr className="border-primary-subtle mb-4" />
|
||||
<h2 className="h1 mb-4">Empower your investors</h2>
|
||||
|
@ -120,8 +136,10 @@ const Register = () => {
|
|||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
</div> */}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="col-12 col-md-6 col-xl-5">
|
||||
<div
|
||||
className="card border-0 rounded-4 shadow-lg"
|
||||
|
@ -132,8 +150,8 @@ const Register = () => {
|
|||
<div className="col-12">
|
||||
<div className="mb-4">
|
||||
<h2 className="h3">Registration</h2>
|
||||
<h3 className="fs-6 fw-normal text-secondary m-0">
|
||||
Enter your details to register
|
||||
<h3 style={{ color: "red" }}>
|
||||
All fields are mandatory to enable "Sign up"
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -142,6 +160,44 @@ const Register = () => {
|
|||
<div className="row gy-3 overflow-hidden">
|
||||
|
||||
|
||||
{/* Radio buttons for Lender and Borrower */}
|
||||
<div className="col-12">
|
||||
|
||||
<div className="form-floating mb-3">
|
||||
<label className="form-label">Please select the role <br /><br /></label>
|
||||
<div className="form-check form-check-inline">
|
||||
|
||||
|
||||
<input
|
||||
className="form-check-input"
|
||||
type="radio"
|
||||
name="userType"
|
||||
value="Lender"
|
||||
checked={userType === "Lender"}
|
||||
onChange={handleUserTypeChange}
|
||||
required
|
||||
/>
|
||||
<label className="form-check-label">Lender</label>
|
||||
</div>
|
||||
<div className="form-check form-check-inline">
|
||||
<input
|
||||
className="form-check-input"
|
||||
type="radio"
|
||||
name="userType"
|
||||
value="Borrower"
|
||||
checked={userType === "Borrower"}
|
||||
onChange={handleUserTypeChange}
|
||||
required
|
||||
/>
|
||||
<label className="form-check-label">Borrower </label>
|
||||
<br /><br /><br />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div className="col-12">
|
||||
<select
|
||||
className="form-floating mb-3 form-control"
|
||||
|
@ -156,13 +212,14 @@ const Register = () => {
|
|||
<option value="Mr">Mr</option>
|
||||
<option value="Miss">Miss</option>
|
||||
</select>
|
||||
<label htmlFor="firstName" className="form-label">
|
||||
{/* <label htmlFor="Select" className="form-label">
|
||||
{title === "Select" ? (
|
||||
<span>You selected {title}</span>
|
||||
) : (
|
||||
`You selected ${title}`
|
||||
)}
|
||||
</label>
|
||||
</label> */}
|
||||
<br />
|
||||
</div>
|
||||
|
||||
<div className="col-12">
|
||||
|
@ -201,8 +258,6 @@ const Register = () => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div className="col-12">
|
||||
<div className="form-floating mb-3">
|
||||
<input
|
||||
|
@ -298,7 +353,6 @@ const Register = () => {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="col-12">
|
||||
<div className="d-grid">
|
||||
<button
|
||||
|
@ -308,10 +362,12 @@ const Register = () => {
|
|||
backgroundColor: "#fda417",
|
||||
border: "#fda417",
|
||||
}}
|
||||
disabled={!isFormValid || loading}
|
||||
>
|
||||
{loading && <LoadingIcons.Bars />}
|
||||
Sign up
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue