add storage management features including update functionality and storage listing page

This commit is contained in:
2026-05-27 22:20:12 +02:00
parent 96488a3137
commit b0731b22db
10 changed files with 252 additions and 13 deletions
+40 -1
View File
@@ -1,6 +1,6 @@
import { API_BASE } from "../config/api.config";
import Cookies from "js-cookie";
import type { ProductFormValues } from "../misc/interfaces";
import type { ProductFormValues, Storage } from "../misc/interfaces";
export const getProducts = async () => {
const result = await fetch(`${API_BASE}/products/all-products`, {
@@ -143,3 +143,42 @@ export const createProduct = async (values: ProductFormValues) => {
return response.data;
}
};
export const updateStorage = async (
uuid: string,
values: Pick<Storage, "name" | "description">,
) => {
const result = await fetch(
`${API_BASE}/storage/update-storage?storageUUID=${uuid}`,
{
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 === "ep001") {
return { success: false, code: response.code };
}
if (response.code === "sp001") {
return response.data;
}
};
export const formatDate = (value?: string | null) => {
if (!value) {
return "-";
}
const date = new Date(value);
if (Number.isNaN(date.getTime())) {
return "-";
}
return date.toLocaleDateString("de-DE");
};