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 // This is signup
export const signup = async (req, res) => { export const signup = async (req, res) => {
const { email, password, firstName, lastName } = req.body; const { email, password, firstName, middleName, lastName } = req.body;
try { try {
// Check if user already exists // Check if user already exists
@ -25,6 +25,7 @@ export const signup = async (req, res) => {
email, email,
password: hashedPassword, password: hashedPassword,
firstName, firstName,
middleName,
lastName, lastName,
}); });

View File

@ -2,6 +2,7 @@ import mongoose from "mongoose";
const userSchema = new mongoose.Schema({ const userSchema = new mongoose.Schema({
firstName: { type: String, required: true }, firstName: { type: String, required: true },
middleName: { type: String, required: true },
lastName: { type: String, required: true }, lastName: { type: String, required: true },
email: { type: String, required: true, unique: true }, email: { type: String, required: true, unique: true },
password: { type: String, required: 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"> <link rel="stylesheet" href="https://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css">
<!-- fonts --> <!-- 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"> <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"> <link rel="stylesheet" crossorigin href="/assets/index-CyAHZLBw.css">
</head> </head>

View File

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

View File

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

View File

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

View File

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

View File

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