75 lines
3.1 KiB
TypeScript
75 lines
3.1 KiB
TypeScript
import type { AttendeeDto } from '@gruperly/shared'
|
|
import { useNavigate } from '@tanstack/react-router'
|
|
import { ChevronRight } from 'lucide-react'
|
|
import { formatPhoneDisplay } from '../../../lib/format'
|
|
import { useGroupDetail } from './GroupDetailProvider'
|
|
|
|
export function MembersTable({ attendees }: { attendees: AttendeeDto[] }) {
|
|
const { groupId } = useGroupDetail()
|
|
const navigate = useNavigate()
|
|
|
|
const openAttendee = (attendeeId: string) => {
|
|
void navigate({ to: '/groups/$groupId/attendees/$attendeeId', params: { groupId, attendeeId } })
|
|
}
|
|
|
|
return (
|
|
<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-[47%] px-2 pb-1.5">Nombre</th>
|
|
<th scope="col" className="px-2 pb-1.5">Teléfono</th>
|
|
<th scope="col" className="w-8 px-1 pb-1.5">
|
|
<span className="sr-only">Detalle</span>
|
|
</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{attendees.map((attendee) => (
|
|
<tr
|
|
key={attendee.id}
|
|
tabIndex={0}
|
|
className="group cursor-pointer border-b border-border/70 transition-colors last:border-b-0 hover:bg-primary-soft/60 focus-visible:bg-primary-soft focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent"
|
|
onClick={() => openAttendee(attendee.id)}
|
|
onKeyDown={(e) => {
|
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
e.preventDefault()
|
|
openAttendee(attendee.id)
|
|
}
|
|
}}
|
|
>
|
|
<td className="px-2 py-2">
|
|
<div className="flex min-w-0 items-center gap-2">
|
|
<div className="flex size-8 shrink-0 items-center justify-center rounded-full bg-accent/10 text-xs font-semibold text-accent">
|
|
{attendee.fullName.charAt(0).toUpperCase()}
|
|
</div>
|
|
{/* `truncate` solo recorta lo pintado: el texto completo sigue en
|
|
el DOM para lectores de pantalla, y `title` lo muestra al hover. */}
|
|
<span
|
|
className="min-w-0 truncate font-semibold text-primary"
|
|
title={attendee.fullName}
|
|
>
|
|
{attendee.fullName}
|
|
</span>
|
|
</div>
|
|
</td>
|
|
{/* El nombre manda; el teléfono es un dato secundario: un nivel
|
|
más abajo en la escala de color, en un tamaño menor. */}
|
|
<td className="min-w-0 px-2 py-2 text-xs text-foreground/70">
|
|
{attendee.phone ? (
|
|
<span className="block truncate tabular-nums" title={attendee.phone}>
|
|
{formatPhoneDisplay(attendee.phone)}
|
|
</span>
|
|
) : (
|
|
<span className="text-foreground/60">—</span>
|
|
)}
|
|
</td>
|
|
<td className="w-8 px-1 py-2 text-foreground/50">
|
|
<ChevronRight className="ml-auto size-4 transition-colors group-hover:text-accent" />
|
|
</td>
|
|
</tr>
|
|
))}
|
|
</tbody>
|
|
</table>
|
|
)
|
|
}
|