import axiosInstance from '@/utills/axiosInstance';

export async function getUserProfile(id: number): Promise<any> {
  return await axiosInstance.get(`/api/v1/users/${id}`);
}

export const changePassword = async(id: number, data: any): Promise<any> => {
  const response = await axiosInstance.post(`/api/v1/auth/change-password/${id}`, data);
  if (response.status === 200) {
    return response.data;
  } else {
    throw new Error('Failed to update password!');
  }
};

export const changePasswordByAdmin = async(id: number, data: any): Promise<any> => {
  const response = await axiosInstance.post(`/api/v1/auth/change-password-by-admin/${id}`, data);
  if (response.status === 200) {
    return response.data;
  } else {
    throw new Error('Failed to update password!');
  }
};

export const uploadProfilePhoto = async(userId: number, formData: FormData): Promise<any> => {
  const response = await axiosInstance.post('/api/v1/upload/profile-photo', formData, {
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  });
  if (response.status === 200) {
    return response.data;
  } else {
    throw new Error('Failed to upload profile photo');
  }
};

