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