diff --git a/src/app/dashboard/ai/history/page.tsx b/src/app/dashboard/ai/history/page.tsx new file mode 100644 index 0000000..99e3d31 --- /dev/null +++ b/src/app/dashboard/ai/history/page.tsx @@ -0,0 +1,96 @@ +'use client'; + +import { useQuery } from '@tanstack/react-query'; +import { apiFetch } from '../../../../lib/api'; +import type { AiRequest } from '../../../../lib/api'; +import { useSession } from '../../../../components/session-provider'; + +export default function AiHistoryPage() { + const { activeTenant } = useSession(); + const tenantId = activeTenant?.tenantId ?? ''; + + const { data: requests = [], isLoading } = useQuery({ + queryKey: ['ai-requests', tenantId], + queryFn: () => apiFetch('/v1/ai-requests?limit=200', { tenantId }), + enabled: Boolean(tenantId), + staleTime: 30_000, + }); + + function statusClass(status: string) { + switch (status) { + case 'completed': return 'bg-signal-ok text-white'; + case 'failed': return 'bg-signal-danger text-white'; + case 'pending': return 'bg-bronze-wash text-bronze-deep'; + default: return 'bg-paper-sunken text-ink-faint'; + } + } + + return ( +
+
+

Istoric Execuții AI

+

+ Toate cererile AI înregistrate pentru workspace —{' '} + {isLoading ? '…' : `${requests.length} cereri`} +

+
+ + {isLoading ? ( +

Se încarcă…

+ ) : requests.length === 0 ? ( +
+

Nicio cerere AI înregistrată

+

+ Cererile AI sunt înregistrate automat la utilizare. +

+
+ ) : ( +
+
+ + + + + + + + + + + + + {requests.map((req) => ( + + + + + + + + + ))} + +
DataScopModelClasă acțiuneCost USDStatus
+ {new Date(req.createdAt).toLocaleString('ro-RO', { + month: 'short', day: 'numeric', + hour: '2-digit', minute: '2-digit', + })} + +

{req.purpose.replace(/_/g, ' ')}

+
{req.model} + + {req.actionClass} + + + {req.costUsd ? `$${Number(req.costUsd).toFixed(4)}` : '—'} + + + {req.resultStatus} + +
+
+
+ )} +
+ ); +}