From 80b16552e2cc875e82869a6779134e406ee8c157 Mon Sep 17 00:00:00 2001 From: Andrew <74398819+AndrewDTR@users.noreply.github.com> Date: Fri, 18 Oct 2024 19:33:53 -0500 Subject: [PATCH] fix truth table --- src/components/DoorStatus.jsx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/components/DoorStatus.jsx b/src/components/DoorStatus.jsx index dce52d8..561e0b7 100644 --- a/src/components/DoorStatus.jsx +++ b/src/components/DoorStatus.jsx @@ -14,12 +14,10 @@ const DoorStatus = () => { const backDoor = data.find((door) => door.door === "back"); const frontDoor = data.find((door) => door.door === "front"); - if (backDoor?.status === "on" && frontDoor?.status === "on") { - setIsOpen(true); - } else if (backDoor?.status === "off" && frontDoor?.status === "off") { + if (backDoor?.status === "off" || frontDoor?.status === "off") { setIsOpen(false); - } else { - setIsOpen(null); + } else if (backDoor?.status === "on" && frontDoor?.status === "on") { + setIsOpen(true); } } catch (error) { console.error("Error fetching door status:", error); @@ -78,4 +76,4 @@ const DoorStatus = () => { ); }; -export default DoorStatus; +export default DoorStatus; \ No newline at end of file