import { Grid, Group, Stack, Text, ThemeIcon } from '@mantine/core'; import { useCommonHooks } from 'hooks'; import { useSunStateAPI } from 'hooks/useAPI'; import { useEffect, useState } from 'react'; import { FaLongArrowAltDown, FaLongArrowAltUp, FaWind } from 'react-icons/fa'; import { WiBarometer, WiHumidity, WiSunrise, WiSunset } from 'react-icons/wi'; import WeatherIcon from './WeatherIcon'; export default function CurrentWeather({ current }: any) { const { currentLocation, isMobile } = useCommonHooks(); const { data: sunStateData } = useSunStateAPI({ lat: currentLocation.lat, lon: currentLocation.lon, }); const [sunStates, setSunStates] = useState([]); useEffect(() => { if (sunStateData) { setSunStates( sunStateData.results.map((item: any) => { return { date: item.date, sunrise: item.sunrise, sunset: item.sunset, }; }), ); } }, [sunStateData]); return ( <> {current ? ( Current Weather {current.temperature}°F {current.textDescription} Feels like {current.heatIndex ?? current.windChill ?? current.temperature} °F {current.highTemp}°F {current.lowTemp}°F {sunStates[0]?.sunrise} {sunStates[0]?.sunset} Humidity {current.humidity}% Wind {current.windSpeed}mph Pressure {current.pressure} in ) : ( <> )} ); }