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

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

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

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

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

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