diff --git a/admin-dashboard.html b/admin-dashboard.html
index 93e8381..1c3e480 100644
--- a/admin-dashboard.html
+++ b/admin-dashboard.html
@@ -2610,14 +2610,21 @@ async function saveApp(event) {
event.preventDefault();
// Get form data
- const formData = new FormData(document.getElementById('appForm'));
+ const form = document.getElementById('appForm');
+ const formData = new FormData(form);
// Get app ID
const appId = document.getElementById('appId').value;
// Get icon class from the selected icon
const iconClass = document.getElementById('appIcon').value;
- formData.append('iconClass', iconClass);
+ formData.set('iconClass', iconClass);
+
+ // Convert FormData to URL-encoded string
+ const urlEncoded = new URLSearchParams();
+ for (const [key, value] of formData.entries()) {
+ urlEncoded.append(key, value);
+ }
// Create request URL
const url = appId ? `/api/apps/${appId}` : '/api/apps';
@@ -2626,26 +2633,29 @@ async function saveApp(event) {
const method = appId ? 'PUT' : 'POST';
// Send request
- fetch(url, {
- method: method,
- body: formData,
- credentials: 'include'
- })
- .then(response => {
+ try {
+ const response = await fetch(url, {
+ method: method,
+ headers: {
+ 'Content-Type': 'application/x-www-form-urlencoded',
+ },
+ body: urlEncoded.toString(),
+ credentials: 'include'
+ });
+
if (!response.ok) {
- throw new Error('Network response was not ok');
+ const errorData = await response.json().catch(() => ({}));
+ throw new Error(errorData.error || 'Network response was not ok');
}
- return response.json();
- })
- .then(data => {
+
+ const data = await response.json();
showNotification('Aplikace byla úspěšně uložena', 'success');
loadApps();
closeAppModal();
- })
- .catch(error => {
+ } catch (error) {
console.error('Error:', error);
- showNotification('Chyba při ukládání aplikace', 'error');
- });
+ showNotification(`Chyba při ukládání aplikace: ${error.message}`, 'error');
+ }
}
// Logout functionality