import api from './api';
import { Medicine, PharmacyMedicine } from '../types';

export async function searchMedicines(query: string): Promise<Medicine[]> {
  const response = await api.get(`/medicines/search?q=${encodeURIComponent(query)}`);
  return response.data;
}

export async function getMedicine(nregistro: string): Promise<Medicine> {
  const response = await api.get(`/medicines/${nregistro}`);
  return response.data;
}

export async function getMedicinePharmacies(nregistro: string): Promise<PharmacyMedicine[]> {
  const response = await api.get(`/medicines/${nregistro}/pharmacies`);
  return response.data;
}
