From c329ab90fcb250068a82ab1bf834c563fd9d58f9 Mon Sep 17 00:00:00 2001 From: ISA Date: Sat, 9 Nov 2024 12:20:09 +0100 Subject: [PATCH] handleClearDatabase anpassung mit volle URL-Adresse --- components/modales/SettingsModal.jsx | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/components/modales/SettingsModal.jsx b/components/modales/SettingsModal.jsx index 1f73ccd..3568796 100644 --- a/components/modales/SettingsModal.jsx +++ b/components/modales/SettingsModal.jsx @@ -77,8 +77,30 @@ function SettingModal({ showModal, onClose }) { ); if (!confirmClear) return; - const clearDbUrl = `CPL?${currentPath}&DEDB=1`; - await fetch(clearDbUrl); // Datenbank wird geleert und Seite neu geladen + // Get the current path and ensure it ends with ".html" + let currentPath = window.location.pathname; + if (!currentPath.endsWith(".html")) { + currentPath += ".html"; + } + + // Full URL with host, current path, and clear database command + const url = `${window.location.origin}/CPL?${currentPath}&DEDB=1`; + + // Log the full URL to the console for debugging + console.log(url); + + // Send the clear database command to the server using fetch and GET method + try { + const response = await fetch(url, { method: "GET" }); + if (response.ok) { + alert("Datenbank erfolgreich geleert!"); + } else { + alert("Fehler beim Leeren der Datenbank!"); + } + } catch (error) { + console.error("Fehler:", error); + alert("Fehler beim Leeren der Datenbank!"); + } }; const handleSubmit = () => {