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:
Jose Selesan
2026-10-27 16:35:07 -03:00
parent 90f31290d4
commit b99bc4d519
48 changed files with 2333 additions and 1379 deletions

View File

@@ -0,0 +1,72 @@
import { z } from 'zod';
const isoDateTimeSchema = z.string().datetime();
/* "Requiere atención": per-attendee alerts that the Grupos list and the
"Ver todos" screen read from the same endpoint. The rule that produces them
lives in `lib/student-alerts.ts`; this file only describes the transport. */
export const studentAlertTypeSchema = z.enum(['asistencia', 'pago']);
export type StudentAlertType = z.output<typeof studentAlertTypeSchema>;
export const studentAlertSeveritySchema = z.enum(['urgente', 'vigilar']);
export type StudentAlertSeverity = z.output<typeof studentAlertSeveritySchema>;
export const StudentAlertSchema = z.object({
tipo: studentAlertTypeSchema,
gravedad: studentAlertSeveritySchema,
/** Short reason for the pill: "4 faltas", "Cuota vencida". */
etiqueta: z.string(),
/** Natural-language line: "Faltó a 4 de las últimas 6 clases." */
detalle: z.string(),
/** What the alert is about (last absence / overdue payments). "Resuelto"
* stores it, so a new absence or a new overdue fee brings the alert back. */
firma: z.string(),
/** How strong the signal is inside its severity (absences, overdue fees);
* only used to order. */
peso: z.number().int().min(0),
});
export type StudentAlert = z.output<typeof StudentAlertSchema>;
export const OverduePaymentSchema = z.object({
id: z.string(),
amount: z.number(),
currency: z.string(),
dueDate: isoDateTimeSchema,
checkoutUrl: z.string().nullable(),
});
export type OverduePayment = z.output<typeof OverduePaymentSchema>;
export const AttentionMemberSchema = z.object({
attendeeId: z.string(),
fullName: z.string(),
/** `phone ?? guardianPhone`, as stored (national format). */
phone: z.string().nullable(),
/** The same phone in E.164 with the professor's country, ready for `wa.me`;
* `null` when it can't be normalized. */
whatsappPhone: z.string().nullable(),
/** Already filtered by "Resuelto" and ordered worst first. */
alerts: z.array(StudentAlertSchema),
overduePayments: z.array(OverduePaymentSchema),
});
export type AttentionMember = z.output<typeof AttentionMemberSchema>;
export const AttentionGroupSchema = z.object({
groupId: z.string(),
groupName: z.string(),
capacity: z.number().int().nullable(),
/** Every ACTIVE member, with or without alerts (the card draws them all). */
members: z.array(AttentionMemberSchema),
});
export type AttentionGroup = z.output<typeof AttentionGroupSchema>;
export const AttentionOverviewSchema = z.object({
groups: z.array(AttentionGroupSchema),
});
export type AttentionOverview = z.output<typeof AttentionOverviewSchema>;
export const ResolveAlertSchema = z.strictObject({
tipo: studentAlertTypeSchema,
firma: z.string().min(1),
});
export type ResolveAlert = z.output<typeof ResolveAlertSchema>;