- Frontend React (SKEEN Brand) con Vite, TypeScript, Tailwind - Frontend Homenest (versión alternativa) - Módulos Odoo 17 custom (citas, pacientes, monedero, pagos, ventas, inventario, whatsapp) - WACRM fork (Next.js 16 + Supabase) - Hermes + Bridge + Skills (Qwen3.6 via Nan Builders) - Scripts de migración y operación - Documentación extensiva en docs/
95 lines
2.6 KiB
TypeScript
95 lines
2.6 KiB
TypeScript
/**
|
|
* Shared status badge config for broadcasts + recipients.
|
|
*
|
|
* Previously `statusConfig` was defined inline in both
|
|
* /broadcasts/page.tsx and /broadcasts/[id]/page.tsx with slight
|
|
* drift risk. One source of truth now.
|
|
*
|
|
* Badge shape: bg-*-500/10 + text-*-400 + border-*-500/20. The
|
|
* translucent fills sit fine on both light and dark surfaces; neutral
|
|
* statuses use text-muted-foreground so the label stays legible in
|
|
* light mode (a solid slate-400 would be too faint on white).
|
|
*/
|
|
|
|
import type { BroadcastStatus, RecipientStatus } from "@/types";
|
|
|
|
export interface StatusDisplay {
|
|
label: string;
|
|
classes: string;
|
|
/**
|
|
* Set true for statuses that should pulse in the UI to convey
|
|
* "live / in-flight" — currently only `sending`.
|
|
*/
|
|
pulse?: boolean;
|
|
}
|
|
|
|
export const broadcastStatusConfig: Record<BroadcastStatus, StatusDisplay> = {
|
|
draft: {
|
|
label: "Draft",
|
|
classes: "bg-slate-500/10 text-muted-foreground border-slate-500/20",
|
|
},
|
|
scheduled: {
|
|
label: "Scheduled",
|
|
classes: "bg-blue-500/10 text-blue-400 border-blue-500/20",
|
|
},
|
|
sending: {
|
|
label: "Sending",
|
|
classes: "bg-yellow-500/10 text-yellow-400 border-yellow-500/20",
|
|
pulse: true,
|
|
},
|
|
sent: {
|
|
label: "Sent",
|
|
classes: "bg-primary/10 text-primary border-primary/20",
|
|
},
|
|
failed: {
|
|
label: "Failed",
|
|
classes: "bg-red-500/10 text-red-400 border-red-500/20",
|
|
},
|
|
};
|
|
|
|
export const recipientStatusConfig: Record<RecipientStatus, StatusDisplay> = {
|
|
pending: {
|
|
label: "Pending",
|
|
classes: "bg-slate-500/10 text-muted-foreground border-slate-500/20",
|
|
},
|
|
sent: {
|
|
label: "Sent",
|
|
classes: "bg-blue-500/10 text-blue-400 border-blue-500/20",
|
|
},
|
|
delivered: {
|
|
label: "Delivered",
|
|
classes: "bg-primary/10 text-primary border-primary/20",
|
|
},
|
|
read: {
|
|
label: "Read",
|
|
classes: "bg-primary/10 text-primary border-primary/20",
|
|
},
|
|
replied: {
|
|
label: "Replied",
|
|
classes: "bg-purple-500/10 text-purple-400 border-purple-500/20",
|
|
},
|
|
failed: {
|
|
label: "Failed",
|
|
classes: "bg-red-500/10 text-red-400 border-red-500/20",
|
|
},
|
|
};
|
|
|
|
/**
|
|
* Tolerant lookup — callers often have a generic string status
|
|
* coming from Supabase. Falls back to the "draft" / "pending"
|
|
* entry so the UI never crashes on an unknown value.
|
|
*/
|
|
export function getBroadcastStatus(status: string): StatusDisplay {
|
|
return (
|
|
broadcastStatusConfig[status as BroadcastStatus] ??
|
|
broadcastStatusConfig.draft
|
|
);
|
|
}
|
|
|
|
export function getRecipientStatus(status: string): StatusDisplay {
|
|
return (
|
|
recipientStatusConfig[status as RecipientStatus] ??
|
|
recipientStatusConfig.pending
|
|
);
|
|
}
|