From 30003edea8d01346cca9087bc32c760718024605 Mon Sep 17 00:00:00 2001 From: madarsbiss Date: Tue, 27 Jul 2021 16:25:09 +0300 Subject: [PATCH] update ui --- pages/index.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/pages/index.js b/pages/index.js index b001000..3b1aaa5 100644 --- a/pages/index.js +++ b/pages/index.js @@ -6,7 +6,6 @@ export default function Home() { const [input, setInput] = useState("mumbai"); const [systemUsed, setSystemUsed] = useState("metric"); const [weatherData, setWeatherData] = useState(); - // const [isLoading, setIsLoading] = useState(true); const getData = async () => { const res = await fetch("/api/data", { @@ -15,6 +14,7 @@ export default function Home() { body: JSON.stringify({ input }), }); const data = await res.json(); + // console.log(data); setWeatherData({ ...data }); setInput(""); @@ -83,13 +83,10 @@ export default function Home() { } }; - const changeSystem = () => { - if (systemUsed == "metric") { - setSystemUsed("imperial"); - } else { - setSystemUsed("metric"); - } - }; + const changeSystem = () => + systemUsed == "metric" + ? setSystemUsed("imperial") + : setSystemUsed("metric"); var weekday = [ "Sunday", @@ -314,6 +311,6 @@ export default function Home() { ) : ( -

Loading results

+

Loading data...

); }