import axiosInstance from '../../../../utils/axiosInstance';

const config = {
    headers: {
      Authorization: localStorage.getItem('token')
    }
};

const fetchProfile = async () => {
    try {
        const response = await axiosInstance.get(`/getMe`, config);
        return response.data;
    } catch (error) {
        throw error;
    }
};

const updateProfile = async (id, formData) => {
    try {
        const response = await axiosInstance.put(`/user/update/${id}`, formData);
        return response.data;
    } catch (error) {
        throw error;
    }
};

const updatePassword = async (userId, passwordData) => {
    try {
      const response = await axiosInstance.put(`/user/update/password/${userId}`, passwordData);
      return response.data;
    } catch (error) {
        throw error;
    }
};

export default {
    fetchProfile,
    updateProfile,
    updatePassword
};
