@umituz/web-dashboard 11.12.0 → 11.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/package.json +17 -1
  2. package/src/domains/activity/activity.css +229 -0
  3. package/src/domains/activity/components/ActivityFeed.test.tsx +61 -0
  4. package/src/domains/activity/components/ActivityFeed.tsx +132 -0
  5. package/src/domains/activity/components/ActivityTimeline.tsx +127 -0
  6. package/src/domains/activity/components/index.ts +2 -0
  7. package/src/domains/activity/index.ts +3 -0
  8. package/src/domains/activity/types.ts +59 -0
  9. package/src/domains/activity/utils.ts +73 -0
  10. package/src/domains/admin/admin.css +187 -0
  11. package/src/domains/admin/components/AdminGate.test.tsx +44 -0
  12. package/src/domains/admin/components/AdminGate.tsx +41 -0
  13. package/src/domains/admin/components/AdminHealthCard.test.tsx +42 -0
  14. package/src/domains/admin/components/AdminHealthCard.tsx +108 -0
  15. package/src/domains/admin/components/AdminOverview.test.tsx +44 -0
  16. package/src/domains/admin/components/AdminOverview.tsx +133 -0
  17. package/src/domains/admin/components/AdminShell.test.tsx +59 -0
  18. package/src/domains/admin/components/AdminShell.tsx +80 -0
  19. package/src/domains/admin/components/AdminUsersTable.test.tsx +79 -0
  20. package/src/domains/admin/components/AdminUsersTable.tsx +239 -0
  21. package/src/domains/admin/components/index.ts +5 -0
  22. package/src/domains/admin/index.ts +2 -0
  23. package/src/domains/admin/types.ts +66 -0
  24. package/src/domains/filters/components/DataToolbar.test.tsx +65 -0
  25. package/src/domains/filters/components/DataToolbar.tsx +119 -0
  26. package/src/domains/filters/components/index.ts +1 -0
  27. package/src/domains/filters/filters.css +128 -0
  28. package/src/domains/filters/index.ts +2 -0
  29. package/src/domains/filters/types.ts +48 -0
  30. package/src/domains/pages/components/DetailPage.test.tsx +96 -0
  31. package/src/domains/pages/components/DetailPage.tsx +227 -0
  32. package/src/domains/pages/components/index.ts +1 -0
  33. package/src/domains/pages/types.ts +60 -0
  34. package/src/domains/stepper/components/Stepper.test.tsx +71 -0
  35. package/src/domains/stepper/components/Stepper.tsx +79 -0
  36. package/src/domains/stepper/components/Wizard.tsx +84 -0
  37. package/src/domains/stepper/components/index.ts +2 -0
  38. package/src/domains/stepper/index.ts +2 -0
  39. package/src/domains/stepper/stepper.css +145 -0
  40. package/src/domains/stepper/types.ts +40 -0
  41. package/src/index.ts +4 -0
