done
This commit is contained in:
parent
0bc57fd92f
commit
2dd33296d0
|
@ -41,6 +41,7 @@ export const signup = async (req, res) => {
|
|||
userId:userId,
|
||||
profileImage,
|
||||
});
|
||||
console.log("result", result)
|
||||
|
||||
// Generate JWT (if needed)
|
||||
const token = jwt.sign({ email: result.email, id: result._id }, secret, { expiresIn: "7h" });
|
||||
|
@ -228,6 +229,8 @@ export const updateUser = async (req, res) => {
|
|||
{ new: true } // Return the updated document
|
||||
);
|
||||
|
||||
console.log("updatedUser", updatedUser);
|
||||
|
||||
if (!updatedUser) {
|
||||
return res.status(404).json({ message: "User not found" });
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ const fundDetailsSchema = new mongoose.Schema({
|
|||
type: String,
|
||||
required: true,
|
||||
},
|
||||
status: { type: Boolean, default: false },
|
||||
}, { timestamps: true });
|
||||
|
||||
const FundDetailsModal = mongoose.model("FundDetails", fundDetailsSchema);
|
||||
|
|
|
@ -6,13 +6,14 @@ const userSchema = new mongoose.Schema({
|
|||
middleName: { type: String, required: true },
|
||||
lastName: { type: String, required: true },
|
||||
email: { type: String, required: true, unique: true },
|
||||
profileImage:String,
|
||||
// profileImage:String,
|
||||
profileImage: { type: String},
|
||||
// profileImage: { type: String, required: true, unique: true },
|
||||
aboutme: { type: String, required: true, unique: true },
|
||||
city: { type: String, required: true, unique: true },
|
||||
state: { type: String, required: true, unique: true },
|
||||
county: { type: String, required: true, unique: true },
|
||||
zip: { type: String, required: true, unique: true },
|
||||
aboutme: { type: String},
|
||||
city: { type: String },
|
||||
state: { type: String},
|
||||
county: { type: String},
|
||||
zip: { type: String },
|
||||
password: { type: String, required: true },
|
||||
termsconditions:{type: String,},
|
||||
userType:{ type: String, required: true },
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -45,7 +45,7 @@
|
|||
|
||||
|
||||
|
||||
<script type="module" crossorigin src="/assets/index-CDSCK5Cp.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-YX7OIV1T.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/assets/index-iEl-il0E.css">
|
||||
</head>
|
||||
|
||||
|
|
|
@ -3,9 +3,10 @@ import { useDispatch, useSelector } from "react-redux";
|
|||
import { updateUser } from "../redux/features/authSlice";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import FileBase from "react-file-base64";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
const UserProfile = () => {
|
||||
const { user, isLoading, error } = useSelector((state) => state.auth);
|
||||
const { user, isLoading } = useSelector((state) => state.auth);
|
||||
const dispatch = useDispatch();
|
||||
const navigate = useNavigate();
|
||||
|
||||
|
@ -51,10 +52,11 @@ const UserProfile = () => {
|
|||
setFormData({ ...formData, profileImage: "" }); // Reset the profileImage field
|
||||
};
|
||||
|
||||
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
dispatch(updateUser(formData)); // Dispatching updateUser with form data
|
||||
navigate("/login");
|
||||
dispatch(updateUser({formData, toast, navigate})); // Dispatching updateUser with form data
|
||||
};
|
||||
|
||||
return (
|
||||
|
@ -356,7 +358,7 @@ const UserProfile = () => {
|
|||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{error && <p>{error}</p>}
|
||||
|
||||
</form>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -2,6 +2,8 @@ import { createSlice, createAsyncThunk } from "@reduxjs/toolkit";
|
|||
import * as api from "../api";
|
||||
import axios from "axios";
|
||||
|
||||
const BASE_URL = import.meta.env.VITE_REACT_APP_SECRET;
|
||||
|
||||
|
||||
|
||||
export const login = createAsyncThunk(
|
||||
|
@ -36,10 +38,12 @@ export const register = createAsyncThunk(
|
|||
// Thunk to update user details
|
||||
export const updateUser = createAsyncThunk(
|
||||
'auth/updateUser',
|
||||
async (updatedUserData, { rejectWithValue }) => {
|
||||
async ({formData, toast, navigate}, { rejectWithValue }) => {
|
||||
try {
|
||||
const response = await axios.put(`http://localhost:3002/users/update`, updatedUserData);
|
||||
const response = await axios.put(`${BASE_URL}/users/update`, formData);
|
||||
// console.log('Update user response:', response.data);
|
||||
toast.success("Updated Successfully");
|
||||
navigate("/login");
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
return rejectWithValue(error.response.data);
|
||||
|
|
Loading…
Reference in New Issue