feat(web): WhatsApp and call actions on attendee phone rows
The phone row in the attendee contact and guardian sections was a single tel: link. It now shows WhatsApp and call icon buttons for that number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { type ReactNode, useEffect, useState } from 'react'
|
||||
import { Mail, Phone } from 'lucide-react'
|
||||
import { ApiError } from '../../lib/api'
|
||||
import { formatPhoneDisplay } from '../../lib/format'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { AttendeeContactForm } from './AttendeeContactForm'
|
||||
import { contactEmailError } from './detail'
|
||||
import { PhoneRowActions } from './PhoneRowActions'
|
||||
import { Section } from './Section'
|
||||
import { useAttendeeDetail } from './AttendeeDetailProvider'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
@@ -99,8 +100,12 @@ export function AttendeeContactSection() {
|
||||
icon={Phone}
|
||||
label={t('contact.phone')}
|
||||
value={formatPhoneDisplay(attendee.phone) ?? t('contact.addPhone')}
|
||||
href={attendee.phone ? `tel:${attendee.phone.replace(/\D/g, '')}` : undefined}
|
||||
placeholder={!attendee.phone}
|
||||
actions={
|
||||
attendee.phone ? (
|
||||
<PhoneRowActions phone={attendee.phone} name={attendee.fullName} />
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<ContactRow
|
||||
icon={Mail}
|
||||
@@ -121,9 +126,11 @@ type ContactRowProps = {
|
||||
value: string
|
||||
href?: string
|
||||
placeholder: boolean
|
||||
/** Acciones a la derecha (p. ej. WhatsApp y Llamar): la fila deja de ser un link. */
|
||||
actions?: ReactNode
|
||||
}
|
||||
|
||||
export function ContactRow({ icon: Icon, label, value, href, placeholder }: ContactRowProps) {
|
||||
export function ContactRow({ icon: Icon, label, value, href, placeholder, actions }: ContactRowProps) {
|
||||
const content = (
|
||||
<>
|
||||
<Icon className="size-4 shrink-0 text-secondary" aria-hidden="true" />
|
||||
@@ -133,11 +140,12 @@ export function ContactRow({ icon: Icon, label, value, href, placeholder }: Cont
|
||||
{value}
|
||||
</span>
|
||||
</span>
|
||||
{actions}
|
||||
</>
|
||||
)
|
||||
|
||||
const className = 'flex min-h-14 items-center gap-3 rounded-lg px-3 py-2'
|
||||
return href ? (
|
||||
return href && !actions ? (
|
||||
<a href={href} className={cn(className, 'transition-colors hover:bg-primary-soft')}>
|
||||
{content}
|
||||
</a>
|
||||
|
||||
@@ -7,6 +7,7 @@ import { formatPhoneDisplay } from '../../lib/format'
|
||||
import { ContactRow } from './AttendeeContactSection'
|
||||
import { useAttendeeDetail } from './AttendeeDetailProvider'
|
||||
import { contactEmailError } from './detail'
|
||||
import { PhoneRowActions } from './PhoneRowActions'
|
||||
import { Section } from './Section'
|
||||
|
||||
/* El adulto a cargo de un chico: es una persona propia (compartida entre
|
||||
@@ -123,8 +124,15 @@ export function GuardianSection() {
|
||||
icon={Phone}
|
||||
label={t('contact.phone')}
|
||||
value={formatPhoneDisplay(attendee.guardianPhone) ?? t('contact.addPhone')}
|
||||
href={attendee.guardianPhone ? `tel:${attendee.guardianPhone.replace(/\D/g, '')}` : undefined}
|
||||
placeholder={!attendee.guardianPhone}
|
||||
actions={
|
||||
attendee.guardianPhone ? (
|
||||
<PhoneRowActions
|
||||
phone={attendee.guardianPhone}
|
||||
name={attendee.guardianName ?? attendee.fullName}
|
||||
/>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
<ContactRow
|
||||
icon={Mail}
|
||||
|
||||
36
apps/web/src/features/attendee-detail/PhoneRowActions.tsx
Normal file
36
apps/web/src/features/attendee-detail/PhoneRowActions.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import { MessageCircle, Phone } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
const ICON_ACTION_CLASS =
|
||||
'inline-flex size-11 shrink-0 items-center justify-center rounded-lg text-accent-fg transition-colors hover:bg-primary-soft hover:text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent'
|
||||
|
||||
/* WhatsApp y Llamar al número de la fila. Los dígitos se arman igual que en
|
||||
`AttendeeContactActions`, así los dos lugares abren el mismo número. */
|
||||
export function PhoneRowActions({ phone, name }: { phone: string; name: string }) {
|
||||
const { t } = useTranslation('attendeeDetail')
|
||||
const digits = phone.replace(/\D/g, '')
|
||||
if (!digits) return null
|
||||
|
||||
return (
|
||||
<div className="ml-auto flex shrink-0 items-center gap-1">
|
||||
<a
|
||||
href={`https://wa.me/${digits}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
aria-label={t('actions.whatsappLabel', { name })}
|
||||
title={t('actions.whatsappLabel', { name })}
|
||||
className={ICON_ACTION_CLASS}
|
||||
>
|
||||
<MessageCircle className="size-4" aria-hidden="true" />
|
||||
</a>
|
||||
<a
|
||||
href={`tel:${digits}`}
|
||||
aria-label={t('actions.callLabel', { name })}
|
||||
title={t('actions.callLabel', { name })}
|
||||
className={ICON_ACTION_CLASS}
|
||||
>
|
||||
<Phone className="size-4" aria-hidden="true" />
|
||||
</a>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user