add new storage modal and validation for storage creation

This commit is contained in:
2026-05-29 17:33:17 +02:00
parent b0731b22db
commit 8c4f194164
6 changed files with 197 additions and 26 deletions
+27 -1
View File
@@ -1,6 +1,10 @@
import { API_BASE } from "../config/api.config";
import Cookies from "js-cookie";
import type { ProductFormValues, Storage } from "../misc/interfaces";
import type {
NewStorage,
ProductFormValues,
Storage,
} from "../misc/interfaces";
export const getProducts = async () => {
const result = await fetch(`${API_BASE}/products/all-products`, {
@@ -182,3 +186,25 @@ export const formatDate = (value?: string | null) => {
}
return date.toLocaleDateString("de-DE");
};
export const mutateNewStorage = async (values: NewStorage) => {
const result = await fetch(`${API_BASE}/storage/new-storage`, {
method: "POST",
body: JSON.stringify(values),
headers: {
Authorization: `Bearer ${Cookies.get("token") || ""}`,
"Content-Type": "application/json",
Accept: "application/json",
},
});
const response = await result.json();
if (response.code === "es002") {
return { success: false, code: response.code };
}
if (response.code === "ss002") {
return response.data;
}
};