feat/pre-registration #7
@@ -1,20 +1,17 @@
|
||||
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 { useGroupDetail } from './GroupDetailProvider'
|
||||
import { MembersTable } from './MembersTable'
|
||||
import { PreRegistrationsTable } from './PreRegistrationsTable'
|
||||
import { SectionChips } from './SectionChips'
|
||||
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,
|
||||
groupId, attendees, attendeesPending,
|
||||
waitlistEntries, waitlistPending,
|
||||
preRegistrations, preRegistrationsPending,
|
||||
listSection, setListSection, searchFilter, setSearchFilter, openInviteModal,
|
||||
} = useGroupDetail()
|
||||
const navigate = useNavigate()
|
||||
@@ -41,65 +38,11 @@ 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">
|
||||
<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..."
|
||||
|
||||
73
apps/web/src/features/groups/detail/SectionChips.tsx
Normal file
73
apps/web/src/features/groups/detail/SectionChips.tsx
Normal file
@@ -0,0 +1,73 @@
|
||||
import { Clock, UserCheck, 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 },
|
||||
] as const satisfies ReadonlyArray<{
|
||||
id: ListSection
|
||||
label: string
|
||||
icon: typeof Users
|
||||
attention: boolean
|
||||
}>
|
||||
|
||||
export function SectionChips() {
|
||||
const { listSection, setListSection, attendeesTotal, preRegistrationsTotal, waitlistTotal } =
|
||||
useGroupDetail()
|
||||
|
||||
const counts: Record<ListSection, number> = {
|
||||
members: attendeesTotal,
|
||||
preregistrations: preRegistrationsTotal,
|
||||
waitlist: 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]
|
||||
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'
|
||||
: section.attention
|
||||
? 'bg-warning-soft text-warning'
|
||||
: 'bg-primary-soft text-foreground/60',
|
||||
)}
|
||||
>
|
||||
{count}
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user