// [REQ T5] Obsługa zapytań API – CRUD rezerwacji przez Axios
// [REQ D7] React Query – te funkcje są queryFn/mutationFn w custom hookach
import axios from 'axios';
import { API_URL } from '../config';

export const createReservation = (data) =>
  axios.post(`${API_URL}/reservations`, data).then((res) => res.data);

export const getAllReservations = () =>
  axios.get(`${API_URL}/reservations`).then((res) => res.data);

export const getReservationsBySlot = (serviceId, date) =>
  axios.get(`${API_URL}/reservations`, { params: { serviceId, date } }).then((res) => res.data);

export const getUserReservations = (userId) =>
  axios.get(`${API_URL}/reservations`, { params: { userId } }).then((res) => res.data);

export const updateReservation = (id, patch) =>
  axios.patch(`${API_URL}/reservations/${id}`, patch).then((res) => res.data);

export const deleteReservation = (id) =>
  axios.delete(`${API_URL}/reservations/${id}`).then((res) => res.data);
