From 6297c58717da60817f9755d636af6c923d681ecb Mon Sep 17 00:00:00 2001 From: Mark Date: Mon, 10 Jun 2024 23:22:52 +0200 Subject: [PATCH] close wizard after action, addlight "preventDefault" error --- src/Pages/Bridge.jsx | 8 ++++++++ src/Pages/Lights.jsx | 2 +- src/components/AddLight/AddLight.jsx | 7 +++---- src/components/NotificationCenter/NotificationCenter.jsx | 1 + 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Pages/Bridge.jsx b/src/Pages/Bridge.jsx index 1942618..0bfbe37 100644 --- a/src/Pages/Bridge.jsx +++ b/src/Pages/Bridge.jsx @@ -153,6 +153,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); + closeWizard() }; const backupConfig = () => { @@ -165,6 +166,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); + closeWizard() }; const downloadConfig = () => { @@ -178,6 +180,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); + closeWizard() }; const Restart = () => { @@ -270,6 +273,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); + closeWizard() }; const restoreAlert = () => { @@ -299,6 +303,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); + closeWizard() }; const debugOptions = () => { @@ -340,6 +345,7 @@ const Bridge = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); + closeWizard() }; const downloadLog = () => { @@ -353,6 +359,8 @@ const Bridge = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); + + closeWizard() }; let options = timezones.map(function (timezone) { diff --git a/src/Pages/Lights.jsx b/src/Pages/Lights.jsx index e2d4b12..0ec91b3 100644 --- a/src/Pages/Lights.jsx +++ b/src/Pages/Lights.jsx @@ -141,7 +141,7 @@ export default function Lights({ HOST_IP, API_KEY }) { closeWizard={closeWizard} headline="Add Light" > - + ); diff --git a/src/components/AddLight/AddLight.jsx b/src/components/AddLight/AddLight.jsx index db0d6a3..a3a16b6 100644 --- a/src/components/AddLight/AddLight.jsx +++ b/src/components/AddLight/AddLight.jsx @@ -7,7 +7,7 @@ import GenericButton from "../GenericButton/GenericButton"; import GenericText from "../GenericText/GenericText"; import SelectMenu from "../SelectMenu/SelectMenu"; -const AddLight = ({ HOST_IP, API_KEY }) => { +const AddLight = ({ HOST_IP, API_KEY, closeWizard }) => { const [lightData, setLightData] = useState({ protocol: "auto", }); @@ -19,8 +19,7 @@ const AddLight = ({ HOST_IP, API_KEY }) => { }); }; - const handleForm = (evt) => { - evt.preventDefault(); + const handleForm = () => { const { protocol: lightproto, ip: lightip, ...rest } = lightData; const formattedData = { protocol: lightproto, @@ -36,7 +35,7 @@ const AddLight = ({ HOST_IP, API_KEY }) => { console.error(error); toast.error(`Error occurred: ${error.message}`); }); - + closeWizard() }; const protocols = [ diff --git a/src/components/NotificationCenter/NotificationCenter.jsx b/src/components/NotificationCenter/NotificationCenter.jsx index 1a9fb88..f3ad924 100644 --- a/src/components/NotificationCenter/NotificationCenter.jsx +++ b/src/components/NotificationCenter/NotificationCenter.jsx @@ -65,6 +65,7 @@ const NotificationCenter = ({HOST_IP, API_KEY, updating, notifications }) => { toast.error(`Error occurred: ${error.message}`); }); } + closeWizard() }; const getValueState = (state) => {