feat: rediseño de Grupos y pantalla "Requiere atención"
- Grupos: subtítulo con resumen (grupos · alumnos · lugares libres), sección "Requiere atención" con los 4 alumnos más urgentes y tarjetas con avatares (punteados por lugar libre en grupos chicos, superpuestos con "+N" en grandes; con alerta primero y anillo de gravedad). - Pantalla nueva /groups/attention: filtros Todos/Asistencia/Pagos, secciones Urgente y A vigilar, Contactar / Enviar recordatorio por wa.me y "Resuelto" persistente con update optimista. - FAB "Nuevo grupo" que se pliega al scrollear (respeta reduced motion); los toasts en mobile suben para no quedar debajo. - Alertas centralizadas en computeStudentAlerts (shared). La regla de asistencia pasa a: urgente = 3 seguidas o 4 de las últimas 6; a vigilar = 2 de las últimas 4 (sin inactividad por días ni tendencia). Cuotas: 1 vencida vigilar, 2+ urgente. - Backend: GET /attention y POST /attention/:attendeeId/resolve; tabla attendee_alert_resolutions (la alerta vuelve si cambia la firma). - Tokens de gravedad para claro y oscuro; se quita el indicador de pills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
80
apps/web/src/features/attention/AttentionCard.tsx
Normal file
80
apps/web/src/features/attention/AttentionCard.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { Check } from 'lucide-react'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { AlertTag } from './AlertTag'
|
||||
import { reminderMessage, whatsappLink, type AttentionItem } from './attention'
|
||||
import { SeverityAvatar } from './SeverityAvatar'
|
||||
|
||||
const ACTION_CLASS =
|
||||
'inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-xl px-3 text-sm font-semibold transition-colors focus-visible:ring-2 focus-visible:ring-accent focus-visible:outline-none motion-reduce:transition-none'
|
||||
|
||||
type AttentionCardProps = {
|
||||
item: AttentionItem
|
||||
onResolve: () => void
|
||||
}
|
||||
|
||||
export function AttentionCard({ item, onResolve }: AttentionCardProps) {
|
||||
const { student, alert } = item
|
||||
const urgent = alert.gravedad === 'urgente'
|
||||
const isPayment = alert.tipo === 'pago'
|
||||
|
||||
const actionLabel = isPayment ? 'Enviar recordatorio' : 'Contactar'
|
||||
const href = whatsappLink(student, isPayment ? reminderMessage(student) : undefined)
|
||||
// Urgent: light fill, the strongest action on screen. To watch: subtle gray.
|
||||
const primaryTone = urgent
|
||||
? 'bg-primary text-background hover:bg-primary/90'
|
||||
: 'bg-primary-soft text-primary hover:bg-border'
|
||||
|
||||
return (
|
||||
<article className="rounded-2xl border border-border bg-surface p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<SeverityAvatar name={student.fullName} seed={student.attendeeId} severity={alert.gravedad} size="md" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<Link
|
||||
to="/groups/$groupId/attendees/$attendeeId"
|
||||
params={{ groupId: student.groupId, attendeeId: student.attendeeId }}
|
||||
className="block truncate font-semibold text-primary hover:underline focus-visible:underline focus-visible:outline-none"
|
||||
>
|
||||
{student.fullName}
|
||||
</Link>
|
||||
<p className="truncate text-sm text-secondary">{student.groupName}</p>
|
||||
</div>
|
||||
<AlertTag severity={alert.gravedad}>{alert.etiqueta}</AlertTag>
|
||||
</div>
|
||||
|
||||
<p className="mt-3 text-sm text-primary">{alert.detalle}</p>
|
||||
|
||||
<div className="mt-3 grid grid-cols-2 gap-2">
|
||||
{href ? (
|
||||
<a
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label={`${actionLabel} a ${student.fullName} por WhatsApp`}
|
||||
className={cn(ACTION_CLASS, primaryTone)}
|
||||
>
|
||||
{actionLabel}
|
||||
</a>
|
||||
) : (
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
aria-label={`${actionLabel}: ${student.fullName} no tiene teléfono cargado`}
|
||||
className={cn(ACTION_CLASS, primaryTone, 'cursor-not-allowed opacity-45')}
|
||||
>
|
||||
{actionLabel}
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
type="button"
|
||||
onClick={onResolve}
|
||||
aria-label={`Marcar como resuelto: ${student.fullName}, ${alert.etiqueta}`}
|
||||
className={cn(ACTION_CLASS, 'border border-border text-primary hover:bg-primary-soft')}
|
||||
>
|
||||
<Check className="size-4" aria-hidden="true" />
|
||||
Resuelto
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user