import { Link } from "react-router-dom" import { CalendarClock, CheckCircle2, AlertTriangle, X, Users, Send, XCircle, Smartphone, } from "lucide-react" import { Badge } from "../../../components/ui/badge" import { Button } from "../../../components/ui/button" import { Card, CardContent } from "../../../components/ui/card" import { channelLabel, formatScheduledAtLabel } from "../../../lib/notificationBulk" import { cn } from "../../../lib/utils" import type { NotificationChannel } from "../../../types/notification.types" export type BulkSendSummary = | { kind: "immediate" channel: NotificationChannel audienceLabel: string titlePreview: string messagePreview: string sent: number failed: number total: number targetUsers?: number devicesTargeted?: number pushImage?: string completedAt: string apiMessage?: string } | { kind: "scheduled" channel: NotificationChannel audienceLabel: string titlePreview: string messagePreview: string jobId: number scheduledAt: string status?: string emailTemplateSlug?: string completedAt: string apiMessage?: string } interface BulkSendSummaryPanelProps { summary: BulkSendSummary onDismiss: () => void } function StatBlock({ label, value, tone = "default", }: { label: string value: number | string tone?: "default" | "success" | "danger" | "muted" }) { const valueClass = tone === "success" ? "text-mint-600" : tone === "danger" ? "text-destructive" : tone === "muted" ? "text-grayScale-500" : "text-grayScale-800" return (
{label}
{value}
{isImmediate ? `Completed at ${completedLabel}` : `Scheduled for ${formatScheduledAtLabel(summary.scheduledAt)} · created ${completedLabel}`}
{summary.apiMessage ? ({summary.apiMessage}
) : null}
{summary.audienceLabel}
{summary.titlePreview || "unassigned"}
{summary.messagePreview || "unassigned"}
{!isImmediate && summary.emailTemplateSlug ? (Template: {summary.emailTemplateSlug}
) : null}{isPush ? `${summary.sent} of ${summary.devicesTargeted ?? summary.total} device deliveries succeeded` : `${summary.sent} of ${summary.total} delivered`} {summary.failed > 0 ? ` · ${summary.failed} failed` : ""}
Image: {summary.pushImage}
) : null} {isPush && (summary.devicesTargeted ?? 0) === 0 && (summary.targetUsers ?? 0) > 0 ? (
{formatScheduledAtLabel(summary.scheduledAt)}
This summary is temporary and clears when you dismiss it or send again.