diff --git a/admin/src/components/AddItemForm.tsx b/admin/src/components/AddItemForm.tsx index 76ec615..5780a94 100644 --- a/admin/src/components/AddItemForm.tsx +++ b/admin/src/components/AddItemForm.tsx @@ -68,8 +68,10 @@ const AddItemForm: React.FC = ({ onClose, alert }) => { alert( "error", "Fehler", - "Der Gegenstand konnte nicht erstellt werden." + res.message || + "Der Gegenstand konnte nicht erstellt werden. (frontend bug)" ); + onClose(); } }} > diff --git a/admin/src/utils/userActions.ts b/admin/src/utils/userActions.ts index d8417e3..38ef767 100644 --- a/admin/src/utils/userActions.ts +++ b/admin/src/utils/userActions.ts @@ -148,7 +148,11 @@ export const createItem = async ( body: JSON.stringify({ item_name, can_borrow_role }), }); if (!response.ok) { - throw new Error("Failed to create item"); + return { + success: false, + message: + "Fehler beim Erstellen des Gegenstands. Der Name des Gegenstandes darf nicht mehrmals vergeben werden.", + }; } return { success: true }; } catch (error) {