import { Center, Group, Skeleton, Stack, Text, Title } from '@mantine/core'; import { IconArrowDownRight, IconArrowUpRight } from '@tabler/icons'; import { WeatherIcon } from './WeatherIcon'; import { BaseTileProps } from '../type'; import { useWeatherForCity } from './useWeatherForCity'; import { WeatherIntegrationType } from '../../../../types/integration'; import { HomarrCardWrapper } from '../HomarrCardWrapper'; import { IntegrationsMenu } from '../Integrations/IntegrationsMenu'; interface WeatherTileProps extends BaseTileProps { module: WeatherIntegrationType | undefined; } export const WeatherTile = ({ className, module }: WeatherTileProps) => { const { data: weather, isLoading, isError, } = useWeatherForCity(module?.properties.location ?? 'Paris'); if (isLoading) { return ( ); } if (isError) { return (
An error occured
); } return (
{getPerferedUnit( weather!.current_weather.temperature, module?.properties.isFahrenheit )}
{getPerferedUnit( weather!.daily.temperature_2m_max[0], module?.properties.isFahrenheit )}
{getPerferedUnit( weather!.daily.temperature_2m_min[0], module?.properties.isFahrenheit )}
); }; const getPerferedUnit = (value: number, isFahrenheit = false): string => isFahrenheit ? `${(value * (9 / 5) + 32).toFixed(1)}°F` : `${value.toFixed(1)}°C`;