This commit is contained in:
omkieit 2024-09-07 11:09:50 +05:30
parent 17fc533c25
commit 690f682f12
9 changed files with 56 additions and 24 deletions

View File

@ -8,7 +8,7 @@ const secret = process.env.SECRET_KEY;
// This is signup
export const signup = async (req, res) => {
const { email, password, firstName, lastName } = req.body;
const { email, password, firstName, middleName, lastName } = req.body;
try {
// Check if user already exists
@ -25,6 +25,7 @@ export const signup = async (req, res) => {
email,
password: hashedPassword,
firstName,
middleName,
lastName,
});

View File

@ -2,6 +2,7 @@ import mongoose from "mongoose";
const userSchema = new mongoose.Schema({
firstName: { type: String, required: true },
middleName: { type: String, required: true },
lastName: { type: String, required: true },
email: { type: String, required: true, unique: true },
password: { type: String, required: true },

File diff suppressed because one or more lines are too long

View File

@ -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-DW_yaEwf.js"></script>
<script type="module" crossorigin src="/assets/index-BSMgqDC4.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-CyAHZLBw.css">
</head>

View File

@ -52,6 +52,10 @@ const Dashboard = () => {
First Name:{" "}
<span style={{ color: "#067ADC" }}>{user.result.firstName}</span>
</label>
<label htmlFor="middleName" className="col-sm-6 col-form-label">
Middle Name:{" "}
<span style={{ color: "#067ADC" }}>{user.result.middleName}</span>
</label>
<label htmlFor="lastName" className="col-sm-6 col-form-label">
Last Name:{" "}
<span style={{ color: "#067ADC" }}>{user.result.lastName}</span>

View File

@ -10,6 +10,7 @@ const Navbar = () => {
const dispatch = useDispatch();
const navigate = useNavigate();
const handleLogout = () => {
dispatch(setLogout());
navigate("/");

View File

@ -11,6 +11,7 @@ import "primeicons/primeicons.css";
const initialState = {
firstName: "",
middleName:"",
lastName: "",
email: "",
password: "",
@ -21,7 +22,7 @@ const Register = () => {
const [formValue, setFormValue] = useState(initialState);
const [isFormValid, setIsFormValid] = useState(false); // New state variable
const { loading, error } = useSelector((state) => ({ ...state.auth }));
const { email, password, firstName, lastName, confirmPassword } = formValue;
const { email, password, firstName, middleName, lastName, confirmPassword } = formValue;
const dispatch = useDispatch();
const navigate = useNavigate();
@ -34,10 +35,10 @@ const Register = () => {
useEffect(() => {
// Check if all fields are filled and all three checkboxes are selected
const isValid =
email && password && firstName && lastName && confirmPassword;
email && password && firstName && middleName && lastName && confirmPassword;
setIsFormValid(isValid);
}, [email, password, firstName, lastName, confirmPassword]);
}, [email, password, firstName, middleName, lastName, confirmPassword]);
const handleSubmit = (e) => {
e.preventDefault();
@ -135,6 +136,27 @@ const Register = () => {
</label>
</div>
</div>
<div className="col-12">
<div className="form-floating mb-3">
<input
type="text"
className="form-control"
value={middleName}
name="middleName"
onChange={onInputChange}
placeholder="Middle Name"
required="required"
/>
<label htmlFor="middleName" className="form-label">
Middle Name
</label>
</div>
</div>
<div className="col-12">
<div className="form-floating mb-3">
<input

View File

@ -1,10 +1,11 @@
import { configureStore } from "@reduxjs/toolkit";
import AuthReducer from "./features/authSlice";
import userReducer from "./features/userSlice";
export default configureStore({
reducer: {
auth: AuthReducer,
user: userReducer,
},
});

View File

@ -18,3 +18,5 @@ export default defineConfig({
},
})