2024-12-05 08:31:12 +00:00
|
|
|
import axiosInstance from '../../../../utils/axiosInstance';
|
2024-10-31 02:32:14 +00:00
|
|
|
|
|
|
|
|
const config = {
|
|
|
|
|
headers: {
|
|
|
|
|
Authorization: localStorage.getItem('token')
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fetchProfile = async () => {
|
|
|
|
|
try {
|
2024-12-05 08:31:12 +00:00
|
|
|
const response = await axiosInstance.get(`/getMe`, config);
|
2024-10-31 02:32:14 +00:00
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const updateProfile = async (id, formData) => {
|
|
|
|
|
try {
|
2024-12-05 08:31:12 +00:00
|
|
|
const response = await axiosInstance.put(`/user/update/${id}`, formData);
|
2024-10-31 02:32:14 +00:00
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const updatePassword = async (userId, passwordData) => {
|
|
|
|
|
try {
|
2024-12-05 08:31:12 +00:00
|
|
|
const response = await axiosInstance.put(`/user/update/password/${userId}`, passwordData);
|
2024-10-31 02:32:14 +00:00
|
|
|
return response.data;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
throw error;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
fetchProfile,
|
|
|
|
|
updateProfile,
|
|
|
|
|
updatePassword
|
|
|
|
|
};
|