Compare commits

2 Commits

12 changed files with 498 additions and 246 deletions

View File

@@ -0,0 +1,97 @@
# Gruperly — sistema de interfaz (apps/web)
Aplicado en el rediseño de `/groups/$groupId` (sept 2026). Fuente de verdad de tokens:
`apps/web/src/index.css` (`@theme`). Ojo: `stack.md` trae tokens viejos (accent `#1e90ff`);
el accent real es **`#2544ea`**.
## Dirección y sensación
Herramienta diaria de un profesor/organizador que abre la pantalla para responder tres
preguntas: ¿quién está? ¿quién falta? ¿qué cobro?. Sensación: **calma operativa** — densa
pero escaneable, nada grita salvo lo que requiere decisión. Tema oscuro slate + un solo
accent azul; copy en español, verbos en infinitivo.
## Profundidad y espaciado
- **Estrategia de depth**: cambios de superficie + bordes de baja opacidad. Sombras solo
`shadow-xs` en tarjetas/paneles. Nada de drop shadows marcados.
- **Unidad base 4px.** Densidad: padding de componente 8–16px, separación entre bloques
`space-y-5 sm:space-y-6` (20/24px).
- **Radius**: default `rounded-xl` (0.75rem). Concéntrico: contenedor `rounded-2xl` (16px) +
padding 8px → interior `rounded-lg` (8px). Chips y pills: `rounded-full`.
## Jerarquía tipográfica (ratio ~1.25)
| nivel | valor | uso |
| --- | --- | --- |
| label | 11px semibold uppercase `tracking-wide` `text-foreground/70` | títulos de celda/sección |
| body | 14px (`text-sm`) `text-foreground/80` | descripciones, filas |
| value | 16px semibold `text-primary` (`text-base`) | dato principal de una celda |
| hero | 24px semibold `tracking-tight` `tabular-nums` | **solo uno por bloque** (hoy: el cupo `1/4`) |
| micro | 10–12px | pills de conteo (`text-[10px] font-bold`), captions |
- Cuatro niveles de color de texto: `text-primary` → `text-foreground` → `/70` → `/50`.
- **Todo dato numérico lleva `tabular-nums`** (contadores, teléfonos, precios, fechas).
## Patrón focal
**Un punto focal por bloque y por estado.** La tarjeta de info manda con el cupo; el header
de grupo no tiene ningún `primary` (las tres acciones son `outline`) y el `primary` vive en
el empty state de la vista que lo explica. Así nunca hay dos elementos azules compitiendo.
## Componentes (valores exactos)
### Chip de sección — `detail/SectionChips.tsx`
- Contenedor: `flex w-full flex-wrap items-center gap-2` + `role="group"` (no tablist).
- Chip: `min-h-10 rounded-full border px-3 text-xs font-semibold gap-1.5`,
activo `border-transparent bg-accent text-on-accent shadow-xs`,
inactivo `border-border bg-surface text-foreground/80 hover:border-accent/40 hover:bg-primary-soft hover:text-primary`,
focus `ring-2 ring-accent ring-offset-2 ring-offset-primary-soft`.
- Pill de conteo: `px-1.5 py-0.5 text-[10px] font-bold leading-none tabular-nums`;
**oculto si el conteo es 0**; atención `bg-warning-soft text-warning`;
neutro `bg-primary-soft text-foreground/60`; sobre chip activo `bg-on-accent/25 text-on-accent`.
- `aria-pressed` en cada chip. Envuelve en 1–3 filas según ancho: nunca recorta.
### Acciones de cabecera — `detail/GroupHeader.tsx`
- `variant="outline"` con icono `text-accent`; `md` (`h-10 px-4`). `primary` solo en empty states.
- Móvil: `grid grid-cols-2 gap-2.5` (tercera acción `col-span-2`); `sm+`: `flex justify-end`.
- Badges de estado: `rounded-full px-2.5 py-0.5 text-[11px]` + punto `size-1.5`.
### Tarjeta de info — `detail/GroupInfoCard.tsx`
- Contenedor: `rounded-2xl bg-primary-soft p-4 sm:p-5` + `divide-y divide-border/70` en móvil,
`md:grid md:grid-cols-3 md:divide-x md:divide-y-0`.
- Celda: `flex items-start gap-3 py-3 first:pt-0 last:pb-0 md:py-0` + `md:pr-6` / `md:px-6` / `md:pl-6`.
- Barra de cupo: `h-1.5 max-w-[9rem] rounded-full bg-accent/15`, fill `bg-accent`
(o `bg-warning` si `total >= capacity`), `transition-[width] duration-300 ease-out`,
con `role="progressbar"` + `aria-valuetext`.
### Sección de listados — `detail/MembersWaitlistSection.tsx`
- Externo `rounded-2xl bg-primary-soft p-2`; interno `space-y-2 p-2 sm:p-3`.
- Panel de contenido: `rounded-lg bg-surface p-1 shadow-xs sm:p-2`.
- Fila header: chips + buscador (`sm:w-72 lg:shrink-0`), apilados hasta `lg`.
- Sub-encabezado de sección apilada (`PendingView.tsx`):
`flex items-center gap-2 border-b border-border/70 px-3 pb-2 pt-3`,
título label 11px, pill a la derecha con `ml-auto`; tabla envuelta en `pt-1`.
### Empty state
`rounded-lg bg-primary-soft/50 px-4 py-10 text-center` · icono `size-10 text-foreground/40` ·
título `text-sm font-semibold text-primary` · cuerpo `max-w-sm text-sm text-foreground/80` ·
acciones: **una** `primary` + el resto `outline`.
### Tablas — `detail/*Table.tsx`
`table-fixed text-sm` · nombre `w-[48%]` · chevron `w-9` · filas `px-3 py-2.5`
con `border-b border-border/70 last:border-b-0 hover:bg-primary-soft/60` ·
avatar `size-9 rounded-full bg-accent/10 text-xs font-semibold text-accent` ·
columnas secundarias con `hidden sm:table-cell` (en móvil manda el teléfono).
### Botón — `components/ui/button.tsx`
`rounded-xl font-medium h-10 px-4 text-sm` · `active:scale-[0.96] motion-reduce:active:scale-100` ·
focus `ring-2 ring-accent` · variantes `primary` (`bg-accent`/`hover:bg-accent-strong`),
`outline`, `ghost`.
## Convenciones que sostienen el sistema
- Sin Radix/shadcn instalado: primitivos propios en `components/ui/` + `cn()` (clsx + tailwind-merge).
- Sin botón "volver" en mobile: `hidden lg:inline-flex`.
- Elementos fijos abajo: `env(safe-area-inset-bottom)` en el padding.
- Los controles nuevos deben pasar el squint test: si dos cosas brillan, sobra una.

