feat(web): rediseño de Inicio en mobile y criterio de inactividad por clases faltadas

- Inicio: saludo con fecha, estadísticas compactas en fila (arregla el
  "0 / 0 por cobrar"), sección "Para atender" (alumnos en riesgo alto y
  cobros vencidos), tarjeta de clase de hoy con CTA a todo el ancho y
  estado vacío de cobros que lleva a vincular Mercado Pago.
- Riesgo: la inactividad se mide desde la última presencia hasta la última
  clase faltada, no contra hoy; un grupo sin clases registradas ya no pone
  a todos sus miembros en riesgo alto.
- Tarjeta de grupo: el aviso usa el motivo real ("12 días sin venir") en
  vez de "0 faltas".
- Días del horario en orden de calendario (sortWeekDays).
- Toast por encima del BottomNav en mobile; ficha de alumno sin flecha de
  volver en mobile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-10-27 11:18:18 -03:00
parent 9617447e05
commit b12ffdda37
12 changed files with 283 additions and 88 deletions

View File

@@ -168,7 +168,7 @@ export function summarizeMemberAttendance(
const present = marked.filter((session) => session.status === 'PRESENT').length;
const attendanceRate = marked.length ? Math.round((present / marked.length) * 100) : null;
const level = classify(consecutiveAbsences, daysSinceLastAttendance, marked);
const level = classify(consecutiveAbsences, missedSpanDays(sessions, lastAttendedAt), marked);
return {
level,
@@ -182,15 +182,13 @@ export function summarizeMemberAttendance(
/** Verdict: first the streak and the inactivity, then the trend. */
function classify(
consecutiveAbsences: number,
daysSinceLastAttendance: number | null,
missedDays: number | null,
markedSessions: MemberClassSession[],
): AttendanceRiskLevel {
const rules = ATTENDANCE_RISK_RULES;
const inactive = missedDays !== null && missedDays > rules.highInactivityDays;
if (
consecutiveAbsences >= rules.highAbsenceStreak ||
(daysSinceLastAttendance !== null && daysSinceLastAttendance > rules.highInactivityDays)
) {
if (consecutiveAbsences >= rules.highAbsenceStreak || inactive) {
return 'riesgo_alto';
}
if (consecutiveAbsences >= rules.attentionAbsenceStreak) {
@@ -283,6 +281,32 @@ function isDeclining(sessions: MemberClassSession[]): boolean {
}
}
/**
* Inactivity as the group lived it: days from the last presence (or, if they
* never came, from their first class) to the most recent class they missed.
* It is measured against the classes and not against today on purpose: if the
* group stopped meeting, or nobody recorded attendance, those days are the
* group's, not the attendee's. Without this, a group that went 10 days without
* recording a class turned all its members red at once. `null` when they have
* not missed any class since their last presence.
*/
function missedSpanDays(
sessions: MemberClassSession[],
lastAttendedAt: string | undefined,
): number | null {
let lastMissedAt: string | undefined;
for (let index = sessions.length - 1; index >= 0; index -= 1) {
if (sessions[index].status === 'ABSENT') {
lastMissedAt = sessions[index].startsAt;
break;
}
}
const from = lastAttendedAt ?? sessions[0]?.startsAt;
if (!lastMissedAt || !from) return null;
const span = new Date(lastMissedAt).getTime() - new Date(from).getTime();
return span > 0 ? Math.floor(span / DAY_MS) : null;
}
/** Start of the most recent class with presence, or `undefined` if they have none. */
function lastPresentAt(sessions: MemberClassSession[]): string | undefined {
for (let index = sessions.length - 1; index >= 0; index -= 1) {