const apiUrl = 'https://66b1b4381ca8ad33d4f4d9c0.mockapi.io/api/v1/category'; // Replace with your MockAPI URL

export const getCategories = async () => {
  const response = await fetch(`${apiUrl}`);
  return response.json();
};

export const getCategoryById = async (id) => {
  const response = await fetch(`${apiUrl}/${id}`);
  return response.json();
};

export const createCategory = async (category) => {
  await fetch(`${apiUrl}`, {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(category),
  });
};

export const updateCategory = async (id, category) => {
  await fetch(`${apiUrl}/${id}`, {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(category),
  });
};

export const deleteCategory = async (id) => {
  await fetch(`${apiUrl}/${id}`, {
    method: 'DELETE',
  });
};
