added add-product page/form

This commit is contained in:
2026-05-27 18:32:31 +02:00
parent 4b1443f197
commit 96488a3137
4 changed files with 313 additions and 2 deletions
+32
View File
@@ -111,3 +111,35 @@ export const getStorages = async () => {
return response.data;
}
};
export const createProduct = async (values: ProductFormValues) => {
const payload = {
name: values.name,
description: values.description,
price: values.price,
amount: values.amount,
storage_location: values.storage_location_uuid,
expiry_date: values.expiry_date || null,
bottling_date: values.bottling_date || null,
};
const result = await fetch(`${API_BASE}/products/new-product`, {
method: "POST",
body: JSON.stringify(payload),
headers: {
Authorization: `Bearer ${Cookies.get("token") || ""}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});
const response = await result.json();
if (response.code === "ep001") {
return { success: false, code: response.code };
}
if (response.code === "sp001") {
return response.data;
}
};