diff --git a/intelligest-ui/src/app/page.js b/intelligest-ui/src/app/page.js index d3e323bbb..07737ac1c 100644 --- a/intelligest-ui/src/app/page.js +++ b/intelligest-ui/src/app/page.js @@ -21,6 +21,8 @@ import Icon from '@mdi/react'; import { mdiAccount, mdiAccountMultiple, mdiHomeAssistant } from '@mdi/js'; import "react-toastify/dist/ReactToastify.css"; + + function Home() { const [data, setData] = useState({}); const [showWeatherPopup, setShowWeatherPopup] = useState(false); @@ -29,9 +31,18 @@ function Home() { const [showEntityChoices, setShowEntityChoices] = useState(false); const [showConfirmation, setShowConfirmation] = useState(false); //const [weather, setWeather] = useState(null); + + + const [lightState, setLightState] = useState("Inactive"); + const [lockState, setLockState] = useState("Inactive"); + const [thermostatState, setThermostatState] = useState("Inactive"); + const [tvState, setTvState] = useState("Inactive"); + const [showNewsPopup, setShowNewsPopup] = useState(false); const [newsData, setNewsData] = useState([]); + const [weatherData, setWeatherData] = useState(null); + const handleClick = (buttonName) => { console.log(buttonName); }; @@ -139,6 +150,26 @@ function Home() { }); }; + }, []); + + //Capture the change of states in devices. + useEffect(() => { + switch(data.deviceChoice){ + case 'Light': + (data.deviceStatus == 'on') && (setLightState("Active")); + case 'Lock': + (data.deviceStatus == 'on') && (setLockState("Active")); + case 'Thermostat': + (data.deviceStatus == 'on') && (setThermostatState("Active")); + case 'TV': + (data.deviceStatus == 'on') && (setTvState("Active")); + default: + console.log("Error"); + } + },[data.lastestGesture]); + + + fetchWeather(); }, [query, units]); @@ -282,6 +313,7 @@ function Home() { } }; + const handleLockButtonClick = async () => { try { const response = await fetch("http://127.0.0.1:5000/get_entities", { @@ -311,6 +343,7 @@ function Home() { } }; + return (
@@ -337,9 +370,30 @@ function Home() { Entity Choice: {data.entityChoice}
+ + +
Devices + +
+ +
+ +