Files
gruperly/apps/web/src/features/groups/detail/MembersWaitlistSection.tsx

76 lines
3.8 KiB
TypeScript

import { Search } from 'lucide-react'
import { Input } from '../../../components/ui'
import { MEMBER_SEARCH_MIN } from './constants'
import { useGroupDetail } from './GroupDetailProvider'
import { MembersView } from './MembersView'
import { PendingView } from './PendingView'
import { SectionChips } from './SectionChips'
export function MembersWaitlistSection() {
const { listSection, searchFilter, setSearchFilter, attendeesTotal } = useGroupDetail()
// With few attendees the search is noise: scrolling the list is enough. It is
// removed from the tree instead of hidden, so as not to leave a gap in the
// row. In Pendientes nothing changes: there the volume is what it is.
const showSearch = listSection === 'pending' || attendeesTotal > MEMBER_SEARCH_MIN
return (
// A single surface: the list sits directly on the wash, like the info card
// above, instead of nesting inside a lighter box. The separation between
// controls and data comes from the row dividers themselves, the input's own
// tone and the chips' border; an intermediate box only added a level of
// containment and horizontal padding.
<div className="rounded-2xl bg-primary-soft">
{/* The controls travel with the scroll: with a long list the chips and the
search are the only way to change what you're looking at, and losing
them halfway down means scrolling back up to undo a search. They stick
under the group's bar and go back to their place on their own when the
panel's top edge comes back into view (i.e. at the first row).
`top-14` is the `h-14` of `ImmersiveBarHost`: without it the row would
slide underneath the bar instead of below it. `z-30` leaves the bar
(`z-40`) and modals/toasts (`z-50`) above. The opaque `bg-primary-soft`
is what hides the rows going under, so no blur is needed. */}
<div className="sticky top-14 z-30 bg-primary-soft p-3">
<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-11 rounded-lg border-transparent pl-9 shadow-xs"
/>
</div>
) : null}
</div>
</div>
{/* Only Pendientes has supporting copy: it explains the difference
between pre-registration and waitlist, which cannot be deduced from
the names. In Miembros the column labels already say everything. It
lives outside the sticky row so it doesn't become fixed height up
there; `pt-2` is the gap the row's `p-3` used to leave. */}
{listSection === 'pending' ? (
<p className="max-w-2xl px-3 pb-3 pt-2 text-xs leading-snug text-foreground/80">
Pre-inscripciones que esperan tu aprobación y personas en lista de espera por un cupo
libre.
</p>
) : null}
{/* The clipping the panel used to do lives here now. It can't stay on the
panel: an ancestor with `overflow` is a scroll container, and a sticky
element resolves against that scrollport — never moving at all. Here it
is harmless because the controls are siblings above it, not inside it.
It squares off the last row's bottom border and the empty states. */}
<div className="overflow-hidden rounded-b-2xl">
{listSection === 'members' ? <MembersView /> : <PendingView />}
</div>
</div>
)
}