"use client"; import { usePoll } from "@/lib/use-poll"; import type { EmailStats } from "@/lib/types"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Badge } from "@/components/ui/badge"; import { StatusBadge } from "@/components/status-badge"; interface BackupResult { host: string; status: string; last_run: string; size?: string; } interface DriftResult { stack: string; drifted: boolean; details?: string; } interface StackRestart { stack: string; status: string; timestamp: string; } export default function AutomationsPage() { const { data: emails } = usePoll( "/api/automations/emails", 60000 ); const { data: backups } = usePoll( "/api/automations/backups", 120000 ); const { data: drift } = usePoll( "/api/automations/drift", 120000 ); const { data: restarts } = usePoll( "/api/automations/restarts", 60000 ); return (

Automations

{/* Email Organizers */} Email Organizers {!emails ? (

Loading...

) : (
{emails.accounts.map((acct) => (
{acct.account} {acct.today} today
{Object.entries(acct.categories).map(([cat, count]) => ( {cat}: {count} ))}
))}
)}
{/* Row 2: Backups, Drift, Restarts */}
Backup Status {!backups ? (

Loading...

) : backups.length === 0 ? (

No backups found

) : (
{backups.map((b) => (
{b.host}
{b.size ?? ""}
))}
)}
Config Drift {!drift ? (

Loading...

) : drift.length === 0 ? (

No drift detected

) : (
{drift.map((d) => (
{d.stack}
))}
)}
Stack Restarts {!restarts ? (

Loading...

) : restarts.length === 0 ? (

No recent restarts

) : (
{restarts.map((r, i) => (
{r.stack}
{new Date(r.timestamp).toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", })}
))}
)}
); }