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

@@ -3,6 +3,7 @@ import { zodResolver } from '@hookform/resolvers/zod'
import type { BillingType, CountryCode, CreateFirstGroup, WeekDay } from '@gruperly/shared'
import { CreateFirstGroupSchema, DEFAULT_COUNTRY } from '@gruperly/shared'
import { ArrowLeft, Check, Loader2 } from 'lucide-react'
import { sortWeekDays } from '../../lib/format'
import { cn } from '../../lib/utils'
import { Button, Input, Label } from '../../components/ui'
import { BILLING_TYPES, WEEK_DAY_CHIPS } from '../onboarding/constants'
@@ -57,7 +58,7 @@ export function GroupForm({
const dueDay = watch('dueDay')
const toggleDay = (day: WeekDay) => {
const next = days.includes(day) ? days.filter((d) => d !== day) : [...days, day]
const next = days.includes(day) ? days.filter((d) => d !== day) : sortWeekDays([...days, day])
setValue('days', next, { shouldValidate: true })
}

View File

@@ -38,6 +38,9 @@ export type GroupMember = {
name: string
status: MemberStatus
absences: number
/** Why they are on the alert line ("3 faltas", "12 días sin venir"). When
* missing, the absences are used. */
reason?: string
}
export type CapacityCounts = {
@@ -90,8 +93,8 @@ export function alertTextFromMembers(members: GroupMember[]): string | null {
if (highRisk.length === 1) {
const first = highRisk[0]
const nombre = firstName(first.name)
const faltas = `${first.absences} ${first.absences === 1 ? 'falta' : 'faltas'}`
return `${nombre}: ${faltas}${kAtencion}`
const motivo = first.reason ?? `${first.absences} ${first.absences === 1 ? 'falta' : 'faltas'}`
return `${nombre}: ${motivo}${kAtencion}`
}
if (highRisk.length >= 2) {
@@ -123,6 +126,7 @@ export function membersFromGroupAndRisk(
name: u.fullName,
status: 'high_risk',
absences: u.consecutiveAbsences,
reason: absenceReason(u) ?? undefined,
})
} else if (u.level === 'atencion') {
members.push({
@@ -130,6 +134,7 @@ export function membersFromGroupAndRisk(
name: u.fullName,
status: 'attention',
absences: u.consecutiveAbsences,
reason: absenceReason(u) ?? undefined,
})
}
}
@@ -278,15 +283,16 @@ function countedLevels(counts: CapacityCounts): string {
}
/* The reason that best explains why someone is on the status line, in the order
the rule considers them: first the streak of absences (something that is
going away), then the time since last showing up, and last the attendance
rate. With a single absence and ok it returns null: not enough to name
anyone. */
function absenceReason(miembro: UrgentMemberSummary): string | null {
the rule considers them: first a streak of absences (something that is going
away), then the time since last showing up, and last the attendance rate. A
single absence only names them when nothing else does: someone at high risk
for inactivity reads better as "12 días sin venir" than as "1 falta". */
export function absenceReason(miembro: UrgentMemberSummary): string | null {
const { consecutiveAbsences: faltas, daysSinceLastAttendance: dias, attendanceRate: asistencia } = miembro
if (faltas > 0) return `${faltas} ${faltas === 1 ? 'falta' : 'faltas'}`
if (faltas >= 2) return `${faltas} faltas`
if (dias != null && dias > 0) return `${dias} ${dias === 1 ? 'día' : 'días'} sin venir`
if (faltas === 1) return '1 falta'
if (asistencia != null && asistencia < 100) return `asistencia ${asistencia}%`
return null
}

View File

@@ -3,6 +3,7 @@ import {
formatBillingMeta,
formatPrice,
WEEK_DAY_FULL_LABELS,
sortWeekDays,
} from '../../../lib/format'
import { cn } from '../../../lib/utils'
import { useGroupDetail } from './GroupDetailProvider'
@@ -18,7 +19,7 @@ export function GroupInfoCard() {
const { group, attendeesTotal, attendeesPending, waitlistTotal } = useGroupDetail()
if (!group) return null
const daysLabel = (group.days ?? []).map((day) => WEEK_DAY_FULL_LABELS[day]).join(', ')
const daysLabel = sortWeekDays(group.days ?? []).map((day) => WEEK_DAY_FULL_LABELS[day]).join(', ')
const capacity = group.capacity
const isFull = capacity != null && attendeesTotal >= capacity
const freeSpots = capacity != null ? Math.max(capacity - attendeesTotal, 0) : null