"use client"; import { motion } from "framer-motion"; import { Droplets, Wind } from "lucide-react"; function getWeatherEmoji(code: string): string { const c = parseInt(code); if (c === 113) return "☀️"; if (c === 116) return "⛅"; if (c === 119 || c === 122) return "☁️"; if (c >= 176 && c <= 182) return "🌦️"; if (c >= 185 && c <= 200) return "🌧️"; if (c >= 200 && c <= 210) return "⛈️"; if (c >= 210 && c <= 260) return "❄️"; if (c >= 260 && c <= 300) return "🌨️"; if (c >= 300 && c <= 400) return "🌧️"; return "🌤️"; } function formatDate(dateStr: string): string { const d = new Date(dateStr); return d.toLocaleDateString("ru-RU", { weekday: "short", day: "numeric" }); } interface Props { weather: any; } export default function WeatherCard({ weather }: Props) { if (!weather) { return (
Загрузка погоды...
); } return (
🌍 Санкт-Петербург
{getWeatherEmoji(weather.weatherCode)}
{weather.temp}°C
{weather.desc}
{weather.humidity}%
{weather.windSpeed} км/ч
{/* Forecast */}
{(weather.forecast || []).map((day: any, i: number) => (
{i === 0 ? "Сегодня" : formatDate(day.date)}
{getWeatherEmoji(day.weatherCode)}
{day.maxTemp}° / {day.minTemp}°
))}
); }