"use client"; import Link from "next/link"; import * as Icons from "lucide-react"; import { getAllModules } from "@/core/module-registry"; import { useFeatureFlag } from "@/core/feature-flags"; import { useI18n } from "@/core/i18n"; import { EXTERNAL_TOOLS } from "@/config/external-tools"; import { Card, CardHeader, CardTitle, CardDescription, CardContent, } from "@/shared/components/ui/card"; import { Badge } from "@/shared/components/ui/badge"; import { useDashboardData } from "@/modules/dashboard/hooks/use-dashboard-data"; function DynamicIcon({ name, className, }: { name: string; className?: string; }) { const pascalName = name.replace(/(^|-)([a-z])/g, (_, _p, c: string) => c.toUpperCase(), ); const IconComponent = ( Icons as unknown as Record< string, React.ComponentType<{ className?: string }> > )[pascalName]; if (!IconComponent) return ; return ; } function ModuleCard({ module, }: { module: { id: string; name: string; description: string; icon: string; route: string; featureFlag: string; }; }) { const enabled = useFeatureFlag(module.featureFlag); if (!enabled) return null; return (
{module.name} {module.description}
); } const RELATIVE_LABELS: Intl.RelativeTimeFormatUnit[] = [ "year", "month", "week", "day", "hour", "minute", "second", ]; const RELATIVE_MS = [ 31536000000, 2592000000, 604800000, 86400000, 3600000, 60000, 1000, ]; function relativeTime(isoString: string): string { const diff = new Date(isoString).getTime() - Date.now(); const rtf = new Intl.RelativeTimeFormat("ro", { numeric: "auto" }); for (let i = 0; i < RELATIVE_MS.length; i++) { const ms = RELATIVE_MS[i]; if (ms === undefined) continue; const absMs = RELATIVE_LABELS[i]; if (absMs === undefined) continue; if (Math.abs(diff) >= ms || i === RELATIVE_MS.length - 1) { return rtf.format(Math.round(diff / ms), absMs); } } return "acum"; } const MODULE_ICONS: Record = { registratura: "BookOpen", "address-book": "Users", "it-inventory": "Monitor", "password-vault": "KeyRound", "digital-signatures": "PenLine", "word-templates": "FileText", "tag-manager": "Tag", "prompt-generator": "Wand2", }; const CATEGORY_LABELS: Record = { dev: "Dezvoltare", tools: "Instrumente", monitoring: "Monitorizare", security: "Securitate", }; export default function DashboardPage() { const { t } = useI18n(); const modules = getAllModules(); const { activity, kpis } = useDashboardData(); const toolCategories = Object.keys(CATEGORY_LABELS).filter((cat) => EXTERNAL_TOOLS.some((tool) => tool.category === cat), ); return (

{t("dashboard.welcome")}

{t("dashboard.subtitle")}

{/* KPI panels */}

Indicatori cheie

Registratură — intrări săptămâna aceasta

{kpis.registraturaThisWeek}

Dosare deschise

{kpis.registraturaOpen}

Termene legale săptămâna aceasta

{kpis.deadlinesThisWeek}

Termene depășite

0 ? "text-destructive" : ""}`} > {kpis.overdueDeadlines}

Contacte noi luna aceasta

{kpis.contactsThisMonth}

Echipamente IT active

{kpis.inventoryActive}

{/* Activity feed */} {activity.length > 0 && (

Activitate recentă

{activity.map((item) => (

{item.label} {item.action}

{item.moduleLabel}

{relativeTime(item.timestamp)}
))}
)} {/* Modules grid */}

{t("dashboard.modules")}

{modules.map((m) => ( ))}
{/* External tools */}

Instrumente externe

{toolCategories.map((cat) => (
{CATEGORY_LABELS[cat]}
{EXTERNAL_TOOLS.filter((tool) => tool.category === cat).map( (tool) => { const cardContent = (

{tool.name}

{tool.description}

); if (!tool.url) return cardContent; return ( {cardContent} ); }, )}
))}
); }