@@ -0,0 +1,73 @@
1
+ import type { ActivityGroup, ActivityItem } from './types';
2
+
3
+ export function toDate(timestamp: string | number | Date): Date {
4
+ if (timestamp instanceof Date) return timestamp;
5
+ if (typeof timestamp === 'number') return new Date(timestamp);
6
+ return new Date(timestamp);
7
+ }
8
+
9
+ export function toIsoDayKey(date: Date): string {
10
+ const y = date.getFullYear();
11
+ const m = String(date.getMonth() + 1).padStart(2, '0');
12
+ const d = String(date.getDate()).padStart(2, '0');
13
+ return `${y}-${m}-${d}`;
14
+ }
15
+
16
+ export function formatDayLabel(date: Date, locale = 'en-US'): string {
17
+ const now = new Date();
18
+ const todayKey = toIsoDayKey(now);
19
+ const targetKey = toIsoDayKey(date);
20
+
21
+ if (targetKey === todayKey) return 'Today';
22
+
23
+ const yesterday = new Date(now);
24
+ yesterday.setDate(yesterday.getDate() - 1);
25
+ if (targetKey === toIsoDayKey(yesterday)) return 'Yesterday';
26
+
27
+ return new Intl.DateTimeFormat(locale, {
28
+ month: 'short',
29
+ day: 'numeric',
30
+ year: now.getFullYear() === date.getFullYear() ? undefined : 'numeric',
31
+ }).format(date);
32
+ }
33
+
34
+ export function formatActivityRelativeTime(date: Date): string {
35
+ const diffSec = Math.floor((Date.now() - date.getTime()) / 1000);
36
+ if (diffSec < 60) return 'just now';
37
+ const diffMin = Math.floor(diffSec / 60);
38
+ if (diffMin < 60) return `${diffMin}m ago`;
39
+ const diffHour = Math.floor(diffMin / 60);
40
+ if (diffHour < 24) return `${diffHour}h ago`;
41
+ const diffDay = Math.floor(diffHour / 24);
42
+ if (diffDay < 30) return `${diffDay}d ago`;
43
+ const diffMonth = Math.floor(diffDay / 30);
44
+ if (diffMonth < 12) return `${diffMonth}mo ago`;
45
+ return `${Math.floor(diffMonth / 12)}y ago`;
46
+ }
47
+
48
+ export function groupActivitiesByDay<T>(
49
+ items: readonly ActivityItem<T>[],
50
+ locale = 'en-US',
51
+ ): readonly ActivityGroup<T>[] {
52
+ const groups: Map<string, { label: string; items: ActivityItem<T>[] }> = new Map();
53
+
54
+ for (const item of items) {
55
+ const d = toDate(item.timestamp);
56
+ const key = toIsoDayKey(d);
57
+ const existing = groups.get(key);
58
+ if (existing) {
59
+ existing.items.push(item);
60
+ } else {
61
+ groups.set(key, {
62
+ label: formatDayLabel(d, locale),
63
+ items: [item],
64
+ });
65
+ }
66
+ }
67
+
68
+ return Array.from(groups.entries()).map(([dateKey, val]) => ({
69
+ dateKey,
70
+ label: val.label,
71
+ items: val.items,
72
+ }));
73
+ }
@@ -0,0 +1,187 @@
1
+ .udb-admin-shell {
2
+ display: flex;
3
+ flex-direction: column;
4
+ gap: 1.25rem;
5
+ width: 100%;
6
+ }
7
+
8
+ .udb-admin-subnav {
9
+ display: flex;
10
+ align-items: center;
11
+ gap: 0.25rem;
12
+ border-bottom: 1px solid var(--line-200, rgba(0, 0, 0, 0.08));
13
+ overflow-x: auto;
14
+ scrollbar-width: none;
15
+ -webkit-overflow-scrolling: touch;
16
+ }
17
+
18
+ .udb-admin-subnav::-webkit-scrollbar {
19
+ display: none;
20
+ }
21
+
22
+ .udb-admin-subnav-item {
23
+ display: inline-flex;
24
+ align-items: center;
25
+ gap: 0.5rem;
26
+ padding: 0.625rem 0.875rem;
27
+ font-size: 0.875rem;
28
+ font-weight: 500;
29
+ white-space: nowrap;
30
+ color: var(--fg-500, #6b7280);
31
+ border-bottom: 2px solid transparent;
32
+ text-decoration: none;
33
+ transition: color 150ms ease, border-color 150ms ease;
34
+ background: transparent;
35
+ border-top: none;
36
+ border-left: none;
37
+ border-right: none;
38
+ cursor: pointer;
39
+ }
40
+
41
+ .udb-admin-subnav-item:hover {
42
+ color: var(--fg-900, #111827);
43
+ border-bottom-color: var(--line-300, rgba(0, 0, 0, 0.15));
44
+ }
45
+
46
+ .udb-admin-subnav-item.is-active {
47
+ color: var(--color-primary, #2563eb);
48
+ border-bottom-color: var(--color-primary, #2563eb);
49
+ font-weight: 600;
50
+ }
51
+
52
+ .udb-admin-overview {
53
+ display: flex;
54
+ flex-direction: column;
55
+ gap: 1.5rem;
56
+ width: 100%;
57
+ }
58
+
59
+ .udb-admin-kpi-grid {
60
+ display: grid;
61
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
62
+ gap: 1rem;
63
+ }
64
+
65
+ .udb-admin-layout-split {
66
+ display: grid;
67
+ grid-template-columns: 1fr;
68
+ gap: 1.5rem;
69
+ }
70
+
71
+ @media (min-width: 1024px) {
72
+ .udb-admin-layout-split {
73
+ grid-template-columns: 1fr 340px;
74
+ }
75
+ }
76
+
77
+ .udb-admin-health-card {
78
+ display: flex;
79
+ flex-direction: column;
80
+ gap: 1rem;
81
+ }
82
+
83
+ .udb-admin-health-header {
84
+ display: flex;
85
+ align-items: center;
86
+ justify-content: space-between;
87
+ }
88
+
89
+ .udb-admin-health-status-row {
90
+ display: flex;
91
+ align-items: center;
92
+ gap: 0.625rem;
93
+ }
94
+
95
+ .udb-admin-pulse-lamp {
96
+ position: relative;
97
+ width: 0.625rem;
98
+ height: 0.625rem;
99
+ border-radius: 9999px;
100
+ }
101
+
102
+ .udb-admin-pulse-lamp::after {
103
+ content: '';
104
+ position: absolute;
105
+ inset: -3px;
106
+ border-radius: 9999px;
107
+ opacity: 0.4;
108
+ animation: udb-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
109
+ }
110
+
111
+ .udb-admin-pulse-lamp--healthy {
112
+ background-color: #10b981;
113
+ }
114
+
115
+ .udb-admin-pulse-lamp--healthy::after {
116
+ background-color: #10b981;
117
+ }
118
+
119
+ .udb-admin-pulse-lamp--degraded {
120
+ background-color: #f59e0b;
121
+ }
122
+
123
+ .udb-admin-pulse-lamp--degraded::after {
124
+ background-color: #f59e0b;
125
+ }
126
+
127
+ .udb-admin-pulse-lamp--down {
128
+ background-color: #ef4444;
129
+ }
130
+
131
+ .udb-admin-pulse-lamp--down::after {
132
+ background-color: #ef4444;
133
+ }
134
+
135
+ @keyframes udb-pulse {
136
+ 0%, 100% {
137
+ transform: scale(1);
138
+ opacity: 0.4;
139
+ }
140
+ 50% {
141
+ transform: scale(1.6);
142
+ opacity: 0;
143
+ }
144
+ }
145
+
146
+ .udb-admin-checks-list {
147
+ display: flex;
148
+ flex-direction: column;
149
+ gap: 0.5rem;
150
+ }
151
+
152
+ .udb-admin-check-item {
153
+ display: flex;
154
+ align-items: center;
155
+ justify-content: space-between;
156
+ padding: 0.5rem 0.75rem;
157
+ border-radius: 0.5rem;
158
+ background: var(--surface-100, rgba(0, 0, 0, 0.02));
159
+ font-size: 0.8125rem;
160
+ }
161
+
162
+ .udb-admin-quick-actions {
163
+ display: flex;
164
+ flex-direction: column;
165
+ gap: 0.5rem;
166
+ }
167
+
168
+ .udb-admin-quick-action-btn {
169
+ display: flex;
170
+ align-items: center;
171
+ gap: 0.75rem;
172
+ padding: 0.75rem;
173
+ border-radius: 0.5rem;
174
+ border: 1px solid var(--line-200, rgba(0, 0, 0, 0.08));
175
+ background: var(--surface-card, #ffffff);
176
+ text-decoration: none;
177
+ color: var(--fg-900, #111827);
178
+ transition: all 150ms ease;
179
+ cursor: pointer;
180
+ width: 100%;
181
+ text-align: left;
182
+ }
183
+
184
+ .udb-admin-quick-action-btn:hover {
185
+ background: var(--surface-hover, rgba(0, 0, 0, 0.03));
186
+ border-color: var(--line-300, rgba(0, 0, 0, 0.15));
187
+ }
@@ -0,0 +1,44 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { AdminGate } from './AdminGate';
4
+
5
+ describe('AdminGate', () => {
6
+ it('renders children when isAdmin is true', () => {
7
+ render(
8
+ <AdminGate isAdmin={true}>
9
+ <div>Privileged admin content</div>
10
+ </AdminGate>,
11
+ );
12
+ expect(screen.getByText('Privileged admin content')).toBeTruthy();
13
+ });
14
+
15
+ it('renders loading state when isLoading is true', () => {
16
+ render(
17
+ <AdminGate isAdmin={false} isLoading={true}>
18
+ <div>Hidden content</div>
19
+ </AdminGate>,
20
+ );
21
+ expect(screen.getByRole('status')).toBeTruthy();
22
+ expect(screen.queryByText('Hidden content')).toBeNull();
23
+ });
24
+
25
+ it('renders default AccessDenied when isAdmin is false', () => {
26
+ render(
27
+ <AdminGate isAdmin={false}>
28
+ <div>Hidden content</div>
29
+ </AdminGate>,
30
+ );
31
+ expect(screen.getByText('Admin Access Required')).toBeTruthy();
32
+ expect(screen.queryByText('Hidden content')).toBeNull();
33
+ });
34
+
35
+ it('renders custom fallback when provided and isAdmin is false', () => {
36
+ render(
37
+ <AdminGate isAdmin={false} fallback={<div>Custom unauthorized message</div>}>
38
+ <div>Hidden content</div>
39
+ </AdminGate>,
40
+ );
41
+ expect(screen.getByText('Custom unauthorized message')).toBeTruthy();
42
+ expect(screen.queryByText('Hidden content')).toBeNull();
43
+ });
44
+ });
@@ -0,0 +1,41 @@
1
+ import type { ReactNode } from 'react';
2
+ import { AccessDenied } from '../../permissions/AccessDenied';
3
+
4
+ export interface AdminGateProps {
5
+ readonly isAdmin: boolean;
6
+ readonly isLoading?: boolean;
7
+ readonly fallback?: ReactNode;
8
+ readonly children: ReactNode;
9
+ }
10
+
11
+ export function AdminGate({
12
+ isAdmin,
13
+ isLoading = false,
14
+ fallback,
15
+ children,
16
+ }: AdminGateProps) {
17
+ if (isLoading) {
18
+ return (
19
+ <div
20
+ role="status"
21
+ aria-label="Checking access"
22
+ className="flex min-h-[240px] w-full items-center justify-center p-8 text-sm text-ink-3"
23
+ >
24
+ <span className="animate-pulse">Checking administrator permissions…</span>
25
+ </div>
26
+ );
27
+ }
28
+
29
+ if (!isAdmin) {
30
+ return (
31
+ fallback ?? (
32
+ <AccessDenied
33
+ title="Admin Access Required"
34
+ description="You do not have administrative privileges to view this section."
35
+ />
36
+ )
37
+ );
38
+ }
39
+
40
+ return <>{children}</>;
41
+ }
@@ -0,0 +1,42 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import { AdminHealthCard } from './AdminHealthCard';
4
+ import type { AdminSystemHealth } from '../types';
5
+
6
+ const sampleHealth: AdminSystemHealth = {
7
+ status: 'healthy',
8
+ latencyMs: 42,
9
+ uptime: '99.99%',
10
+ version: 'v2.4.0',
11
+ checks: [
12
+ { name: 'Database connection', status: 'ok', latencyMs: 12 },
13
+ { name: 'Edge Worker', status: 'ok', latencyMs: 8 },
14
+ { name: 'Redis Cache', status: 'warn', latencyMs: 95, message: 'High load' },
15
+ ],
16
+ };
17
+
18
+ describe('AdminHealthCard', () => {
19
+ it('renders title, status label, and metrics', () => {
20
+ render(<AdminHealthCard health={sampleHealth} />);
21
+ expect(screen.getByText('System Telemetry')).toBeTruthy();
22
+ expect(screen.getByText('Operational')).toBeTruthy();
23
+ expect(screen.getByText('42ms')).toBeTruthy();
24
+ expect(screen.getByText('99.99%')).toBeTruthy();
25
+ expect(screen.getByText('v2.4.0')).toBeTruthy();
26
+ });
27
+
28
+ it('renders service checks list', () => {
29
+ render(<AdminHealthCard health={sampleHealth} />);
30
+ expect(screen.getByText('Database connection')).toBeTruthy();
31
+ expect(screen.getByText('Edge Worker')).toBeTruthy();
32
+ expect(screen.getByText('Redis Cache')).toBeTruthy();
33
+ expect(screen.getByText('High load')).toBeTruthy();
34
+ });
35
+
36
+ it('calls onRefresh when refresh button is clicked', () => {
37
+ const handleRefresh = vi.fn();
38
+ render(<AdminHealthCard health={sampleHealth} onRefresh={handleRefresh} />);
39
+ fireEvent.click(screen.getByLabelText('Refresh telemetry'));
40
+ expect(handleRefresh).toHaveBeenCalled();
41
+ });
42
+ });
@@ -0,0 +1,108 @@
1
+ import { Activity, AlertTriangle, CheckCircle2, RefreshCw, XCircle } from 'lucide-react';
2
+ import { Badge, Button } from '@umituz/web-design-system/atoms';
3
+ import { Card } from '@umituz/web-design-system/organisms';
4
+ import { cn } from '@umituz/web-design-system/utils';
5
+ import type { AdminSystemHealth } from '../types';
6
+
7
+ export interface AdminHealthCardProps {
8
+ readonly health: AdminSystemHealth;
9
+ readonly title?: string;
10
+ readonly subtitle?: string;
11
+ readonly onRefresh?: () => void;
12
+ readonly isRefreshing?: boolean;
13
+ readonly className?: string;
14
+ }
15
+
16
+ export function AdminHealthCard({
17
+ health,
18
+ title = 'System Telemetry',
19
+ subtitle = 'Live infrastructure and service checks',
20
+ onRefresh,
21
+ isRefreshing = false,
22
+ className,
23
+ }: AdminHealthCardProps) {
24
+ const tone = health.status === 'healthy' ? 'success' : health.status === 'degraded' ? 'warning' : 'danger';
25
+ const label = health.status === 'healthy' ? 'Operational' : health.status === 'degraded' ? 'Degraded' : 'Outage';
26
+
27
+ return (
28
+ <Card className={cn('p-5', className)}>
29
+ <div className="udb-admin-health-header mb-4">
30
+ <div className="flex items-center gap-2.5">
31
+ <Activity size={18} className="text-ink-2" />
32
+ <div>
33
+ <h3 className="font-display text-base font-semibold text-ink leading-tight">{title}</h3>
34
+ {subtitle && <p className="text-xs text-ink-3">{subtitle}</p>}
35
+ </div>
36
+ </div>
37
+
38
+ <div className="flex items-center gap-2">
39
+ <div className="udb-admin-health-status-row">
40
+ <span
41
+ className={cn(
42
+ 'udb-admin-pulse-lamp',
43
+ health.status === 'healthy' && 'udb-admin-pulse-lamp--healthy',
44
+ health.status === 'degraded' && 'udb-admin-pulse-lamp--degraded',
45
+ health.status === 'down' && 'udb-admin-pulse-lamp--down',
46
+ )}
47
+ />
48
+ <Badge variant={tone}>{label}</Badge>
49
+ </div>
50
+
51
+ {onRefresh && (
52
+ <Button
53
+ variant="outline"
54
+ size="sm"
55
+ onClick={onRefresh}
56
+ disabled={isRefreshing}
57
+ aria-label="Refresh telemetry"
58
+ className="h-8 w-8 p-0"
59
+ >
60
+ <RefreshCw size={13} className={cn(isRefreshing && 'animate-spin')} />
61
+ </Button>
62
+ )}
63
+ </div>
64
+ </div>
65
+
66
+ <div className="grid grid-cols-3 gap-2 border-y border-line py-3 text-center">
67
+ <div>
68
+ <span className="block text-2xs font-semibold uppercase tracking-wider text-ink-3">Latency</span>
69
+ <span className="font-mono text-sm font-semibold text-ink">
70
+ {typeof health.latencyMs === 'number' ? `${health.latencyMs}ms` : '—'}
71
+ </span>
72
+ </div>
73
+ <div>
74
+ <span className="block text-2xs font-semibold uppercase tracking-wider text-ink-3">Uptime</span>
75
+ <span className="font-mono text-sm font-semibold text-ink">{health.uptime ?? '99.98%'}</span>
76
+ </div>
77
+ <div>
78
+ <span className="block text-2xs font-semibold uppercase tracking-wider text-ink-3">Version</span>
79
+ <span className="font-mono text-sm font-semibold text-ink">{health.version ?? '—'}</span>
80
+ </div>
81
+ </div>
82
+
83
+ {health.checks && health.checks.length > 0 && (
84
+ <div className="udb-admin-checks-list mt-3.5">
85
+ {health.checks.map((check) => {
86
+ const checkTone = check.status === 'ok' ? 'text-emerald-600' : check.status === 'warn' ? 'text-amber-600' : 'text-rose-600';
87
+ const CheckIcon = check.status === 'ok' ? CheckCircle2 : check.status === 'warn' ? AlertTriangle : XCircle;
88
+
89
+ return (
90
+ <div key={check.name} className="udb-admin-check-item">
91
+ <div className="flex items-center gap-2">
92
+ <CheckIcon size={14} className={checkTone} />
93
+ <span className="font-medium text-ink">{check.name}</span>
94
+ </div>
95
+ <div className="flex items-center gap-2">
96
+ {check.message && <span className="text-2xs text-ink-3">{check.message}</span>}
97
+ {typeof check.latencyMs === 'number' && (
98
+ <span className="font-mono text-xs text-ink-2">{check.latencyMs}ms</span>
99
+ )}
100
+ </div>
101
+ </div>
102
+ );
103
+ })}
104
+ </div>
105
+ )}
106
+ </Card>
107
+ );
108
+ }
@@ -0,0 +1,44 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import { AdminOverview } from './AdminOverview';
4
+ import type { AdminKpiItem, AdminSystemHealth } from '../types';
5
+
6
+ const kpis: AdminKpiItem[] = [
7
+ { id: 'tenants', label: 'Total Tenants', value: 142, sub: '128 active' },
8
+ { id: 'mrr', label: 'Monthly Recurring Revenue', value: '$24,500', change: { value: '+12%', trend: 'up' } },
9
+ ];
10
+
11
+ const health: AdminSystemHealth = {
12
+ status: 'healthy',
13
+ latencyMs: 35,
14
+ uptime: '99.95%',
15
+ };
16
+
17
+ describe('AdminOverview', () => {
18
+ it('renders KPI items with values and trends', () => {
19
+ render(<AdminOverview kpis={kpis}><div>Main overview content</div></AdminOverview>);
20
+ expect(screen.getByText('Total Tenants')).toBeTruthy();
21
+ expect(screen.getByText('142')).toBeTruthy();
22
+ expect(screen.getByText('Monthly Recurring Revenue')).toBeTruthy();
23
+ expect(screen.getByText('$24,500')).toBeTruthy();
24
+ expect(screen.getByText('+12%')).toBeTruthy();
25
+ expect(screen.getByText('Main overview content')).toBeTruthy();
26
+ });
27
+
28
+ it('renders quick action buttons and handles clicks', () => {
29
+ const handleClick = vi.fn();
30
+ render(
31
+ <AdminOverview
32
+ health={health}
33
+ quickActions={[
34
+ { title: 'Create Tenant', description: 'Add a new organization', onClick: handleClick },
35
+ ]}
36
+ />,
37
+ );
38
+
39
+ expect(screen.getByText('Create Tenant')).toBeTruthy();
40
+ expect(screen.getByText('Add a new organization')).toBeTruthy();
41
+ fireEvent.click(screen.getByText('Create Tenant'));
42
+ expect(handleClick).toHaveBeenCalled();
43
+ });
44
+ });
@@ -0,0 +1,133 @@
1
+ import type { ReactNode } from 'react';
2
+ import { ChevronRight, TrendingDown, TrendingUp } from 'lucide-react';
3
+ import { Card } from '@umituz/web-design-system/organisms';
4
+ import { cn } from '@umituz/web-design-system/utils';
5
+ import type { AdminKpiItem, AdminSystemHealth } from '../types';
6
+ import { AdminHealthCard } from './AdminHealthCard';
7
+
8
+ export interface AdminQuickAction {
9
+ readonly title: string;
10
+ readonly description?: string;
11
+ readonly icon?: ReactNode;
12
+ readonly href?: string;
13
+ readonly onClick?: () => void;
14
+ }
15
+
16
+ export interface AdminOverviewProps {
17
+ readonly kpis?: readonly AdminKpiItem[];
18
+ readonly health?: AdminSystemHealth;
19
+ readonly onRefreshHealth?: () => void;
20
+ readonly isRefreshingHealth?: boolean;
21
+ readonly healthTitle?: string;
22
+ readonly quickActions?: readonly AdminQuickAction[];
23
+ readonly children?: ReactNode;
24
+ readonly className?: string;
25
+ }
26
+
27
+ export function AdminOverview({
28
+ kpis,
29
+ health,
30
+ onRefreshHealth,
31
+ isRefreshingHealth,
32
+ healthTitle,
33
+ quickActions,
34
+ children,
35
+ className,
36
+ }: AdminOverviewProps) {
37
+ return (
38
+ <div className={cn('udb-admin-overview', className)}>
39
+ {kpis && kpis.length > 0 && (
40
+ <div className="udb-admin-kpi-grid">
41
+ {kpis.map((kpi) => (
42
+ <Card key={kpi.id} className="p-4">
43
+ <div className="flex items-center justify-between">
44
+ <span className="text-xs font-semibold uppercase tracking-wider text-ink-3">{kpi.label}</span>
45
+ {kpi.icon && <span className="text-ink-3">{kpi.icon}</span>}
46
+ </div>
47
+
48
+ <div className="mt-2 flex items-baseline justify-between gap-2">
49
+ <span className="font-display text-2xl font-bold tracking-tight text-ink">{kpi.value}</span>
50
+ {kpi.change && (
51
+ <span
52
+ className={cn(
53
+ 'inline-flex items-center gap-0.5 text-xs font-medium',
54
+ kpi.change.trend === 'up' && 'text-emerald-600',
55
+ kpi.change.trend === 'down' && 'text-rose-600',
56
+ kpi.change.trend === 'neutral' && 'text-ink-3',
57
+ )}
58
+ >
59
+ {kpi.change.trend === 'up' && <TrendingUp size={12} />}
60
+ {kpi.change.trend === 'down' && <TrendingDown size={12} />}
61
+ {kpi.change.value}
62
+ </span>
63
+ )}
64
+ </div>
65
+
66
+ {kpi.sub && <p className="mt-1 text-2xs text-ink-3">{kpi.sub}</p>}
67
+ </Card>
68
+ ))}
69
+ </div>
70
+ )}
71
+
72
+ <div className={cn(Boolean(health || quickActions) && 'udb-admin-layout-split')}>
73
+ <div className="min-w-0 flex-1">{children}</div>
74
+
75
+ {(health || (quickActions && quickActions.length > 0)) && (
76
+ <aside className="flex flex-col gap-4">
77
+ {health && (
78
+ <AdminHealthCard
79
+ health={health}
80
+ title={healthTitle}
81
+ onRefresh={onRefreshHealth}
82
+ isRefreshing={isRefreshingHealth}
83
+ />
84
+ )}
85
+
86
+ {quickActions && quickActions.length > 0 && (
87
+ <Card className="p-4">
88
+ <h3 className="font-display text-sm font-semibold uppercase tracking-wider text-ink-3 mb-3">
89
+ Shortcuts & Actions
90
+ </h3>
91
+ <div className="udb-admin-quick-actions">
92
+ {quickActions.map((action) => {
93
+ const content = (
94
+ <>
95
+ {action.icon && <span className="text-ink-2">{action.icon}</span>}
96
+ <div className="min-w-0 flex-1">
97
+ <span className="block text-sm font-semibold text-ink leading-tight">{action.title}</span>
98
+ {action.description && (
99
+ <span className="block text-2xs text-ink-3">{action.description}</span>
100
+ )}
101
+ </div>
102
+ <ChevronRight size={14} className="text-ink-4 shrink-0" />
103
+ </>
104
+ );
105
+
106
+ if (action.href) {
107
+ return (
108
+ <a key={action.title} href={action.href} className="udb-admin-quick-action-btn">
109
+ {content}
110
+ </a>
111
+ );
112
+ }
113
+
114
+ return (
115
+ <button
116
+ key={action.title}
117
+ type="button"
118
+ onClick={action.onClick}
119
+ className="udb-admin-quick-action-btn"
120
+ >
121
+ {content}
122
+ </button>
123
+ );
124
+ })}
125
+ </div>
126
+ </Card>
127
+ )}
128
+ </aside>
129
+ )}
130
+ </div>
131
+ </div>
132
+ );
133
+ }