Files
gruperly/apps/web/src/features/groups/detail/SectionChips.tsx
Jose Selesan 69275c37b4 chore: update comments and documentation for clarity and consistency across various files
- Translated comments from Spanish to English in vite.config.ts, docker-compose.yml, attendance-risk.ts, analytics.ts, attendance.ts, attendees.ts, enums.ts, groups.ts, and onboarding.ts.
- Improved descriptions for better understanding of code functionality and purpose.
- Ensured uniformity in terminology and phrasing throughout the codebase.
2026-10-01 16:06:54 -03:00

80 lines
2.7 KiB
TypeScript

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 },
{ id: 'pending', label: 'Pendientes', icon: Inbox },
] as const satisfies ReadonlyArray<{
id: ListSection
label: string
icon: typeof Users
}>
export function SectionChips() {
const {
listSection,
setListSection,
attendeesTotal,
preRegistrationsTotal,
waitlistTotal,
} = useGroupDetail()
const counts: Record<ListSection, number> = {
members: attendeesTotal,
pending: preRegistrationsTotal + 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]
// Amber only when there is something to decide: pre-registrations to
// review.
const isAttention = section.id === 'pending' && preRegistrationsTotal > 0
const Icon = section.icon
return (
<button
key={section.id}
type="button"
aria-pressed={isActive}
onClick={() => setListSection(section.id)}
className={cn(
// min-h-11 (44px): minimum iOS/Android touch target.
'inline-flex min-h-11 items-center gap-1.5 rounded-full border px-3.5 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'
: isAttention
? 'bg-warning-soft text-warning'
: 'bg-primary-soft text-foreground/70',
)}
>
{count}
</span>
) : null}
</button>
)
})}
</div>
)
}