2026-04-20 15:10:54 +02:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import { useCeoOverview, useAuditorFlags, useRecentActivity } from "@/hooks/use-dashboard";
|
|
|
|
|
import { useTasks } from "@/hooks/use-tasks";
|
|
|
|
|
import { TeamHealthCards } from "./team-health-cards";
|
|
|
|
|
import { KeyMetricsPanel } from "./key-metrics-panel";
|
|
|
|
|
import { AuditorAlertsPanel } from "./auditor-alerts-panel";
|
|
|
|
|
import { ActiveBlockersPanel } from "./active-blockers-panel";
|
|
|
|
|
import { RecentActivityFeed } from "./recent-activity-feed";
|
|
|
|
|
import { QuickActionsBar } from "./quick-actions-bar";
|
|
|
|
|
import { CeoApprovalQueue } from "./ceo-approval-queue";
|
|
|
|
|
import type { Activity } from "./activity-item";
|
|
|
|
|
import { Button } from "@/components/ui/button";
|
2026-06-10 14:38:44 +02:00
|
|
|
import { UsageOverviewPanel } from "./usage-overview-panel";
|
2026-06-16 06:57:00 +02:00
|
|
|
import { RefreshCw, Settings, AlertCircle } from "lucide-react";
|
2026-04-20 15:10:54 +02:00
|
|
|
import Link from "next/link";
|
|
|
|
|
|
|
|
|
|
export function CommandCenter() {
|
2026-06-16 06:57:00 +02:00
|
|
|
const { data: overview, isLoading: loadingOverview, isError: errorOverview, refetch: refetchOverview } = useCeoOverview();
|
|
|
|
|
const { data: flags, isLoading: loadingFlags, isError: errorFlags, refetch: refetchFlags } = useAuditorFlags({ resolved: false });
|
|
|
|
|
const { data: tasks, isLoading: loadingTasks, isError: errorTasks, refetch: refetchTasks } = useTasks();
|
|
|
|
|
const { data: activity, isLoading: loadingActivity, isError: errorActivity, refetch: refetchActivity } = useRecentActivity(24);
|
|
|
|
|
|
|
|
|
|
const hasError = errorOverview || errorFlags || errorTasks || errorActivity;
|
2026-04-20 15:10:54 +02:00
|
|
|
|
|
|
|
|
const handleRefresh = () => {
|
|
|
|
|
refetchOverview();
|
2026-06-16 06:57:00 +02:00
|
|
|
refetchFlags();
|
|
|
|
|
refetchTasks();
|
|
|
|
|
refetchActivity();
|
2026-04-20 15:10:54 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
{/* Header */}
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<div>
|
|
|
|
|
<h1 className="text-3xl font-bold tracking-tight">RoboCo Command Center</h1>
|
|
|
|
|
<p className="text-muted-foreground">
|
|
|
|
|
Complete visibility into all operations
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<Button variant="outline" onClick={handleRefresh}>
|
|
|
|
|
<RefreshCw className="h-4 w-4 mr-2" />
|
|
|
|
|
Refresh
|
|
|
|
|
</Button>
|
|
|
|
|
<Link href="/settings">
|
|
|
|
|
<Button variant="ghost" size="icon">
|
|
|
|
|
<Settings className="h-5 w-5" />
|
|
|
|
|
</Button>
|
|
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-06-16 06:57:00 +02:00
|
|
|
{/* Error indicator */}
|
|
|
|
|
{hasError && (
|
|
|
|
|
<div className="flex items-center gap-2 rounded-md border border-destructive/50 bg-destructive/10 px-4 py-2 text-sm text-destructive">
|
|
|
|
|
<AlertCircle className="h-4 w-4 shrink-0" />
|
|
|
|
|
Some data failed to load. Click Refresh to try again.
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-04-20 15:10:54 +02:00
|
|
|
{/* Team Health */}
|
|
|
|
|
<section>
|
|
|
|
|
<h2 className="text-lg font-semibold mb-4">Team Health</h2>
|
|
|
|
|
<TeamHealthCards
|
|
|
|
|
teams={overview?.health_status}
|
|
|
|
|
isLoading={loadingOverview}
|
|
|
|
|
/>
|
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
{/* CEO Approval Queue - Your primary action item */}
|
|
|
|
|
<section>
|
|
|
|
|
<CeoApprovalQueue />
|
|
|
|
|
</section>
|
|
|
|
|
|
2026-06-10 14:38:44 +02:00
|
|
|
{/* Metrics, Alerts, and Usage Row */}
|
2026-06-14 20:55:23 +02:00
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-3 xl:grid-cols-3 2xl:grid-cols-3 gap-6">
|
2026-04-20 15:10:54 +02:00
|
|
|
<KeyMetricsPanel
|
|
|
|
|
metrics={overview?.key_metrics}
|
|
|
|
|
isLoading={loadingOverview}
|
|
|
|
|
/>
|
|
|
|
|
<AuditorAlertsPanel alerts={flags} isLoading={loadingFlags} />
|
2026-06-10 14:38:44 +02:00
|
|
|
<UsageOverviewPanel />
|
2026-04-20 15:10:54 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Blockers and Activity Row */}
|
2026-06-14 20:55:23 +02:00
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-2 2xl:grid-cols-2 gap-6">
|
2026-04-20 15:10:54 +02:00
|
|
|
<ActiveBlockersPanel tasks={tasks} isLoading={loadingTasks} />
|
|
|
|
|
<RecentActivityFeed
|
|
|
|
|
activities={activity as Activity[] | undefined}
|
|
|
|
|
isLoading={loadingActivity}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Quick Actions */}
|
|
|
|
|
<section className="pt-4 border-t">
|
|
|
|
|
<h2 className="text-lg font-semibold mb-4">Quick Actions</h2>
|
|
|
|
|
<QuickActionsBar />
|
|
|
|
|
</section>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|