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

74 lines
3.2 KiB
TypeScript

import type { GroupWaitlistEntryDto } from '@gruperly/shared'
import { ChevronRight } from 'lucide-react'
import { formatPhoneDisplay } from '../../../lib/format'
import { useGroupDetail } from './GroupDetailProvider'
export function WaitlistTable({ entries }: { entries: GroupWaitlistEntryDto[] }) {
const { setSelectedWaitlistEntry } = useGroupDetail()
return (
<table className="w-full table-fixed text-left text-sm">
<thead>
{/* `border-foreground/10` y no `border`: en dark `--border` es igual a
`primary-soft`, el fondo de la fila, y el separador desaparecería. */}
<tr className="border-b border-foreground/10 text-xs font-semibold text-foreground/80">
<th scope="col" className="w-[47%] px-3 pb-1.5">Nombre</th>
<th scope="col" className="px-3 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>
{entries.map((entry) => (
<tr
key={entry.id}
tabIndex={0}
// El hover va a `surface` porque la fila ya vive sobre `primary-soft`.
className="group cursor-pointer border-b border-foreground/10 transition-colors last:border-b-0 hover:bg-surface/60 focus-visible:bg-surface focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent"
onClick={() => setSelectedWaitlistEntry(entry)}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault()
setSelectedWaitlistEntry(entry)
}
}}
>
{/* `px-3` alinea el texto con el chips y el search de arriba: es el
mismo eje izquierdo de 12px en toda la sección. */}
<td className="px-3 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">
{entry.fullName.charAt(0).toUpperCase()}
</div>
<div className="min-w-0">
<p className="truncate font-semibold text-primary" title={entry.fullName}>
{entry.fullName}
</p>
{entry.notes ? (
<p className="truncate text-xs text-foreground/70" title={entry.notes}>
{entry.notes}
</p>
) : null}
</div>
</div>
</td>
<td className="min-w-0 px-3 py-2 text-xs text-foreground/70">
{entry.phone ? (
<span className="block truncate tabular-nums" title={entry.phone}>
{formatPhoneDisplay(entry.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>
)
}