"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 { useHA, useWeather, useTasks, useSavings } from "@/hooks/useHA"; 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 */}
{activeTab === "home" && ( {/* Row 1 */} {/* Свет Гостиная */} {/* Свет Спальня */} {/* Температура */} {/* Очиститель воздуха */} {/* Row 2 */} {/* Задачи — 2 колонки */}
{/* Погода */} {/* Накопления */}
)} {activeTab === "devices" && (
)} {activeTab === "tasks" && ( )} {activeTab === "settings" && (
⚙️

Настройки

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

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