import axios from 'axios';

const API_URL = 'http://localhost:3000/api/spare-parts';

export const getSpareParts = async () => {
  const response = await axios.get(API_URL);
  return response.data;
};

export const getSparePartByName = async (Name) => {
  const response = await axios.get(`${API_URL}/${Name}`);
  return response.data;
};

export const createSparePart = async (sparePart) => {
  const response = await axios.post(API_URL, sparePart);
  return response.data;
};

export const updateSparePart = async (Name, sparePart) => {
  const response = await axios.put(`${API_URL}/${Name}`, sparePart);
  return response.data;
};

export const deleteSparePart = async (Name) => {
  const response = await axios.delete(`${API_URL}/${Name}`);
  return response.data;
};