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 (
)
}
const hasAnyEntry = preRegistrations.length > 0 || waitlistEntries.length > 0
if (!hasAnyEntry && !query) {
return (
// Full-bleed and with no radius of its own: the list wrapper's
// `overflow-hidden` clips it against the rounded silhouette. `surface` over
// `primary-soft` sinks the block; with the previous wash it camouflaged.
No hay pendientes
Las pre-inscripciones que lleguen por el enlace compartido y las personas en lista de
espera aparecerán aquí para que las revises.
Compartir enlace
)
}
if (filteredPrereg.length === 0 && filteredWaitlist.length === 0) {
return (
No se encontraron pendientes que coincidan con la búsqueda.
)
}
const sections = [
{
key: 'preregistrations',
title: 'Pre-inscripciones',
icon: UserCheck,
attention: true,
count: filteredPrereg.length,
emptyNote: 'Sin pre-inscripciones pendientes.',
table: ,
},
{
key: 'waitlist',
title: 'Lista de espera',
icon: Clock,
attention: false,
count: filteredWaitlist.length,
emptyNote: 'Sin nadie en la lista de espera.',
table: ,
},
]
return (
{sections.map((section) => {
const Icon = section.icon
const hasRows = section.count > 0
const titleId = `pending-${section.title.replace(/\s+/g, '-').toLowerCase()}`
// With the search on, sections with no matches are hidden.
if (!hasRows && query) return null
return (
{section.title}
{hasRows ? (
{section.count}
) : null}
{hasRows ? (
{section.table}
) : (
{section.emptyNote}
)}
)
})}
)
}