init
This commit is contained in:
42
frontend/app/dashboard/vorlagenFlaechendruck/action.ts
Normal file
42
frontend/app/dashboard/vorlagenFlaechendruck/action.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
"use server";
|
||||
|
||||
const apiUrl = process.env.NEXT_SERVER_API_URL;
|
||||
|
||||
export async function getTableData() {
|
||||
try {
|
||||
const res = await fetch(
|
||||
`${apiUrl}/vorlageFlaechendruck/getAllFlaechendruckVorlagen`
|
||||
);
|
||||
if (!res.ok) {
|
||||
console.error("Response status:", res.status);
|
||||
}
|
||||
|
||||
const data: {
|
||||
id: number;
|
||||
product_type: string;
|
||||
height: number;
|
||||
width: number;
|
||||
printer: string;
|
||||
coordinates: {
|
||||
x: number;
|
||||
y: number;
|
||||
rotation: number;
|
||||
}[];
|
||||
}[] = await res.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error fetching vorlagen:", error);
|
||||
throw new Error("An error occurred while fetching vorlagen.");
|
||||
}
|
||||
}
|
||||
export async function deleteVorlageFlaechendruck(id: number) {
|
||||
const res = await fetch(`${apiUrl}/vorlageFlaechendruck/delete/${id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
|
||||
if (!res.ok) {
|
||||
throw new Error("Failed to delete item");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
Reference in New Issue
Block a user