import { useQuery } from '@tanstack/react-query';
import { useNavigate } from 'react-router-dom';
import { getOperations, type OperationsView } from '@/lib/api-client';
import { useDemoMode } from '@/lib/demo-mode';
import { formatRelative } from '@/lib/time';
import { DemoRestricted } from '@/shared/components';
import { Activity, AlertTriangle, Clock, Database, Loader2, Timer } from 'lucide-react';
function statusClass(status: string): string {
switch (status) {
case 'deployed':
case 'completed':
case 'success':
return 'text-[var(--success)]';
case 'failed':
case 'cancelled':
case 'rolled_back':
return 'text-[var(--error)]';
case 'building':
case 'deploying':
case 'in_progress':
case 'running':
return 'text-[var(--accent-primary)]';
default:
return 'text-[var(--warning)]';
}
}
function Section({ title, icon: Icon, count, children }: {
title: string;
icon: typeof Activity;
count: number;
children: React.ReactNode;
}) {
return (
{title}
({count})
{text}
; } export function OperationsPage() { const isDemoMode = useDemoMode(); const navigate = useNavigate(); const opsQuery = useQuery({ queryKey: ['operations'], queryFn: getOperations, enabled: !isDemoMode, refetchInterval: (query) => (query.state.data?.active_deployments?.length ?? 0) > 0 ? 3000 : 15000, }); if (isDemoMode) { returnLive view of deploys, queues, cron runs, and backups
In flight
{active.length}
Queued
{queuedTotal}
Failed 24h
{failed.length}
Backups 24h
{backups.length}