Fixed location entry creation failure still results in success message

This commit is contained in:
2025-11-01 16:28:44 +01:00
parent f588c89df9
commit 0035144730
2 changed files with 10 additions and 2 deletions

View File

@@ -82,4 +82,7 @@
<data name="Confirm Delete" xml:space="preserve"> <data name="Confirm Delete" xml:space="preserve">
<value>Löschen bestätigen</value> <value>Löschen bestätigen</value>
</data> </data>
<data name="Entry already exists" xml:space="preserve">
<value>Eintrag mit diesem Namen existiert bereits</value>
</data>
</root> </root>

View File

@@ -327,7 +327,7 @@
const result = await response.json(); const result = await response.json();
if (result) { if (result.success) {
const newLoc = data.Description; const newLoc = data.Description;
const slugifiedLocationID = `${newLoc.Location}-${newLoc.RoomNumber}-${newLoc.Seat}` const slugifiedLocationID = `${newLoc.Location}-${newLoc.RoomNumber}-${newLoc.Seat}`
.toLowerCase() .toLowerCase()
@@ -371,7 +371,12 @@
createForm.reset(); createForm.reset();
showToast('@T["Location created successfully"]', 'success'); showToast('@T["Location created successfully"]', 'success');
} else { } else {
showToast(`${result.reason || '@T["Location creation failed"]'}`, 'danger'); switch (result.errorMessage) {
case "Entry Already Exists":
result.errorMessage = "@T["Entry already exists"]";
break;
}
showToast(`${result.errorMessage || '@T["Location creation failed"]'}`, 'danger');
} }
} catch (error) { } catch (error) {
console.error(error); console.error(error);