import type { SuppressionCounts } from '../../../services/CampaignService'; // Only condition audiences carry null: the server withholds a clinical count under its floor. export const WITHHELD = 'Withheld for a small audience'; const LABELS: Record = { 'not-opted-in': 'Not opted in to promotional messages', suppressed: 'Email bounced or was reported as spam', unreachable: 'No way to reach them', 'not-entitled': 'Reachable only by text, not included in your plan', 'no-relationship': 'No care relationship with this practice', }; export interface ReasonRow { key: keyof SuppressionCounts; label: string; count: string; } export const reasonRows = (byReason: SuppressionCounts): ReasonRow[] => (Object.keys(LABELS) as (keyof SuppressionCounts)[]) .filter((key) => byReason[key] !== 0) .map((key) => ({ key, label: LABELS[key], count: byReason[key] === null ? WITHHELD : String(byReason[key]), }));