import type { GroupAutomationsDto } from '@gruperly/shared' import { Link } from '@tanstack/react-router' import { MessageCircle } from 'lucide-react' import { Badge, Switch } from '../../../components/ui' import { hasPlanFeature, useBillingStatus } from '../../billing' import { automationBlockedReason, useWhatsappStatus, WEEKLY_SEND_LABEL } from '../../whatsapp' import { useGroupDetail } from './GroupDetailProvider' type Automation = { key: keyof GroupAutomationsDto kind: 'PAYMENT_REMINDER' | 'REENGAGEMENT' title: string description: string } const AUTOMATIONS: readonly Automation[] = [ { key: 'autoPaymentReminders', kind: 'PAYMENT_REMINDER', title: 'Recordatorio semanal de pago', description: 'A quien tenga un cobro pendiente o vencido, con su link de pago.', }, { key: 'autoReengagement', kind: 'REENGAGEMENT', title: 'Mensaje de reenganche semanal', description: 'A los miembros en riesgo por faltas. Como mucho uno cada 2 semanas.', }, ] /** * Los envíos automáticos por WhatsApp del grupo. Solo el dueño los cambia: los * mensajes salen de su número. Se pueden apagar siempre; prenderlos exige un * WhatsApp vinculado y el mensaje aprobado. */ export function GroupAutomationsCard() { const { group, updateAutomations, isUpdatingAutomations, isGroupOwner } = useGroupDetail() const whatsappQuery = useWhatsappStatus({ enabled: isGroupOwner }) const billingQuery = useBillingStatus({ enabled: isGroupOwner }) if (!group || !isGroupOwner) return null const includedInPlan = hasPlanFeature(billingQuery.data, 'whatsappAutomations') return (

Mensajes automáticos por WhatsApp

{includedInPlan ? null : Pro}

{WEEKLY_SEND_LABEL} {includedInPlan ? null : ( <> {' '} Disponible en el plan Pro.{' '} Ver planes )}

) }