From 675843b3b312d52cbdc4529c5a94143b57bc7da1 Mon Sep 17 00:00:00 2001 From: ISA Date: Sat, 9 Nov 2024 12:23:12 +0100 Subject: [PATCH] =?UTF-8?q?handleSubmit=20=20vollst=C3=A4ndige=20URL=20mit?= =?UTF-8?q?=20Host=20und=20dem=20aktuellen=20Pfad=20(pathname)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/modales/SettingsModal.jsx | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/components/modales/SettingsModal.jsx b/components/modales/SettingsModal.jsx index 3568796..1c4f7b9 100644 --- a/components/modales/SettingsModal.jsx +++ b/components/modales/SettingsModal.jsx @@ -137,30 +137,40 @@ function SettingModal({ showModal, onClose }) { // Falls Änderungen vorhanden sind, sende die neuen Daten if (Object.keys(changes).length > 0) { - let url = `CPL?${currentPath}`; + // 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 all change parameters + let url = `${window.location.origin}/CPL?${currentPath}`; Object.keys(changes).forEach((paramKey) => { url += `&${paramKey}=${encodeURIComponent(changes[paramKey])}`; }); + // Log the full URL to the console for debugging + console.log(url); + + // Send the URL with changes to the server fetch(url, { method: "GET" }) .then((response) => { if (response.ok) { alert("Daten erfolgreich gesendet!"); } else { - alert("Daten erfolgreich gesendet!"); - //alert("Fehler beim Senden der Daten!"); weil wird sofort ausgefüht und bekommt kein Antwort + alert("Fehler beim Senden der Daten!"); } }) .catch((error) => { console.error("Fehler:", error); - //alert("Fehler beim Senden der Daten!"); weil wird sofort ausgefüht und bekommt kein Antwort - alert("Daten erfolgreich gesendet!"); + alert("Fehler beim Senden der Daten!"); }); } else { alert("Keine Änderungen vorgenommen."); } }; + const handleSetDateTime = () => { const currentDate = new Date();