import { Box, Center, Divider, Group, Modal, Stack, Text } from '@mantine/core'; import { modalClasses } from 'styles'; import SmallOutlookCard from './SmallOutlookCard'; import SmallWeatherCard from './SmallWeatherCard'; import { useCommonHooks, useWeatherAPI } from 'hooks'; import { useEffect, useState } from 'react'; import HourlyCard from './HourlyCard'; export function WeatherModal({ current, outlook, closeWeatherModal, weatherModalOpened, }: any) { const { theme, isMobile, setProviderLabel, setSearchValue, setProviderURL, currentUser, currentLocation, } = useCommonHooks(); const { data: hourly } = useWeatherAPI({ endpoint: 'hourly', office: currentLocation.office, x: currentLocation.x, y: currentLocation.y, }); const [hourlyForecast, setHourlyForecast] = useState([]); const [sunset, setSunset] = useState(100); useEffect(() => { if (hourly) { setHourlyForecast(hourly.properties.periods.slice(1, 13)); } }, [hourly]); useEffect(() => { if (hourlyForecast) { hourlyForecast[0]?.isDaytime ? setSunset( (hourlyForecast.findIndex((item: any) => item.isDaytime === false) / 12) * 100, ) : setSunset( (hourlyForecast.findIndex((item: any) => item.isDaytime === true) / 12) * 100, ); } }, [hourlyForecast]); return ( { closeWeatherModal(); setProviderLabel('Google Search'); setSearchValue(''); setProviderURL('https://www.google.com/search?q='); }} style={{ '--color-text-pri': theme.primaryColor, '--color-text-acc': theme.accentColor, '--color-background': theme.backgroundColor, '--color-border': theme.borderColor, '--color-search-background': theme.searchColor, '--image-background': `url(${theme.backgroundImage})`, }} closeOnEscape closeOnClickOutside > Weather Forecast for{' '} {currentUser.physicalAddress}

Currently

{outlook.map((o: any) => (

{o.name}

))}
0 && hourlyForecast[0].isDaytime ? `linear-gradient(90deg, rgba(245, 225, 171, 0.85) ${sunset - 5}%, rgba(35, 28, 42, 0.85) ${sunset + 5}%)` : `linear-gradient(90deg, rgba(35, 28, 42, 0.85)${sunset - 5}%, rgba(245, 225, 171, 0.85)${sunset + 5}%)`, padding: '.5rem', borderRadius: '.5rem', }} > {hourlyForecast.length > 0 && hourlyForecast.map((h: any) => { return ; })}
); }