import axios from 'axios';

const API_URL = '/api';

// Auth API
export const authAPI = {
  login: (credentials) => axios.post(`${API_URL}/auth/login`, credentials),
  register: (userData) => axios.post(`${API_URL}/auth/register`, userData),
  getMe: () => axios.get(`${API_URL}/auth/me`)
};

// Patients API
export const patientsAPI = {
  getAll: () => axios.get(`${API_URL}/patients`),
  getById: (id) => axios.get(`${API_URL}/patients/${id}`),
  create: (data) => axios.post(`${API_URL}/patients`, data),
  update: (id, data) => axios.put(`${API_URL}/patients/${id}`, data),
  delete: (id) => axios.delete(`${API_URL}/patients/${id}`),
  search: (query) => axios.get(`${API_URL}/patients/search/${query}`)
};

// Doctors API
export const doctorsAPI = {
  getAll: () => axios.get(`${API_URL}/doctors`),
  getById: (id) => axios.get(`${API_URL}/doctors/${id}`),
  create: (data) => axios.post(`${API_URL}/doctors`, data),
  update: (id, data) => axios.put(`${API_URL}/doctors/${id}`, data),
  delete: (id) => axios.delete(`${API_URL}/doctors/${id}`),
  search: (query) => axios.get(`${API_URL}/doctors/search/${query}`)
};

// Appointments API
export const appointmentsAPI = {
  getAll: () => axios.get(`${API_URL}/appointments`),
  getById: (id) => axios.get(`${API_URL}/appointments/${id}`),
  create: (data) => axios.post(`${API_URL}/appointments`, data),
  update: (id, data) => axios.put(`${API_URL}/appointments/${id}`, data),
  delete: (id) => axios.delete(`${API_URL}/appointments/${id}`),
  getByStatus: (status) => axios.get(`${API_URL}/appointments/filter/${status}`)
};

// Reports API
export const reportsAPI = {
  getOverview: () => axios.get(`${API_URL}/reports/overview`),
  getPatientsReport: () => axios.get(`${API_URL}/reports/patients`),
  getDoctorsReport: () => axios.get(`${API_URL}/reports/doctors`),
  getAppointmentsReport: () => axios.get(`${API_URL}/reports/appointments`)
};
