"use client"; import React, { useState, useEffect } from "react"; import { Moon, Sun } from "lucide-react"; import { WeatherInfo, UserInfo, CompanyInfo } from "./types"; interface DashboardHeaderProps { theme: "dark" | "light"; weather: WeatherInfo; user: UserInfo; company: CompanyInfo; onThemeToggle: () => void; onUserClick: () => void; } export function DashboardHeader({ theme, weather, user, company, onThemeToggle, onUserClick, }: DashboardHeaderProps) { const [mounted, setMounted] = useState(false); const [currentTime, setCurrentTime] = useState(new Date()); useEffect(() => { setMounted(true); const timer = setInterval(() => { setCurrentTime(new Date()); }, 1000); return () => clearInterval(timer); }, []); const formatTime = (date: Date) => { const hours = String(date.getHours()).padStart(2, "0"); const minutes = String(date.getMinutes()).padStart(2, "0"); const seconds = String(date.getSeconds()).padStart(2, "0"); return `${hours}:${minutes}:${seconds}`; }; const formatDate = (date: Date) => { const year = date.getFullYear(); const month = String(date.getMonth() + 1).padStart(2, "0"); const day = String(date.getDate()).padStart(2, "0"); return `${year}-${month}-${day}`; }; return (
{mounted ? formatTime(currentTime) : "--:--:--"}
{mounted ? formatDate(currentTime) : "----.--.--"}
{/* 테마 토글 */} {/* 날씨 정보 */}
{weather.temp} {weather.description}
{/* 회사 정보 */}
{company.name}
{company.subTitle}
{/* 사용자 배지 */}
); }