"use client"; import { useState, useTransition } from "react"; import { AlertCircleIcon, PlayIcon, XIcon, Loader2Icon, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { resumeReminderRunAction, cancelReminderRunAction, } from "@/actions/reminders"; interface PausedRunBannerProps { runId: string; /** Best-effort sent count for the body copy. Falls back to a * generic message when undefined. */ sent?: number; /** Best-effort total target count. */ total?: number; /** Deadline hour the bot stopped at. Shown in the body copy. */ windowEndHour: number; /** Operator timezone (for the deadline label). */ timezone: string; } /** * Amber callout shown above the reminder detail view when the most * recent run is in 'paused' state. Two interactive choices: * • Resume → re-enqueues the run via the bot. * • Cancel run → stops the run cleanly (remaining pending → skipped). * * Pause notifications deep-link the operator into this surface. */ export function PausedRunBanner({ runId, sent, total, windowEndHour, timezone, }: PausedRunBannerProps) { const [pending, startTransition] = useTransition(); const [error, setError] = useState(null); const onResume = () => startTransition(async () => { setError(null); const r = await resumeReminderRunAction({ runId }); if (!r.ok) setError(r.error); }); const onCancel = () => startTransition(async () => { setError(null); const r = await cancelReminderRunAction({ runId }); if (!r.ok) setError(r.error); }); const remaining = typeof sent === "number" && typeof total === "number" ? Math.max(0, total - sent) : null; return (

Reminder paused

{typeof sent === "number" && typeof total === "number" ? `${sent} of ${total} groups delivered.` : "The delivery window closed before all groups got the message."}{" "} The deadline was {windowEndHour}:00 ({timezone}).{" "} {remaining !== null && remaining > 0 ? `Resume to send the remaining ${remaining}, or cancel the run.` : "Resume to keep going, or cancel the run."}

{error && (
{error}
)}
); }