Files
gruperly/apps/web/src/features/attention/AttentionCard.tsx
Jose Selesan ecdbbbbca6 feat(i18n): traducir Requiere atención y redactar las alertas en cada idioma
Las alertas de shared suman razon + valores para que la web las redacte;
etiqueta/detalle se mantienen en español para el backend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 12:27:17 -03:00

84 lines
3.3 KiB
TypeScript

import { Link } from '@tanstack/react-router'
import { Check } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import { cn } from '../../lib/utils'
import { AlertTag } from './AlertTag'
import { alertDetail, alertLabel, reminderMessage, whatsappLink, type AttentionItem } from './attention'
import { SeverityAvatar } from './SeverityAvatar'
const ACTION_CLASS =
'inline-flex min-h-11 w-full items-center justify-center gap-2 rounded-xl px-3 text-sm font-semibold transition-colors focus-visible:ring-2 focus-visible:ring-accent focus-visible:outline-none motion-reduce:transition-none'
type AttentionCardProps = {
item: AttentionItem
onResolve: () => void
}
export function AttentionCard({ item, onResolve }: AttentionCardProps) {
const { student, alert } = item
const { t } = useTranslation('attention')
const label = alertLabel(alert)
const urgent = alert.gravedad === 'urgente'
const isPayment = alert.tipo === 'pago'
const actionLabel = isPayment ? t('card.remind') : t('card.contact')
const href = whatsappLink(student, isPayment ? reminderMessage(student) : undefined)
// Urgent: light fill, the strongest action on screen. To watch: subtle gray.
const primaryTone = urgent
? 'bg-primary text-background hover:bg-primary/90'
: 'bg-primary-soft text-primary hover:bg-border'
return (
<article className="rounded-2xl border border-border bg-surface p-4">
<div className="flex items-start gap-3">
<SeverityAvatar name={student.fullName} seed={student.attendeeId} severity={alert.gravedad} size="md" />
<div className="min-w-0 flex-1">
<Link
to="/groups/$groupId/attendees/$attendeeId"
params={{ groupId: student.groupId, attendeeId: student.attendeeId }}
className="block truncate font-semibold text-primary hover:underline focus-visible:underline focus-visible:outline-none"
>
{student.fullName}
</Link>
<p className="truncate text-sm text-secondary">{student.groupName}</p>
</div>
<AlertTag severity={alert.gravedad}>{label}</AlertTag>
</div>
<p className="mt-3 text-sm text-primary">{alertDetail(alert)}</p>
<div className="mt-3 grid grid-cols-2 gap-2">
{href ? (
<a
href={href}
target="_blank"
rel="noopener noreferrer"
aria-label={t('card.actionWhatsapp', { action: actionLabel, name: student.fullName })}
className={cn(ACTION_CLASS, primaryTone)}
>
{actionLabel}
</a>
) : (
<button
type="button"
disabled
aria-label={t('card.noPhone', { action: actionLabel, name: student.fullName })}
className={cn(ACTION_CLASS, primaryTone, 'cursor-not-allowed opacity-45')}
>
{actionLabel}
</button>
)}
<button
type="button"
onClick={onResolve}
aria-label={t('card.resolveLabel', { name: student.fullName, alert: label })}
className={cn(ACTION_CLASS, 'border border-border text-primary hover:bg-primary-soft')}
>
<Check className="size-4" aria-hidden="true" />
{t('card.resolve')}
</button>
</div>
</article>
)
}