Aplicación para llevar a cabo el stock de la fábrica
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

96 lines
1.8 KiB

import axios from "axios";
const API = process.env.REACT_APP_API;
//get all components
export const getComponents = async () => {
console.log(API);
const res = await axios.get(
`${API}/api/inventory/components/get`
);
if (res.status === 200) {
return res.data;
} else {
return;
}
};
// add component
export const addComponent = async (formData) => {
const res = await axios({
method: "post",
url: `${API}/api/inventory/components/add`,
data: formData,
headers: {
"Content-Type": "multipart/form-data",
},
});
if (res.status === 200) {
return res.data;
} else {
return;
}
};
// get component by Id
export const getComponentsByIds = async (ids) => {
const res = await axios.post(
`${API}/api/inventory/components/getids`,
{ ids }
);
if (res.status === 200) {
return res.data;
} else {
return;
}
};
export const deleteComponent = async (id) => {
const res = await axios.delete(
`${API}/api/inventory/components/delete/${id}`
);
if (res.status === 200) {
return res.data;
} else {
return;
}
};
// edit component by Id
export const editComponentById = async (id, formData) => {
const res = await axios({
method: "put",
url: `${API}/api/inventory/components/editdata/${id}`,
data: formData,
headers: {
"Content-Type": "multipart/form-data",
},
});
if (res.status === 200) {
return res.data;
} else {
return;
}
};
// send csv file to server
export const sendCsvFile = async (formData) => {
const res = await axios({
method: "post",
url: `${API}/api/inventory/components/csv`,
data: formData,
headers: {
"Content-Type": "multipart/form-data",
},
});
if (res.status === 200) {
return res.data;
} else {
return;
}
};