View File

@@ -24,7 +24,7 @@ import {
} from '../../../lib/api'
import { useRemoveAttendee } from './useRemoveAttendee'
export type ListSection = 'members' | 'preregistrations' | 'waitlist'
export type ListSection = 'members' | 'pending'
type GroupDetailContextValue = {
groupId: string
@@ -83,12 +83,19 @@ export function GroupDetailProvider({ groupId, children }: { groupId: string; ch
const toast = useToast()
const [isInviteModalOpen, setIsInviteModalOpen] = useState(false)
const [listSection, setListSection] = useState<ListSection>('members')
const [listSection, setListSectionState] = useState<ListSection>('members')
const [attendeeToRemove, setAttendeeToRemove] = useState<AttendeeDto | null>(null)
const [selectedWaitlistEntry, setSelectedWaitlistEntry] = useState<GroupWaitlistEntryDto | null>(null)
const [selectedPreRegistration, setSelectedPreRegistration] = useState<GroupPreRegistrationDto | null>(null)
const [searchFilter, setSearchFilter] = useState('')
// La búsqueda pertenece a la vista que la abrió: al cambiar de pestaña se
// limpia para no heredar un filtro sin coincidencias.
const setListSection = (value: ListSection) => {
setListSectionState(value)
setSearchFilter('')
}
const groupQuery = useQuery({
queryKey: ['group', groupId],
queryFn: () => getGroup(groupId),

View File

@@ -71,14 +71,17 @@ export function GroupHeader() {
Compartir <span className="hidden sm:inline">Link</span>
</span>
</Button>
{/* Acciones de nivel secundario: con miembros en el grupo el foco es el
listado, no el botón. El `primary` de "Agregar" vive en el empty
state, que es donde la acción necesita explicarse. */}
<Button
variant="primary"
variant="outline"
onClick={() =>
void navigate({ to: '/groups/$groupId/attendees/new', params: { groupId } })
}
className="col-span-2 w-full justify-center sm:w-auto"
>
<UserPlus className="size-4" />
<UserPlus className="size-4 text-accent" />
<span>
Agregar <span className="hidden sm:inline">Miembros</span>
</span>

View File

@@ -1,51 +1,103 @@
import { CalendarClock, Users } from 'lucide-react'
import { BILLING_LABELS, formatPrice, formatSchedule } from '../../../lib/format'
import {
formatBillingMeta,
formatPrice,
WEEK_DAY_FULL_LABELS,
} from '../../../lib/format'
import { cn } from '../../../lib/utils'
import { useGroupDetail } from './GroupDetailProvider'
/* Escala de la tarjeta: label 11 (etiqueta) · valor 16 (dato) · hero 24
(cupo). El cupo es lo único que se escanea de un vistazo, por eso es el
único que sube de nivel; el resto se lee en línea. */
const LABEL_CLASS = 'text-[11px] font-semibold uppercase tracking-wide text-foreground/70'
const CELL_CLASS = 'flex items-start gap-3 py-3 first:pt-0 last:pb-0 md:py-0'
export function GroupInfoCard() {
const { group, attendees, waitlistTotal } = useGroupDetail()
const { group, attendeesTotal, attendeesPending, waitlistTotal } = useGroupDetail()
if (!group) return null
const daysLabel = (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
const occupancy = capacity ? Math.min(attendeesTotal / capacity, 1) : 0
const billingMeta = formatBillingMeta(group.billingType, group.dueDay)
const capacityMeta = !capacity
? 'Sin cupo definido'
: isFull
? 'Cupo completo'
: `${freeSpots} ${freeSpots === 1 ? 'lugar libre' : 'lugares libres'}`
const waitlistMeta = waitlistTotal > 0 ? ` · ${waitlistTotal} en espera` : ''
return (
<div className="grid grid-cols-1 gap-x-6 gap-y-4 rounded-2xl bg-primary-soft p-4 sm:p-5 md:grid-cols-3 md:gap-x-0 md:divide-x md:divide-border/70">
<div className="flex items-start gap-3 md:pr-6">
<div className="divide-y divide-border/70 rounded-2xl bg-primary-soft p-4 sm:p-5 md:grid md:grid-cols-3 md:divide-x md:divide-y-0">
<div className={cn(CELL_CLASS, 'md:pr-6')}>
<CalendarClock className="mt-0.5 size-5 shrink-0 text-accent" />
<div className="min-w-0">
<p className="text-[11px] font-semibold uppercase tracking-wide text-foreground/80">
Horario
</p>
<p className="mt-0.5 text-sm font-semibold text-primary">
{(group.days?.length ?? 0) > 0
? formatSchedule(group.days ?? [], group.time)
: 'Sin horario definido'}
<div className="min-w-0 flex-1">
<p className={LABEL_CLASS}>Horario</p>
<p className="mt-1 text-base font-semibold leading-snug text-primary">
{daysLabel || 'Sin horario definido'}
</p>
{daysLabel && group.time ? (
<p className="mt-0.5 text-sm tabular-nums text-foreground">{group.time}</p>
) : null}
</div>
</div>
<div className="flex items-start gap-3 md:px-6">
<div className={cn(CELL_CLASS, 'md:px-6')}>
<Users className="mt-0.5 size-5 shrink-0 text-accent" />
<div className="min-w-0">
<p className="text-[11px] font-semibold uppercase tracking-wide text-foreground/80">
Miembros &amp; Cupo
</p>
<p className="mt-0.5 text-sm font-semibold tabular-nums text-primary">
{attendees.length} inscritos {waitlistTotal > 0 ? ` · ${waitlistTotal} en espera` : ''}
{group.capacity ? ` · Cupo de ${group.capacity}` : ''}
<div className="min-w-0 flex-1">
<p className={LABEL_CLASS}>Miembros &amp; Cupo</p>
<p className="mt-1 flex items-baseline text-2xl font-semibold leading-none tracking-tight tabular-nums text-primary">
<span>{attendeesPending ? '—' : attendeesTotal}</span>
{capacity ? (
<span className="text-base font-medium text-foreground/70">/{capacity}</span>
) : null}
</p>
{capacity ? (
<div
role="progressbar"
aria-label="Ocupación del cupo"
aria-valuemin={0}
aria-valuemax={capacity}
aria-valuenow={attendeesPending ? 0 : attendeesTotal}
aria-valuetext={`${attendeesTotal} de ${capacity}`}
className="mt-2 h-1.5 w-full max-w-[9rem] overflow-hidden rounded-full bg-accent/15"
>
<div
className={cn(
'h-full rounded-full transition-[width] duration-300 ease-out',
isFull ? 'bg-warning' : 'bg-accent',
)}
style={{ width: `${Math.round(occupancy * 100)}%` }}
/>
</div>
) : null}
{!attendeesPending ? (
<p className={cn('mt-1.5 text-sm', isFull ? 'text-warning' : 'text-foreground')}>
{capacityMeta}
{waitlistMeta}
</p>
) : null}
</div>
</div>
<div className="flex items-start gap-3 md:pl-6">
<div className={cn(CELL_CLASS, 'md:pl-6')}>
<div className="mt-0.5 flex size-5 shrink-0 items-center justify-center text-sm font-bold leading-none text-accent">
$
</div>
<div className="min-w-0">
<p className="text-[11px] font-semibold uppercase tracking-wide text-foreground/80">Cobro</p>
<p className="mt-0.5 text-sm font-semibold tabular-nums text-primary">
<div className="min-w-0 flex-1">
<p className={LABEL_CLASS}>Cobro</p>
<p className="mt-1 text-base font-semibold tabular-nums text-primary">
{group.price != null ? formatPrice(group.price) : 'Sin precio'}
{group.billingType ? ` · ${BILLING_LABELS[group.billingType]}` : ''}
{group.dueDay ? ` · Vence día ${group.dueDay}` : ''}
</p>
{billingMeta && group.price != null ? (
<p className="mt-0.5 text-sm text-foreground">{billingMeta}</p>
) : null}
</div>
</div>
</div>

View File

@@ -15,7 +15,7 @@ export function MembersTable({ attendees }: { attendees: AttendeeDto[] }) {
<table className="w-full table-fixed text-left text-sm">
<thead>
<tr className="border-b border-border/70 text-xs font-semibold text-foreground/80">
<th scope="col" className="w-[54%] px-3 pb-2">Nombre</th>
<th scope="col" className="w-[48%] px-3 pb-2">Nombre</th>
<th scope="col" className="px-3 pb-2">Teléfono</th>
<th scope="col" className="w-9 px-1 pb-2">
<span className="sr-only">Detalle</span>

View File

@@ -0,0 +1,69 @@
import { useNavigate } from '@tanstack/react-router'
import { Loader2, Plus, Share2, Users } from 'lucide-react'
import { Button } from '../../../components/ui'
import { useGroupDetail } from './GroupDetailProvider'
import { MembersTable } from './MembersTable'
export function MembersView() {
const { groupId, attendees, attendeesPending, searchFilter, openInviteModal } = useGroupDetail()
const navigate = useNavigate()
const query = searchFilter.trim().toLowerCase()
const filtered = query
? attendees.filter(
(a) =>
a.fullName.toLowerCase().includes(query) ||
(a.phone && a.phone.includes(query)) ||
(a.email && a.email.toLowerCase().includes(query)),
)
: attendees
if (attendeesPending) {
return (
<div className="flex items-center justify-center py-12">
<Loader2 className="size-6 animate-spin text-accent" />
</div>
)
}
if (attendees.length === 0) {
return (
<div className="rounded-lg bg-primary-soft/50 px-4 py-10 text-center">
<Users className="mx-auto mb-2 size-10 text-foreground/40" />
<p className="text-sm font-semibold text-primary">
Todavía no hay miembros en este grupo
</p>
<p className="mx-auto mt-1 max-w-sm text-sm text-foreground/80">
Puedes compartir el enlace de invitación único o agregar miembros de forma manual o
masiva.
</p>
<div className="mt-4 flex flex-col gap-2.5 sm:flex-row sm:items-center sm:justify-center sm:gap-3">
<Button variant="outline" onClick={openInviteModal} className="w-full sm:w-auto">
<Share2 className="size-4" />
Compartir Enlace
</Button>
<Button
variant="primary"
onClick={() =>
void navigate({ to: '/groups/$groupId/attendees/new', params: { groupId } })
}
className="w-full sm:w-auto"
>
<Plus className="size-4" />
Agregar Miembros
</Button>
</div>
</div>
)
}
if (filtered.length === 0) {
return (
<div className="py-8 text-center text-sm text-foreground/80">
No se encontraron miembros que coincidan con la búsqueda.
</div>
)
}
return <MembersTable attendees={filtered} />
}

View File

@@ -1,39 +1,12 @@
import { useNavigate } from '@tanstack/react-router'
import { Clock, Loader2, Plus, Search, Share2, UserCheck, Users } from 'lucide-react'
import { Button, Input } from '../../../components/ui'
import { cn } from '../../../lib/utils'
import { Search } from 'lucide-react'
import { Input } from '../../../components/ui'
import { useGroupDetail } from './GroupDetailProvider'
import { MembersTable } from './MembersTable'
import { PreRegistrationsTable } from './PreRegistrationsTable'
import { WaitlistTable } from './WaitlistTable'
const TAB_CLASS =
'flex min-h-10 flex-1 items-center justify-center gap-1.5 rounded-md px-2 text-xs font-semibold transition-[color,background-color,box-shadow] duration-150'
import { MembersView } from './MembersView'
import { PendingView } from './PendingView'
import { SectionChips } from './SectionChips'
export function MembersWaitlistSection() {
const {
groupId, attendees, attendeesTotal, attendeesPending,
waitlistEntries, waitlistTotal, waitlistPending,
preRegistrations, preRegistrationsTotal, preRegistrationsPending,
listSection, setListSection, searchFilter, setSearchFilter, openInviteModal,
} = useGroupDetail()
const navigate = useNavigate()
const query = searchFilter.toLowerCase()
const filteredAttendees = attendees.filter(
(a) =>
a.fullName.toLowerCase().includes(query) ||
(a.phone && a.phone.includes(query)) ||
(a.email && a.email.toLowerCase().includes(query)),
)
const filteredPreRegistrations = preRegistrations.filter(
(p) =>
p.fullName.toLowerCase().includes(query) ||
p.phone.includes(query) ||
(p.email && p.email.toLowerCase().includes(query)),
)
const showSearch = listSection === 'members' || listSection === 'preregistrations'
const { listSection, searchFilter, setSearchFilter } = useGroupDetail()
return (
// Radios concéntricos: `rounded-2xl` (16px) con `p-2` (8px) deja a las
@@ -41,195 +14,30 @@ export function MembersWaitlistSection() {
// Sin bordes: el lavado `bg-primary-soft` separa la sección del fondo.
<div className="rounded-2xl bg-primary-soft p-2">
<div className="space-y-2 p-2 sm:p-3">
<div className="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3">
<div
role="tablist"
aria-label="Listado del grupo"
className="flex w-full items-center gap-1 rounded-lg bg-surface p-0.5 shadow-xs sm:w-[36rem]"
>
<button
type="button"
role="tab"
aria-selected={listSection === 'members'}
onClick={() => setListSection('members')}
className={cn(
TAB_CLASS,
listSection === 'members'
? 'bg-accent text-on-accent shadow-xs'
: 'text-foreground/80 hover:bg-primary-soft hover:text-primary',
)}
>
<Users className="size-4 shrink-0" />
<span className="whitespace-nowrap">
Miembros ({attendeesTotal})
</span>
</button>
<button
type="button"
role="tab"
aria-selected={listSection === 'preregistrations'}
onClick={() => setListSection('preregistrations')}
className={cn(
TAB_CLASS,
listSection === 'preregistrations'
? 'bg-accent text-on-accent shadow-xs'
: 'text-foreground/80 hover:bg-primary-soft hover:text-primary',
)}
>
<UserCheck className="size-4 shrink-0" />
<span className="whitespace-nowrap">
Pre-inscripciones ({preRegistrationsTotal})
</span>
</button>
<button
type="button"
role="tab"
aria-selected={listSection === 'waitlist'}
onClick={() => setListSection('waitlist')}
className={cn(
TAB_CLASS,
listSection === 'waitlist'
? 'bg-accent text-on-accent shadow-xs'
: 'text-foreground/80 hover:bg-primary-soft hover:text-primary',
)}
>
<Clock className="size-4 shrink-0" />
<span className="whitespace-nowrap">Lista de espera ({waitlistTotal})</span>
</button>
</div>
<div className="flex flex-col gap-2.5 lg:flex-row lg:items-center lg:justify-between">
<SectionChips />
{showSearch ? (
<div className="relative w-full sm:w-64">
<Search className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-foreground/70" />
<Input
placeholder="Buscar por nombre o teléfono..."
value={searchFilter}
onChange={(e) => setSearchFilter(e.target.value)}
aria-label="Buscar en el listado"
className="h-10 rounded-lg border-transparent pl-9 shadow-xs placeholder:text-foreground/80"
/>
</div>
) : null}
<div className="relative w-full sm:w-72 lg:shrink-0">
<Search className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-foreground/70" />
<Input
placeholder="Buscar por nombre o teléfono..."
value={searchFilter}
onChange={(e) => setSearchFilter(e.target.value)}
aria-label="Buscar en el listado"
className="h-10 rounded-lg border-transparent pl-9 shadow-xs placeholder:text-foreground/80"
/>
</div>
</div>
<p className="text-xs leading-relaxed text-foreground/80">
{listSection === 'members'
? 'Listado de todos los miembros incorporados al grupo.'
: listSection === 'preregistrations'
? 'Personas que se inscribieron a través del enlace compartido. Al aprobar, entran al grupo; si el grupo está lleno, pasan a la lista de espera.'
: 'Personas que esperan un cupo libre en el grupo. Al pasar a alguien al grupo, se crea automáticamente su registro como miembro.'}
: 'Pre-inscripciones que esperan tu aprobación y personas en lista de espera por un cupo libre.'}
</p>
</div>
<div className="rounded-lg bg-surface p-1 shadow-xs sm:p-2">
{listSection === 'members' ? (
<>
{attendeesPending ? (
<div className="flex items-center justify-center py-12">
<Loader2 className="size-6 animate-spin text-accent" />
</div>
) : null}
{!attendeesPending && attendees.length === 0 ? (
<div className="rounded-lg bg-primary-soft/50 px-4 py-10 text-center">
<Users className="mx-auto mb-2 size-10 text-foreground/40" />
<p className="text-sm font-semibold text-primary">
Todavía no hay miembros en este grupo
</p>
<p className="mx-auto mt-1 max-w-sm text-sm text-foreground/80">
Puedes compartir el enlace de invitación único o agregar miembros de forma manual o
masiva.
</p>
<div className="mt-4 flex flex-col gap-2.5 sm:flex-row sm:items-center sm:justify-center sm:gap-3">
<Button variant="outline" onClick={openInviteModal} className="w-full sm:w-auto">
<Share2 className="size-4" />
Compartir Enlace
</Button>
<Button
variant="primary"
onClick={() =>
void navigate({ to: '/groups/$groupId/attendees/new', params: { groupId } })
}
className="w-full sm:w-auto"
>
<Plus className="size-4" />
Agregar Miembros
</Button>
</div>
</div>
) : null}
{attendees.length > 0 && filteredAttendees.length === 0 ? (
<div className="py-8 text-center text-sm text-foreground/80">
No se encontraron miembros que coincidan con la búsqueda.
</div>
) : null}
{filteredAttendees.length > 0 ? <MembersTable attendees={filteredAttendees} /> : null}
</>
) : null}
{listSection === 'preregistrations' ? (
<div className="space-y-4">
{preRegistrationsPending ? (
<div className="flex items-center justify-center py-12">
<Loader2 className="size-6 animate-spin text-accent" />
</div>
) : null}
{!preRegistrationsPending && preRegistrations.length === 0 ? (
<div className="rounded-lg bg-primary-soft/50 px-4 py-10 text-center">
<UserCheck className="mx-auto mb-2 size-10 text-foreground/40" />
<p className="text-sm font-semibold text-primary">
No hay pre-inscripciones pendientes
</p>
<p className="mx-auto mt-1 max-w-sm text-sm text-foreground/80">
Cuando alguien se inscriba a través del enlace compartido, aparecerá aquí para que
revises y apruebes su lugar.
</p>
<div className="mt-4 flex justify-center">
<Button variant="outline" onClick={openInviteModal} className="w-full sm:w-auto">
<Share2 className="size-4" />
Compartir Enlace
</Button>
</div>
</div>
) : null}
{preRegistrations.length > 0 && filteredPreRegistrations.length === 0 ? (
<div className="py-8 text-center text-sm text-foreground/80">
No se encontraron pre-inscripciones que coincidan con la búsqueda.
</div>
) : null}
{filteredPreRegistrations.length > 0 ? (
<PreRegistrationsTable entries={filteredPreRegistrations} />
) : null}
</div>
) : null}
{listSection === 'waitlist' ? (
<div className="space-y-4">
{waitlistPending ? (
<div className="flex items-center justify-center py-12">
<Loader2 className="size-6 animate-spin text-accent" />
</div>
) : null}
{!waitlistPending && waitlistEntries.length === 0 ? (
<div className="rounded-lg bg-primary-soft/50 px-4 py-10 text-center">
<Clock className="mx-auto mb-2 size-10 text-foreground/40" />
<p className="text-sm font-semibold text-primary">No hay nadie en la lista de espera</p>
<p className="mx-auto mt-1 max-w-sm text-sm text-foreground/80">
Cuando el grupo alcance su cupo, las personas podrán sumarse a la espera y podrás
pasarlas al grupo desde aquí.
</p>
</div>
) : null}
{waitlistEntries.length > 0 ? <WaitlistTable entries={waitlistEntries} /> : null}
</div>
) : null}
{listSection === 'members' ? <MembersView /> : <PendingView />}
</div>
</div>
)

View File

@@ -0,0 +1,125 @@
import { Clock, Inbox, Loader2, Share2, UserCheck } from 'lucide-react'
import { Button } from '../../../components/ui'
import { cn } from '../../../lib/utils'
import { useGroupDetail } from './GroupDetailProvider'
import { PreRegistrationsTable } from './PreRegistrationsTable'
import { WaitlistTable } from './WaitlistTable'
export function PendingView() {
const {
preRegistrations,
preRegistrationsPending,
waitlistEntries,
waitlistPending,
searchFilter,
openInviteModal,
} = useGroupDetail()
const query = searchFilter.trim().toLowerCase()
const matches = (fullName: string, phone: string | null | undefined, email?: string | null) =>
!query ||
fullName.toLowerCase().includes(query) ||
(phone != null && phone.includes(query)) ||
(email != null && email.toLowerCase().includes(query))
const filteredPrereg = preRegistrations.filter((p) => matches(p.fullName, p.phone, p.email))
const filteredWaitlist = waitlistEntries.filter((w) => matches(w.fullName, w.phone))
if (preRegistrationsPending || waitlistPending) {
return (
<div className="flex items-center justify-center py-12">
<Loader2 className="size-6 animate-spin text-accent" />
</div>
)
}
const hasAnyEntry = preRegistrations.length > 0 || waitlistEntries.length > 0
if (!hasAnyEntry && !query) {
return (
<div className="rounded-lg bg-primary-soft/50 px-4 py-10 text-center">
<Inbox className="mx-auto mb-2 size-10 text-foreground/40" />
<p className="text-sm font-semibold text-primary">No hay pendientes</p>
<p className="mx-auto mt-1 max-w-sm text-sm text-foreground/80">
Las pre-inscripciones que lleguen por el enlace compartido y las personas en lista de
espera aparecerán aquí para que las revises.
</p>
<div className="mt-4 flex justify-center">
<Button variant="primary" onClick={openInviteModal} className="w-full sm:w-auto">
<Share2 className="size-4" />
Compartir Enlace
</Button>
</div>
</div>
)
}
if (filteredPrereg.length === 0 && filteredWaitlist.length === 0) {
return (
<div className="py-8 text-center text-sm text-foreground/80">
No se encontraron pendientes que coincidan con la búsqueda.
</div>
)
}
const sections = [
{
key: 'preregistrations',
title: 'Pre-inscripciones',
icon: UserCheck,
attention: true,
count: filteredPrereg.length,
emptyNote: 'Sin pre-inscripciones pendientes.',
table: <PreRegistrationsTable entries={filteredPrereg} />,
},
{
key: 'waitlist',
title: 'Lista de espera',
icon: Clock,
attention: false,
count: filteredWaitlist.length,
emptyNote: 'Sin nadie en la lista de espera.',
table: <WaitlistTable entries={filteredWaitlist} />,
},
]
return (
<div className="space-y-1">
{sections.map((section) => {
const Icon = section.icon
const hasRows = section.count > 0
// Con búsqueda activa, las secciones sin coincidencias se ocultan.
if (!hasRows && query) return null
return (
<section key={section.key}>
<div className="flex items-center gap-2 border-b border-border/70 px-3 pb-2 pt-3">
<Icon className="size-4 shrink-0 text-accent" />
<h3 className="text-xs font-semibold uppercase tracking-wide text-foreground/70">
{section.title}
</h3>
{hasRows ? (
<span
className={cn(
'ml-auto inline-flex items-center justify-center rounded-full px-1.5 py-0.5 text-[10px] font-bold leading-none tabular-nums',
section.attention
? 'bg-warning-soft text-warning'
: 'bg-primary-soft text-foreground/60',
)}
>
{section.count}
</span>
) : null}
</div>
{hasRows ? (
<div className="pt-1">{section.table}</div>
) : (
<p className="px-3 py-3 text-xs text-foreground/70">{section.emptyNote}</p>
)}
</section>
)
})}
</div>
)
}

View File

@@ -11,7 +11,8 @@ export function PreRegistrationsTable({ entries }: { entries: GroupPreRegistrati
<tr className="border-b border-border/70 text-xs font-semibold text-foreground/80">
<th scope="col" className="w-[46%] px-3 pb-2">Nombre</th>
<th scope="col" className="px-3 pb-2">Teléfono</th>
<th scope="col" className="px-3 pb-2">Solicitado</th>
{/* En móvil el teléfono manda: la fecha vive en el detalle. */}
<th scope="col" className="hidden px-3 pb-2 sm:table-cell">Solicitado</th>
<th scope="col" className="w-9 px-1 pb-2">
<span className="sr-only">Detalle</span>
</th>
@@ -46,7 +47,7 @@ export function PreRegistrationsTable({ entries }: { entries: GroupPreRegistrati
{entry.phone}
</span>
</td>
<td className="min-w-0 px-3 py-2.5 text-xs text-foreground/70">
<td className="hidden min-w-0 px-3 py-2.5 text-xs text-foreground/70 sm:table-cell">
{new Date(entry.createdAt).toLocaleDateString('es-ES', {
day: 'numeric',
month: 'short',

View File

@@ -0,0 +1,77 @@
import { Inbox, Users } from 'lucide-react'
import { cn } from '../../../lib/utils'
import { type ListSection, useGroupDetail } from './GroupDetailProvider'
const SECTIONS = [
{ id: 'members', label: 'Miembros', icon: Users },
{ id: 'pending', label: 'Pendientes', icon: Inbox },
] as const satisfies ReadonlyArray<{
id: ListSection
label: string
icon: typeof Users
}>
export function SectionChips() {
const {
listSection,
setListSection,
attendeesTotal,
preRegistrationsTotal,
waitlistTotal,
} = useGroupDetail()
const counts: Record<ListSection, number> = {
members: attendeesTotal,
pending: preRegistrationsTotal + waitlistTotal,
}
return (
<div
role="group"
aria-label="Listado del grupo"
className="flex w-full flex-wrap items-center gap-2"
>
{SECTIONS.map((section) => {
const isActive = listSection === section.id
const count = counts[section.id]
// Ámbar solo cuando hay algo que decidir: pre-inscripciones por revisar.
const isAttention = section.id === 'pending' && preRegistrationsTotal > 0
const Icon = section.icon
return (
<button
key={section.id}
type="button"
aria-pressed={isActive}
onClick={() => setListSection(section.id)}
className={cn(
'inline-flex min-h-10 items-center gap-1.5 rounded-full border px-3 text-xs font-semibold',
'transition-[background-color,color,border-color,box-shadow] duration-150',
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-primary-soft',
isActive
? 'border-transparent bg-accent text-on-accent shadow-xs'
: 'border-border bg-surface text-foreground/80 hover:border-accent/40 hover:bg-primary-soft hover:text-primary',
)}
>
<Icon className="size-3.5 shrink-0" />
<span className="whitespace-nowrap">{section.label}</span>
{count > 0 ? (
<span
className={cn(
'inline-flex items-center justify-center rounded-full px-1.5 py-0.5 text-[10px] font-bold leading-none tabular-nums',
isActive
? 'bg-on-accent/25 text-on-accent'
: isAttention
? 'bg-warning-soft text-warning'
: 'bg-primary-soft text-foreground/60',
)}
>
{count}
</span>
) : null}
</button>
)
})}
</div>
)
}

View File

@@ -9,7 +9,7 @@ export function WaitlistTable({ entries }: { entries: GroupWaitlistEntryDto[] })
<table className="w-full table-fixed text-left text-sm">
<thead>
<tr className="border-b border-border/70 text-xs font-semibold text-foreground/80">
<th scope="col" className="w-[54%] px-3 pb-2">Nombre</th>
<th scope="col" className="w-[48%] px-3 pb-2">Nombre</th>
<th scope="col" className="px-3 pb-2">Teléfono</th>
<th scope="col" className="w-9 px-1 pb-2">
<span className="sr-only">Detalle</span>

View File

@@ -52,4 +52,17 @@ export function formatSchedule(days: readonly WeekDay[], time: string | null): s
export function formatPrice(price: number | null): string {
if (price == null) return '—'
return price.toLocaleString('es-MX', { style: 'currency', currency: 'MXN' })
}
// El vencimiento se cuenta como frase ("Vence el día 10 de cada mes") en vez
// de "Vence día 10": se lee como una promesa, no como un dato suelto.
export function formatBillingMeta(
billingType: BillingType | null,
dueDay: number | null,
): string | null {
if (billingType === 'PER_CLASS') return BILLING_LABELS.PER_CLASS
if (billingType === 'MONTHLY') {
return dueDay ? `Vence el día ${dueDay} de cada mes` : BILLING_LABELS.MONTHLY
}
return null
}