chore: update comments and documentation for clarity and consistency across various files
- Translated comments from Spanish to English in vite.config.ts, docker-compose.yml, attendance-risk.ts, analytics.ts, attendance.ts, attendees.ts, enums.ts, groups.ts, and onboarding.ts. - Improved descriptions for better understanding of code functionality and purpose. - Ensured uniformity in terminology and phrasing throughout the codebase.
This commit is contained in:
@@ -28,16 +28,16 @@ export function AbsenceLinkSection() {
|
||||
title="Link de ausencias"
|
||||
toggle={{ isOpen, panelId, onToggle: () => setIsOpen((value) => !value) }}
|
||||
>
|
||||
{/* El panel queda en el DOM pero oculto: `aria-controls` siempre resuelve y
|
||||
el texto de "Link copiado" no se pierde al plegar y desplegar. */}
|
||||
{/* The panel stays in the DOM but hidden: `aria-controls` always resolves and
|
||||
the "Link copied" text is not lost on collapse/expand. */}
|
||||
<div id={panelId} hidden={!isOpen}>
|
||||
<p className="px-3 text-sm text-foreground">
|
||||
Mandales este link para que avisen cuando no puedan venir.
|
||||
</p>
|
||||
{/* Apiladas y a ancho completo: al 50% los rótulos ("Enviar por WhatsApp")
|
||||
se partían en dos líneas y quedaban por debajo del mínimo táctil.
|
||||
Copiar queda arriba, pegado a su confirmación, y la acción principal
|
||||
se distingue por el relleno de acento. */}
|
||||
{/* Stacked and full width: at 50% the labels ("Enviar por WhatsApp")
|
||||
wrapped onto two lines and fell below the minimum touch target.
|
||||
Copy stays on top, glued to its confirmation, and the primary action
|
||||
is told apart by the accent fill. */}
|
||||
<div className="mt-2.5 flex flex-col gap-2">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -6,21 +6,21 @@ import { useAttendeeDetail } from './AttendeeDetailProvider'
|
||||
const ITEM_CLASS =
|
||||
'flex min-h-11 w-full items-center gap-2.5 rounded-lg px-3 text-left text-sm font-medium text-primary transition-colors hover:bg-danger-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent'
|
||||
|
||||
/** Menú "⋯" de la ficha del miembro.
|
||||
/** "⋯" menu on the attendee detail page.
|
||||
*
|
||||
* Por ahora solo guarda "Quitar del grupo": el backend no tiene forma de
|
||||
* regenerar el token de ausencias, así que la opción no se muestra antes que
|
||||
* exista el endpoint (ver `apps/backend/prisma/models/domain.prisma`, campo
|
||||
* `notifyToken`). Cuando exista, es un `<button role="menuitem">` más en la
|
||||
* lista de abajo.
|
||||
* For now it only holds "Quitar del grupo": the backend has no way to
|
||||
* regenerate the absence token, so the option is not shown before that
|
||||
* endpoint exists (see `apps/backend/prisma/models/domain.prisma`, field
|
||||
* `notifyToken`). Once it does, it is one more `<button role="menuitem">` in
|
||||
* the list below.
|
||||
*
|
||||
* La etiqueta va en `text-primary` y el ícono lleva el `text-danger`: el rojo
|
||||
* de `danger` sobre blanco queda en 3.7:1 y no llega a AA para texto normal. */
|
||||
* The label goes in `text-primary` and the icon carries the `text-danger`: the
|
||||
* `danger` red on white sits at 3.7:1 and does not reach AA for normal text. */
|
||||
export function AttendeeActionsMenu({
|
||||
triggerRef,
|
||||
}: {
|
||||
/** Se lo pasa la pantalla para que el diálogo de confirmación le devuelva el
|
||||
* foco cuando se cierra. */
|
||||
/** The screen passes it in so the confirmation dialog can give focus back
|
||||
* when it closes. */
|
||||
triggerRef: RefObject<HTMLButtonElement | null>
|
||||
}) {
|
||||
const { openRemoveDialog } = useAttendeeDetail()
|
||||
|
||||
@@ -96,8 +96,8 @@ export function AttendeeAttendanceSection() {
|
||||
})}
|
||||
</ul>
|
||||
|
||||
{/* Las clases sin registro no son ausencias: se avisa aparte y en voz baja
|
||||
para que el "1 de 1" de arriba no se lea como un fallo. */}
|
||||
{/* Classes with no record are not absences: they are reported separately
|
||||
and quietly so the "1 de 1" above does not read as a failure. */}
|
||||
{summary.unmarkedLabel ? (
|
||||
<p className="px-3 pt-2 text-right text-xs text-foreground">{summary.unmarkedLabel}</p>
|
||||
) : null}
|
||||
|
||||
@@ -10,15 +10,15 @@ export function AttendeeContactActions() {
|
||||
const phone = attendee?.phone
|
||||
if (!phone) return null
|
||||
|
||||
// Los links van con los dígitos crudos: wa.me y tel: no entienden formatos.
|
||||
// The links use the raw digits: wa.me and tel: do not understand formats.
|
||||
const digits = phone.replace(/\D/g, '')
|
||||
const label = formatPhoneDisplay(phone) ?? phone
|
||||
|
||||
return (
|
||||
<div className="flex gap-2.5">
|
||||
{/* Los íconos van con `accent-fg` y no con `accent`: el azul de `accent` es
|
||||
el mismo en los dos temas y sobre `primary-soft` oscuro queda en 2.2:1.
|
||||
`accent-fg` da 6.2:1 en claro y 7.1:1 en oscuro. */}
|
||||
{/* The icons go with `accent-fg` and not with `accent`: the `accent` blue is
|
||||
the same in both themes and on dark `primary-soft` it sits at 2.2:1.
|
||||
`accent-fg` gives 6.2:1 in light and 7.1:1 in dark. */}
|
||||
<a
|
||||
href={`https://wa.me/${digits}`}
|
||||
target="_blank"
|
||||
|
||||
@@ -2,19 +2,20 @@ import { Mail } from 'lucide-react'
|
||||
import { useAttendeeDetail } from './AttendeeDetailProvider'
|
||||
import { Section } from './Section'
|
||||
|
||||
/* `px-3` interno: la banda de hover sigue a sangre hasta el borde de la sección
|
||||
(la separa del texto, no al revés) y las notas de abajo suman el mismo para
|
||||
que el email y ellas caigan en la misma columna. */
|
||||
/* Inner `px-3`: the hover band bleeds all the way to the section edge
|
||||
(it separates from the text, not the other way around) and the notes below
|
||||
add the same so the email and they land in the same column. */
|
||||
const ROW_CLASS =
|
||||
'flex w-full min-h-11 items-center justify-between gap-3 rounded-lg px-3 py-2.5 transition-colors hover:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent'
|
||||
|
||||
/** Email y notas del miembro. El teléfono no va acá: ya está en el subtítulo y
|
||||
* detrás de los botones de WhatsApp y Llamar, y repetirlo llenaba la pantalla
|
||||
* de un dato que ya estaba a la vista.
|
||||
/** The attendee's email and notes. The phone does not go here: it is already in
|
||||
* the subtitle, behind the WhatsApp and Llamar buttons, and repeating it filled
|
||||
* the screen with a value that was already in view.
|
||||
*
|
||||
* Sin datos no se dibuja la sección: no hay filas con "Sin email"/"Sin notas".
|
||||
* Aparece sola en cuanto el miembro tenga alguno (hoy el email puede llegar al
|
||||
* aprobar una preinscripción; las notas, cuando exista la edición). */
|
||||
* With no data the section is not drawn: there are no "Sin email"/"Sin notas"
|
||||
* rows. It shows up on its own as soon as the attendee has one of them (today
|
||||
* the email can arrive when approving a pre-registration; the notes, once
|
||||
* editing exists). */
|
||||
export function AttendeeContactSection() {
|
||||
const { attendee } = useAttendeeDetail()
|
||||
|
||||
|
||||
@@ -51,16 +51,16 @@ export function AttendeeDetailProvider({
|
||||
enabled: Boolean(groupId && attendeeId),
|
||||
})
|
||||
|
||||
// Misma clave que usa la pantalla de estadísticas: las dos leen el mismo
|
||||
// historial y no se pisan la caché.
|
||||
// Same key the analytics screen uses: both read the same history and do not
|
||||
// clobber each other's cache.
|
||||
const historyQuery = useQuery({
|
||||
queryKey: ['attendee-history', groupId, attendeeId],
|
||||
queryFn: () => getAttendeeHistory(groupId, attendeeId),
|
||||
enabled: Boolean(groupId && attendeeId),
|
||||
})
|
||||
|
||||
// La lista de espera solo hace falta para el diálogo de quitar, así que no se
|
||||
// pide hasta que el usuario lo abre.
|
||||
// The waitlist is only needed for the remove dialog, so it is not fetched
|
||||
// until the user opens it.
|
||||
const waitlistQuery = useQuery({
|
||||
queryKey: ['group-waitlist', groupId],
|
||||
queryFn: () => getGroupWaitlist(groupId, 1, 100),
|
||||
|
||||
@@ -28,9 +28,9 @@ export function AttendeeDetailView() {
|
||||
if (attendeeFailed || !attendee) {
|
||||
return (
|
||||
<div className="animate-fade-in rounded-2xl bg-danger-soft p-6">
|
||||
{/* El título lleva el rojo (a 18px ya cuenta como texto grande y llega a
|
||||
los 3:1) y el cuerpo usa `text-primary`: en `danger-soft` el rojo no
|
||||
pasa los 4.5:1 que necesita un `text-sm`. */}
|
||||
{/* The title carries the red (at 18px it already counts as large text and
|
||||
reaches 3:1) and the body uses `text-primary`: on `danger-soft` the red
|
||||
does not pass the 4.5:1 a `text-sm` needs. */}
|
||||
<h1 className="text-lg font-bold text-danger">Miembro no encontrado</h1>
|
||||
<p className="mt-2 text-sm text-primary">
|
||||
No se pudo cargar la información de este miembro.
|
||||
@@ -75,9 +75,9 @@ export function AttendeeDetailView() {
|
||||
<AttendeeContactActions />
|
||||
</div>
|
||||
|
||||
{/* Orden por frecuencia de uso. Sumar Pagos es insertar un bloque más
|
||||
arriba de Asistencia; cada sección lleva su propio aire, así que el
|
||||
layout no se toca. */}
|
||||
{/* Ordered by how often they are used. Adding Pagos means inserting one
|
||||
more block above Asistencia; each section brings its own spacing, so
|
||||
the layout does not need to change. */}
|
||||
<div className="mt-5">
|
||||
<AttendeeAttendanceSection />
|
||||
<AttendeeContactSection />
|
||||
|
||||
@@ -3,12 +3,12 @@ import { formatPhoneDisplay } from '../../lib/format'
|
||||
import { useAttendeeDetail } from './AttendeeDetailProvider'
|
||||
import { useCopyToClipboard } from './useCopyToClipboard'
|
||||
|
||||
/** Teléfono como segunda línea del subtítulo.
|
||||
/** The phone as the subtitle's second line.
|
||||
*
|
||||
* Vivía en una sección "Contacto" con una sola fila que repetía el número que
|
||||
* ya está a la vista detrás de los botones de WhatsApp y Llamar. Acá acompaña
|
||||
* al "Miembro desde…", se copia con un toque y tiene 44px de alto aunque el
|
||||
* texto sea de 14px: es un control, no un dato decorativo. */
|
||||
* It used to live in a "Contacto" section with a single row that repeated the
|
||||
* number already visible behind the WhatsApp and Llamar buttons. Here it sits
|
||||
* next to "Miembro desde…", copies on one tap and is 44px tall even though the
|
||||
* text is 14px: it is a control, not decorative data. */
|
||||
export function AttendeePhoneLine() {
|
||||
const { attendee } = useAttendeeDetail()
|
||||
const { copied, copy } = useCopyToClipboard()
|
||||
@@ -25,8 +25,8 @@ export function AttendeePhoneLine() {
|
||||
className="flex min-h-11 max-w-fit items-center gap-2 rounded-lg text-left transition-colors hover:bg-primary-soft active:scale-[0.98] motion-reduce:active:scale-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
|
||||
>
|
||||
<span className="truncate text-sm text-foreground">{label}</span>
|
||||
{/* `aria-hidden`: la confirmación se anuncia desde la región viva de
|
||||
abajo, así no se cuela en el nombre del botón. */}
|
||||
{/* `aria-hidden`: the confirmation is announced from the live region
|
||||
below, so it does not sneak into the button's name. */}
|
||||
{copied ? (
|
||||
<span
|
||||
aria-hidden="true"
|
||||
|
||||
@@ -10,7 +10,7 @@ type Consequence = { key: string; icon: LucideIcon; text: string }
|
||||
export function ConfirmRemoveAttendeeDialog({
|
||||
returnFocusRef,
|
||||
}: {
|
||||
/** Elemento al que vuelve el foco al cerrarse (el botón "⋯"). */
|
||||
/** The element focus returns to when it closes (the "⋯" button). */
|
||||
returnFocusRef: RefObject<HTMLButtonElement | null>
|
||||
}) {
|
||||
const {
|
||||
@@ -117,9 +117,9 @@ export function ConfirmRemoveAttendeeDialog({
|
||||
<Button variant="ghost" onClick={closeRemoveDialog} autoFocus>
|
||||
Cancelar
|
||||
</Button>
|
||||
{/* Etiqueta en negro sobre el relleno `danger`: es la única forma de
|
||||
llegar a AA con el mismo rojo en los dos temas (4.9:1 claro,
|
||||
6.7:1 oscuro); en blanco quedan 3.7:1 y 2.7:1. */}
|
||||
{/* Label in black on the `danger` fill: it is the only way to reach AA
|
||||
with the same red in both themes (4.9:1 light, 6.7:1 dark); in white
|
||||
they are 3.7:1 and 2.7:1. */}
|
||||
<Button
|
||||
onClick={() => confirmRemoveAttendee(false)}
|
||||
disabled={isSubmittingRemoval}
|
||||
@@ -138,10 +138,10 @@ export function ConfirmRemoveAttendeeDialog({
|
||||
)
|
||||
}
|
||||
|
||||
/** El `Modal` de la app no atrapa el foco; este diálogo sí, para que el Tab no
|
||||
* se vaya detrás del overlay. Solo cicla entre los controles del contenido: si
|
||||
* el foco está en otro lado (la X del `Modal`, que se sigue cerrando con
|
||||
* Escape) lo deja seguir su curso normal. */
|
||||
/** The app's `Modal` does not trap focus; this dialog does, so Tab does not walk
|
||||
* behind the overlay. It only cycles between the content's controls: if focus is
|
||||
* somewhere else (the `Modal`'s X, which still closes on Escape) it lets it
|
||||
* follow its normal course. */
|
||||
function trapTabWithin(contentRef: RefObject<HTMLDivElement | null>) {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key !== 'Tab') return
|
||||
|
||||
@@ -3,18 +3,18 @@ import type { ReactNode } from 'react'
|
||||
import { ChevronDown } from 'lucide-react'
|
||||
import { cn } from '../../lib/utils'
|
||||
|
||||
/* El gris va sin opacidad: sobre el fondo oscuro `text-foreground/50` cae a
|
||||
~2.7:1 y `/80` a ~4.2:1, los dos por debajo de AA. El token entero sí pasa. */
|
||||
/* The grey has no opacity modifier: on the dark background `text-foreground/50`
|
||||
drops to ~2.7:1 and `/80` to ~4.2:1, both below AA. The full token passes. */
|
||||
export const SECTION_TITLE_CLASS = 'text-[11px] font-semibold uppercase tracking-wide text-foreground'
|
||||
|
||||
/* La fila que despliega la sección es un botón, no un título: por eso lleva
|
||||
superficie de hover y presión, se pinta en `primary` para que se lea
|
||||
distinta de los títulos fijos, y el chevron cae al borde derecho de la fila
|
||||
en vez de pegado al texto.
|
||||
/* The row that expands the section is a button, not a heading: that is why it
|
||||
gets hover and press surfaces, it is painted in `primary` so it reads
|
||||
different from the fixed titles, and the chevron lands on the row's right edge
|
||||
instead of hugging the text.
|
||||
|
||||
El `px-3` es interno: la banda de hover sigue a sangre hasta el borde de la
|
||||
sección y lo que se separa del borde es el contenido (el `px-3` del `h2` y
|
||||
del `trailing` de abajo alinea rótulo y resumen con esta fila). */
|
||||
The `px-3` is internal: the hover band bleeds all the way to the section edge
|
||||
and it is the content that is set off from the edge (the `px-3` on the `h2`
|
||||
and on the `trailing` below align the label and the summary with this row). */
|
||||
const TOGGLE_ROW_CLASS = cn(
|
||||
SECTION_TITLE_CLASS,
|
||||
'flex min-h-11 w-full items-center justify-between gap-2 rounded-lg px-3 text-left text-primary',
|
||||
@@ -23,24 +23,24 @@ const TOGGLE_ROW_CLASS = cn(
|
||||
)
|
||||
|
||||
type SectionProps = {
|
||||
/** Título de la sección. Un string por lo general. */
|
||||
/** The section title. Usually a string. */
|
||||
title: ReactNode
|
||||
/** A la derecha del título: el resumen de asistencia, por ejemplo. */
|
||||
/** To the right of the title: the attendance summary, for example. */
|
||||
trailing?: ReactNode
|
||||
/** Cuando está, el título entero es el disparador del contenido y `title` es
|
||||
* solo su rótulo: el `<h2>` sigue siendo el encabezado de la sección y el
|
||||
* botón ocupa la fila completa. */
|
||||
/** When present, the whole title is the content's trigger and `title` is just
|
||||
* its label: the `<h2>` is still the section heading and the button takes the
|
||||
* full row. */
|
||||
toggle?: { isOpen: boolean; panelId: string; onToggle: () => void }
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
/** Bloque de sección: separador fino sobre el fondo, título chico en
|
||||
* mayúsculas y contenido sin padding propio (el de la pantalla).
|
||||
/** Section block: thin separator over the background, small uppercase title and
|
||||
* content with no padding of its own (the screen's).
|
||||
*
|
||||
* El aire vive acá y no en la pantalla: cada sección cierra con su propio
|
||||
* padding, así que el separador queda siempre a la misma distancia del
|
||||
* contenido de arriba. Sumar otra sección (Pagos, por ejemplo) es insertar
|
||||
* otro bloque y nada más. */
|
||||
* The spacing lives here and not in the screen: every section closes with its
|
||||
* own padding, so the separator always sits the same distance from the content
|
||||
* above. Adding another section (Pagos, say) means inserting one more block and
|
||||
* nothing else. */
|
||||
export function Section({ title, trailing, toggle, children }: SectionProps) {
|
||||
const headingId = useId()
|
||||
|
||||
@@ -48,9 +48,9 @@ export function Section({ title, trailing, toggle, children }: SectionProps) {
|
||||
<section aria-labelledby={headingId} className="border-t border-border/70 py-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
{toggle ? (
|
||||
// El botón vive dentro del `<h2>`: el encabezado no se pierde y el
|
||||
// disparador sigue siendo un control de verdad (Enter, Espacio y foco
|
||||
// visible por teclado).
|
||||
// The button lives inside the `<h2>`: the heading is not lost and the
|
||||
// trigger is still a real control (Enter, Space and keyboard-visible
|
||||
// focus).
|
||||
<h2 id={headingId} className="min-w-0 flex-1">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
/** Botón de acción de la pantalla (WhatsApp, Llamar, Copiar link).
|
||||
/** The screen's action button (WhatsApp, Llamar, Copiar link).
|
||||
*
|
||||
* Relleno `primary-soft`, que es la misma superficie rellena que usa el detalle
|
||||
* de grupo: un borde fino sobre `surface` en tema claro es invisible porque
|
||||
* `surface` y `background` son el mismo blanco. 44px de alto para el dedo, y
|
||||
* el mismo anillo de foco y feedback de presión que el `Button` de la app. */
|
||||
* `primary-soft` fill, which is the same filled surface the group detail uses:
|
||||
* a thin border over `surface` is invisible in the light theme because
|
||||
* `surface` and `background` are both white. 44px tall for the finger, and the
|
||||
* same focus ring and press feedback as the app's `Button`. */
|
||||
export const ACTION_BUTTON_CLASS =
|
||||
'inline-flex h-11 items-center justify-center gap-2 rounded-xl bg-primary-soft px-3 text-sm font-medium text-primary transition-colors hover:bg-accent-soft active:scale-[0.96] motion-reduce:active:scale-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent'
|
||||
|
||||
/** Acción principal de un panel (Enviar por WhatsApp). Misma superficie que el
|
||||
* `Button` `primary` de la app —relleno `accent` con texto `on-accent`, que
|
||||
* da 6.8:1 en los dos temas— pero a ancho completo porque sola en la columna:
|
||||
* al lado de la secundaria al 50% los rótulos largos se parten en dos líneas. */
|
||||
/** A panel's primary action (Enviar por WhatsApp). Same surface as the app's
|
||||
* `primary` `Button` —`accent` fill with `on-accent` text, which gives 6.8:1 in
|
||||
* both themes— but full width because it is alone in the column: next to the
|
||||
* secondary one at 50% the long labels wrap onto two lines. */
|
||||
export const PRIMARY_ACTION_CLASS =
|
||||
'inline-flex h-11 w-full items-center justify-center gap-2 rounded-xl bg-accent px-4 text-sm font-medium text-on-accent transition-colors hover:bg-accent-strong active:scale-[0.96] motion-reduce:active:scale-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import type { AttendanceHistoryItem } from '@gruperly/shared'
|
||||
|
||||
/* El endpoint de historial corta en 20 sesiones (HISTORY_SESSIONS_LIMIT en el
|
||||
backend). Es el techo real de lo que esta pantalla puede mostrar, así que
|
||||
"Ver todas" no promete más de lo que hay. */
|
||||
/* The history endpoint cuts off at 20 sessions (HISTORY_SESSIONS_LIMIT on the
|
||||
backend). It is the real ceiling on what this screen can show, so "Ver todas"
|
||||
does not promise more than there is. */
|
||||
export const HISTORY_PREVIEW = 5
|
||||
export const HISTORY_LIMIT = 20
|
||||
|
||||
@@ -29,9 +29,9 @@ export function attendanceStatusLabel(status: AttendanceSession['status']): stri
|
||||
}
|
||||
}
|
||||
|
||||
/* El estado se lee por texto e ícono, no solo por color: los tokens de estado
|
||||
están pensados como texto sobre superficies oscuras y el verde sobre blanco
|
||||
queda justo por debajo de AA, así que la fila lleva las tres señales. */
|
||||
/* The status is read through text and icon, not color alone: the status tokens
|
||||
are meant as text over dark surfaces and the green on white sits just below
|
||||
AA, so the row carries all three signals. */
|
||||
export function attendanceStatusClass(status: AttendanceSession['status']): string {
|
||||
switch (status) {
|
||||
case 'PRESENT':
|
||||
@@ -45,7 +45,7 @@ export function attendanceStatusClass(status: AttendanceSession['status']): stri
|
||||
}
|
||||
}
|
||||
|
||||
/** "28 sep 2026". Es la fecha corta de siempre: entra en una línea en móvil. */
|
||||
/** "28 sep 2026". It is the usual short date: it fits on one line on mobile. */
|
||||
export function formatMemberSince(iso: string): string {
|
||||
return new Date(iso).toLocaleDateString('es-MX', {
|
||||
day: 'numeric',
|
||||
@@ -59,9 +59,9 @@ export function classCountLabel(count: number): string {
|
||||
return count === 1 ? '1 clase' : `${count} clases`
|
||||
}
|
||||
|
||||
/** Lo que se muestra: de la más reciente a la más antigua, con las últimas
|
||||
* `HISTORY_PREVIEW` como vista previa. El endpoint devuelve el orden
|
||||
* contrario (más antigua → más reciente). */
|
||||
/** What is displayed: from the most recent to the oldest, with the last
|
||||
* `HISTORY_PREVIEW` as the preview. The endpoint returns the opposite order
|
||||
* (oldest → most recent). */
|
||||
export function visibleSessions(
|
||||
sessions: AttendanceSession[],
|
||||
showAll: boolean,
|
||||
@@ -70,26 +70,27 @@ export function visibleSessions(
|
||||
return showAll ? ordered : ordered.slice(0, HISTORY_PREVIEW)
|
||||
}
|
||||
|
||||
/** 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. */
|
||||
/** Classes with a recorded attendance: attended, was absent or was absent with
|
||||
* notice. The "Sin registrar" ones do not count: without a record there is
|
||||
* neither attendance nor absence, and putting them in the denominator made
|
||||
* "1 de 3" read as two absences. */
|
||||
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. */
|
||||
/** "1 de 1 clase", or "Sin clases registradas" if there is none with a record. */
|
||||
label: string
|
||||
/** "2 sin registrar", o `null` si no hay clases sin registro. */
|
||||
/** "2 sin registrar", or `null` if there are no classes without a record. */
|
||||
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.
|
||||
/** Summary of the rows being shown: how many classes the person recorded out of
|
||||
* how many have a record, and how many were left unmarked.
|
||||
*
|
||||
* 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. */
|
||||
* The "sin registrar" text is dimmed when there is no marked class: the summary
|
||||
* already says there is no data and the two texts would say the same thing
|
||||
* twice. */
|
||||
export function attendanceSummary(sessions: AttendanceSession[]): AttendanceSummary {
|
||||
const marked = markedSessions(sessions)
|
||||
if (marked.length === 0) return { label: 'Sin clases registradas', unmarkedLabel: null }
|
||||
|
||||
@@ -2,8 +2,9 @@ import { useEffect, useRef, useState } from 'react'
|
||||
|
||||
const FEEDBACK_MS = 1800
|
||||
|
||||
/** Copia al portapapeles y avisa en el mismo lugar donde se apretó, que es
|
||||
* donde sigue la vista: un toast encima obliga a volver a buscar el control. */
|
||||
/** Copies to the clipboard and confirms in the same spot where it was pressed,
|
||||
* which is where the eye already is: a toast on top forces the view to hunt for
|
||||
* the control again. */
|
||||
export function useCopyToClipboard() {
|
||||
const [copied, setCopied] = useState(false)
|
||||
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
@@ -24,8 +25,8 @@ export function useCopyToClipboard() {
|
||||
if (timeoutRef.current) clearTimeout(timeoutRef.current)
|
||||
timeoutRef.current = setTimeout(() => setCopied(false), FEEDBACK_MS)
|
||||
})
|
||||
// Si el navegador rechaza la escritura no hay nada que confirmar: se
|
||||
// deja el control como estaba en vez de dejar la promesa sin manejar.
|
||||
// If the browser rejects the write there is nothing to confirm: the control
|
||||
// is left as it was instead of leaving the promise unhandled.
|
||||
.catch(() => setCopied(false))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user