feat(api): add timezone support for group fetching and increase page size
feat(attendance): refactor attendance summary logic and update tests feat(analytics): extend GroupRiskSummary schema with absence and attendance counts feat(groups): enhance group schema with attendee and waitlist counts chore(skills): add frontend design skill with guidelines and license feat(attendee-detail): implement AttendeePhoneLine component for phone display feat(groups): create AttendanceBadge and CapacityIndicator components for group cards feat(groups): add card utility functions for attendance alerts and capacity summaries test(groups): implement tests for attendance alert and capacity summary logic
This commit is contained in:
@@ -70,8 +70,34 @@ export function visibleSessions(
|
||||
return showAll ? ordered : ordered.slice(0, HISTORY_PREVIEW)
|
||||
}
|
||||
|
||||
/** "3 de 5 clases", contando solo las sesiones que se están mostrando. */
|
||||
export function attendanceSummaryLabel(sessions: AttendanceSession[]): string {
|
||||
const present = sessions.filter((session) => session.status === 'PRESENT').length
|
||||
return `${present} de ${classCountLabel(sessions.length)}`
|
||||
/** Clases con asistencia registrada: asistió, faltó o faltó con aviso. Las
|
||||
* "Sin registrar" no cuentan: sin dato no hay ni asistencia ni ausencia, y
|
||||
* meterlas en el denominador hacía que "1 de 3" se leyera como dos ausencias. */
|
||||
function markedSessions(sessions: AttendanceSession[]): AttendanceSession[] {
|
||||
return sessions.filter((session) => session.status != null)
|
||||
}
|
||||
|
||||
export type AttendanceSummary = {
|
||||
/** "1 de 1 clase", o "Sin clases registradas" si no hay ninguna con dato. */
|
||||
label: string
|
||||
/** "2 sin registrar", o `null` si no hay clases sin registro. */
|
||||
unmarkedLabel: string | null
|
||||
}
|
||||
|
||||
/** Resumen de las filas que se están mostrando: cuántas clases registró la
|
||||
* persona sobre cuántas hay con dato, y cuántas quedaron sin registrar.
|
||||
*
|
||||
* El texto de las "sin registrar" se apaga cuando no hay ninguna clase
|
||||
* registrada: el resumen ya dice que no hay datos y los dos textos dirían lo
|
||||
* mismo dos veces. */
|
||||
export function attendanceSummary(sessions: AttendanceSession[]): AttendanceSummary {
|
||||
const marked = markedSessions(sessions)
|
||||
if (marked.length === 0) return { label: 'Sin clases registradas', unmarkedLabel: null }
|
||||
|
||||
const present = marked.filter((session) => session.status === 'PRESENT').length
|
||||
const unmarked = sessions.length - marked.length
|
||||
return {
|
||||
label: `${present} de ${classCountLabel(marked.length)}`,
|
||||
unmarkedLabel: unmarked > 0 ? `${unmarked} sin registrar` : null,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user