diff --git a/src/app/dashboard/settings/platform/page.tsx b/src/app/dashboard/settings/platform/page.tsx new file mode 100644 index 0000000..bc3be97 --- /dev/null +++ b/src/app/dashboard/settings/platform/page.tsx @@ -0,0 +1,123 @@ +'use client'; + +import { useState } from 'react'; +import { useQuery } from '@tanstack/react-query'; +import Link from 'next/link'; +import { apiFetch } from '../../../../lib/api'; +import { useSession } from '../../../../components/session-provider'; + +interface AuditEvent { id: string; action: string; userId: string | null; createdAt: string; metadata: Record | null; } +interface Member { id: string; userId: string; role: string; createdAt: string; } + +export default function SettingsPlatformPage() { + const { activeTenant } = useSession(); + const tenantId = activeTenant?.tenantId ?? ''; + const [dangerOpen, setDangerOpen] = useState(false); + + const { data: members = [] } = useQuery({ queryKey: ['plat-members', tenantId], queryFn: () => apiFetch('/v1/workspace/members', { tenantId }), enabled: Boolean(tenantId), staleTime: 120_000 }); + const { data: audit = [] } = useQuery({ queryKey: ['plat-audit', tenantId], queryFn: () => apiFetch('/v1/audit-log?limit=50', { tenantId }), enabled: Boolean(tenantId), staleTime: 60_000 }); + + const adminCount = members.filter((m) => m.role === 'admin' || m.role === 'owner').length; + + const PLATFORM_LINKS = [ + { label: 'Utilizatori & Roluri', href: '/dashboard/privacy/delegated', icon: '👥', desc: `${members.length} membri, ${adminCount} admini` }, + { label: 'API & Dezvoltatori', href: '/dashboard/settings/api', icon: '🔑', desc: 'Chei API, endpoint-uri' }, + { label: 'Integrări', href: '/dashboard/integrations', icon: '🔌', desc: 'Conexiuni externe active' }, + { label: 'Export control', href: '/dashboard/data/export-control', icon: '📤', desc: 'Log exporturi date' }, + { label: 'Security Events', href: '/dashboard/privacy/security', icon: '🛡️', desc: 'Autentificări, accesuri' }, + { label: 'Retenție date', href: '/dashboard/privacy/retention', icon: '📁', desc: 'Politici GDPR' }, + ]; + + return ( +
+
+

Administrare platformă

+

Configurare avansată CEO OS — acces, integrări, GDPR, date.

+
+ + {/* Overview */} +
+
+

{members.length}

+

membri workspace

+
+
+

{adminCount}

+

administratori

+
+
+

{audit.length}

+

evenimente recente

+
+
+ + {/* Navigation links */} +
+ {PLATFORM_LINKS.map((link) => ( + + {link.icon} +
+

{link.label}

+

{link.desc}

+
+ + ))} +
+ + {/* Recent audit */} + {audit.length > 0 && ( +
+

Activitate recentă platformă

+
+ {audit.slice(0, 20).map((ev) => ( +
+ + {new Date(ev.createdAt).toLocaleTimeString('ro-RO', { hour: '2-digit', minute: '2-digit' })} + + {ev.action} +
+ ))} +
+ + Vezi toate evenimentele → + +
+ )} + + {/* Danger zone */} +
+ + {dangerOpen && ( +
+

+ Acțiunile din această zonă sunt ireversibile sau pot afecta datele platformei. + Contactează support înainte de a proceda. +

+ {[ + { label: 'Exportă toate datele (GDPR Article 20)', desc: 'Descarcă toate datele workspace-ului în format JSON', action: 'export' }, + { label: 'Resetează setările workspace', desc: 'Revine la configurația implicită (nu șterge date)', action: 'reset-settings' }, + { label: 'Șterge workspace-ul', desc: 'Șterge definitiv toate datele — IREVERSIBIL', action: 'delete', danger: true }, + ].map((op) => ( +
+
+

{op.label}

+

{op.desc}

+
+ +
+ ))} +

* Butoanele sunt dezactivate — funcționalitate în dezvoltare

+
+ )} +
+
+ ); +}