feat: implement group pre-registration feature with approval and rejection workflows

- Add API endpoints for managing group pre-registrations, including approval and rejection.
- Create database migration for `group_pre_registrations` table and associated enum for status.
- Implement use cases for listing, approving, and rejecting pre-registrations.
- Add frontend components for displaying pre-registration details and managing approvals/rejections.
- Update shared schemas to include pre-registration data structures and validation.
- Remove obsolete `WaitlistNoticeCard` component and replace with `PreRegistrationNoticeCard`.
This commit is contained in:
Jose Selesan
2026-09-29 15:25:24 -03:00
parent 0f02331dfc
commit 45a1f50231
32 changed files with 1335 additions and 165 deletions

View File

@@ -1,15 +1,20 @@
import { useNavigate } from '@tanstack/react-router'
import { Clock, Loader2, Plus, Search, Share2, Users } from 'lucide-react'
import { Clock, Loader2, Plus, Search, Share2, UserCheck, Users } from 'lucide-react'
import { Button, Input } from '../../../components/ui'
import { cn } from '../../../lib/utils'
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'
export function MembersWaitlistSection() {
const {
groupId, attendees, attendeesTotal, attendeesPending,
waitlistEntries, waitlistTotal, waitlistPending,
preRegistrations, preRegistrationsTotal, preRegistrationsPending,
listSection, setListSection, searchFilter, setSearchFilter, openInviteModal,
} = useGroupDetail()
const navigate = useNavigate()
@@ -21,6 +26,14 @@ export function MembersWaitlistSection() {
(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'
return (
// Radios concéntricos: `rounded-2xl` (16px) con `p-2` (8px) deja a las
@@ -32,7 +45,7 @@ export function MembersWaitlistSection() {
<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-[26rem]"
className="flex w-full items-center gap-1 rounded-lg bg-surface p-0.5 shadow-xs sm:w-[36rem]"
>
<button
type="button"
@@ -40,7 +53,7 @@ export function MembersWaitlistSection() {
aria-selected={listSection === 'members'}
onClick={() => setListSection('members')}
className={cn(
'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',
TAB_CLASS,
listSection === 'members'
? 'bg-accent text-on-accent shadow-xs'
: 'text-foreground/80 hover:bg-primary-soft hover:text-primary',
@@ -51,13 +64,30 @@ export function MembersWaitlistSection() {
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(
'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',
TAB_CLASS,
listSection === 'waitlist'
? 'bg-accent text-on-accent shadow-xs'
: 'text-foreground/80 hover:bg-primary-soft hover:text-primary',
@@ -68,14 +98,14 @@ export function MembersWaitlistSection() {
</button>
</div>
{listSection === 'members' ? (
{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 miembros"
aria-label="Buscar en el listado"
className="h-10 rounded-lg border-transparent pl-9 shadow-xs placeholder:text-foreground/80"
/>
</div>
@@ -85,7 +115,9 @@ export function MembersWaitlistSection() {
<p className="text-xs leading-relaxed text-foreground/80">
{listSection === 'members'
? 'Listado de todos los miembros incorporados al grupo.'
: 'Personas que esperan un cupo libre en el grupo. Al pasar a alguien al grupo, se crea automáticamente su registro como miembro.'}
: 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.'}
</p>
</div>
@@ -135,7 +167,48 @@ export function MembersWaitlistSection() {
{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">
@@ -156,7 +229,7 @@ export function MembersWaitlistSection() {
{waitlistEntries.length > 0 ? <WaitlistTable entries={waitlistEntries} /> : null}
</div>
)}
) : null}
</div>
</div>
)