refactor: remove unused attendee detail components and provider

This commit is contained in:
Jose Selesan
2026-09-30 13:37:42 -03:00
parent 27bff32e76
commit 4e86096653
30 changed files with 1710 additions and 475 deletions

View File

@@ -0,0 +1,91 @@
import { useId, useState } from 'react'
import { Check, ChevronDown, Copy, MessageCircle } from 'lucide-react'
import { cn } from '../../lib/utils'
import { useAttendeeDetail } from './AttendeeDetailProvider'
import { ACTION_BUTTON_CLASS } from './actionButton'
import { SECTION_TITLE_CLASS, Section } from './Section'
import { useCopyToClipboard } from './useCopyToClipboard'
export function AbsenceLinkSection() {
const { attendee } = useAttendeeDetail()
const { copied, copy } = useCopyToClipboard()
const [isOpen, setIsOpen] = useState(false)
const panelId = useId()
const token = attendee?.notifyToken
const url = token ? `${window.location.origin}/report-absence/${token}` : null
if (!attendee || !url) return null
const phoneDigits = attendee.phone?.replace(/\D/g, '') ?? ''
const shareUrl = phoneDigits
? `https://wa.me/${phoneDigits}?text=${encodeURIComponent(
`Hola ${attendee.fullName.split(' ')[0]}, desde este link podés avisar tus ausencias en ${url}`,
)}`
: null
return (
<Section
title={
<button
type="button"
onClick={() => setIsOpen((value) => !value)}
aria-expanded={isOpen}
aria-controls={panelId}
className={cn(
SECTION_TITLE_CLASS,
'flex min-h-11 w-full items-center gap-1.5 text-left',
)}
>
Link de ausencias
<ChevronDown
className={cn('size-4 transition-transform', isOpen && 'rotate-180')}
aria-hidden="true"
/>
</button>
}
>
{/* El panel queda en el DOM pero oculto: `aria-controls` siempre resuelve y
el texto de "Link copiado" no se pierde al plegar y desplegar. */}
<div id={panelId} hidden={!isOpen}>
<div className="pt-1">
<p className="text-sm text-foreground">
Mandales este link para que avisen cuando no puedan venir.
</p>
<div className="mt-2.5 flex flex-col gap-2 sm:flex-row">
<button
type="button"
onClick={() => copy(url)}
className={cn(ACTION_BUTTON_CLASS, 'flex-1')}
>
<Copy className="size-4" aria-hidden="true" />
Copiar link
</button>
{shareUrl ? (
<a
href={shareUrl}
target="_blank"
rel="noopener noreferrer"
aria-label={`Enviar el link por WhatsApp a ${attendee.fullName}`}
className={cn(ACTION_BUTTON_CLASS, 'flex-1')}
>
<MessageCircle className="size-4" aria-hidden="true" />
Enviar por WhatsApp
</a>
) : null}
</div>
<p
aria-live="polite"
className="flex min-h-5 items-center gap-1.5 pt-2 text-xs font-medium text-success"
>
{copied ? (
<>
<Check className="size-3.5" aria-hidden="true" />
Link copiado
</>
) : null}
</p>
</div>
</div>
</Section>
)
}