"use client"; import { useState, useCallback, useEffect } from "react"; import { motion, AnimatePresence } from "framer-motion"; import TopBar from "@/components/TopBar"; import BottomNav from "@/components/BottomNav"; import LightCard from "@/components/cards/LightCard"; import TemperatureCard from "@/components/cards/TemperatureCard"; import AirPurifierCard from "@/components/cards/AirPurifierCard"; import TasksCard from "@/components/cards/TasksCard"; import WeatherCard from "@/components/cards/WeatherCard"; import SavingsCard from "@/components/cards/SavingsCard"; import WeatherSavingsCard from "@/components/cards/WeatherSavingsCard"; import { useHA, useWeather, useTasks, useSavings } from "@/hooks/useHA"; // Stagger container variants const containerVariants = { hidden: {}, visible: { transition: { staggerChildren: 0.07 } }, }; const cardVariants = { hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0, transition: { duration: 0.35 } }, }; export default function Home() { const [isDark, setIsDark] = useState(true); const [activeTab, setActiveTab] = useState("home"); const { data: haData, loading: haLoading, refresh: refreshHA } = useHA(15000); const weather = useWeather(); const { tasks, refresh: refreshTasks } = useTasks(); const { savings } = useSavings(); // Apply theme to html element useEffect(() => { const html = document.documentElement; if (isDark) { html.classList.add("dark"); html.classList.remove("light"); document.body.classList.remove("light"); } else { html.classList.remove("dark"); html.classList.add("light"); document.body.classList.add("light"); } }, [isDark]); const states = haData?.states || {}; const isDemo = haData?.demo || false; const handleHAUpdate = useCallback(() => { setTimeout(refreshHA, 500); }, [refreshHA]); const livingRoom = states["light.living_room"]; const bedroom = states["light.bedroom"]; const thermostat = states["climate.thermostat"]; const airPurifier = states["fan.air_purifier"]; return (
{/* Ambient orbs */}
{/* Main layout */}
{/* Top bar */} setIsDark(!isDark)} weather={weather} /> {/* Demo badge */} {isDemo && ( 🔌 Демо режим — HA Token не настроен )} {/* Content area */}
{/* ═══════════════ HOME TAB ═══════════════ */} {activeTab === "home" && ( {/* 3-col grid: Row 1: [Свет] [Климат] [Задачи] Row 2: [Воздух ×2] [Погода+Накопления] */}
{/* Свет Гостиная */} {/* Термостат */} {/* Задачи */} {/* Очиститель воздуха — 2 колонки */} {/* Погода + Накопления — правый нижний */}
)} {/* ═══════════════ DEVICES TAB ═══════════════ */} {activeTab === "devices" && ( )} {/* ═══════════════ TASKS TAB ═══════════════ */} {activeTab === "tasks" && ( )} {/* ═══════════════ SETTINGS TAB ═══════════════ */} {activeTab === "settings" && (
⚙️

Настройки

Добавь HA Token в Coolify для подключения к умному дому

{[ { label: "HA URL", value: "Настроен" }, { label: "HA Token", value: isDemo ? "❌ Не настроен" : "✅ Настроен" }, { label: "Vikunja", value: "✅ Подключён" }, { label: "Pulse API", value: "✅ Подключён" }, ].map((item) => (
{item.label} {item.value}
))}
)}
{/* Bottom nav */}
); }