feat: refactor group detail components for improved member and pending views
This commit is contained in:
@@ -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',
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user