feat: refactor group detail components for improved member and pending views
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 & 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 & 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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
69
apps/web/src/features/groups/detail/MembersView.tsx
Normal file
69
apps/web/src/features/groups/detail/MembersView.tsx
Normal 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} />
|
||||
}
|
||||
@@ -1,36 +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 { Search } from 'lucide-react'
|
||||
import { Input } from '../../../components/ui'
|
||||
import { useGroupDetail } from './GroupDetailProvider'
|
||||
import { MembersTable } from './MembersTable'
|
||||
import { PreRegistrationsTable } from './PreRegistrationsTable'
|
||||
import { MembersView } from './MembersView'
|
||||
import { PendingView } from './PendingView'
|
||||
import { SectionChips } from './SectionChips'
|
||||
import { WaitlistTable } from './WaitlistTable'
|
||||
|
||||
export function MembersWaitlistSection() {
|
||||
const {
|
||||
groupId, attendees, attendeesPending,
|
||||
waitlistEntries, waitlistPending,
|
||||
preRegistrations, 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,138 +17,27 @@ export function MembersWaitlistSection() {
|
||||
<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-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>
|
||||
) : 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>
|
||||
)
|
||||
|
||||
125
apps/web/src/features/groups/detail/PendingView.tsx
Normal file
125
apps/web/src/features/groups/detail/PendingView.tsx
Normal 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>
|
||||
)
|
||||
}
|
||||
@@ -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',
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
import { Clock, UserCheck, Users } from 'lucide-react'
|
||||
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, attention: false },
|
||||
{ id: 'preregistrations', label: 'Pre-inscripciones', icon: UserCheck, attention: true },
|
||||
{ id: 'waitlist', label: 'Lista de espera', icon: Clock, attention: false },
|
||||
{ id: 'members', label: 'Miembros', icon: Users },
|
||||
{ id: 'pending', label: 'Pendientes', icon: Inbox },
|
||||
] as const satisfies ReadonlyArray<{
|
||||
id: ListSection
|
||||
label: string
|
||||
icon: typeof Users
|
||||
attention: boolean
|
||||
}>
|
||||
|
||||
export function SectionChips() {
|
||||
const { listSection, setListSection, attendeesTotal, preRegistrationsTotal, waitlistTotal } =
|
||||
useGroupDetail()
|
||||
const {
|
||||
listSection,
|
||||
setListSection,
|
||||
attendeesTotal,
|
||||
preRegistrationsTotal,
|
||||
waitlistTotal,
|
||||
} = useGroupDetail()
|
||||
|
||||
const counts: Record<ListSection, number> = {
|
||||
members: attendeesTotal,
|
||||
preregistrations: preRegistrationsTotal,
|
||||
waitlist: waitlistTotal,
|
||||
pending: preRegistrationsTotal + waitlistTotal,
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -32,6 +34,8 @@ export function SectionChips() {
|
||||
{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 (
|
||||
@@ -57,7 +61,7 @@ export function SectionChips() {
|
||||
'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'
|
||||
: section.attention
|
||||
: isAttention
|
||||
? 'bg-warning-soft text-warning'
|
||||
: 'bg-primary-soft text-foreground/60',
|
||||
)}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user