"use client"; import { main_font } from "@/public/fonts/font_index"; import MagnetLines from "../magnet-lines"; import { Card } from "../ui/card"; type DashboardWelcomeProps = { name?: string | null; disableMagnetlines?: boolean; }; const capitalizeFirstLetter = (value: string) => value.length > 0 ? value[0]?.toUpperCase() + value.slice(1) : value; const formatCurrentDate = (date = new Date()) => { const formatted = new Intl.DateTimeFormat("pt-BR", { weekday: "long", day: "numeric", month: "long", year: "numeric", timeZone: "America/Sao_Paulo", }).format(date); return capitalizeFirstLetter(formatted); }; const getGreeting = () => { const now = new Date(); // Get hour in Brasilia timezone const brasiliaHour = new Intl.DateTimeFormat("pt-BR", { hour: "numeric", hour12: false, timeZone: "America/Sao_Paulo", }).format(now); const hour = parseInt(brasiliaHour, 10); if (hour >= 5 && hour < 12) { return "Bom dia"; } else if (hour >= 12 && hour < 18) { return "Boa tarde"; } else { return "Boa noite"; } }; export function DashboardWelcome({ name, disableMagnetlines = false, }: DashboardWelcomeProps) { const displayName = name && name.trim().length > 0 ? name : "Administrador"; const formattedDate = formatCurrentDate(); const greeting = getGreeting(); return (

{greeting}, {displayName}!

{formattedDate}

); }