Files
gruperly/apps/web/src/features/attendee-detail/AttendeeDetailView.tsx
Jose Selesan 8a5768e0c0 feat(i18n): traducir la ficha del alumno
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 12:30:11 -03:00

109 lines
4.4 KiB
TypeScript

import { useRef } from 'react'
import { Link, useNavigate } from '@tanstack/react-router'
import { ArrowLeft, Loader2 } from 'lucide-react'
import { LargeTitle } from '../../components/layout/LargeTitle'
import { Avatar, Badge, Button } from '../../components/ui'
import { AbsenceLinkSection } from './AbsenceLinkSection'
import { AttendeeActionsMenu } from './AttendeeActionsMenu'
import { AttendeeAttendanceSection } from './AttendeeAttendanceSection'
import { AttendeeContactActions } from './AttendeeContactActions'
import { AttendeeContactSection } from './AttendeeContactSection'
import { AttendeeNotesSection } from './AttendeeNotesSection'
import { AttendeePaymentsSection } from './AttendeePaymentsSection'
import { OtherGroupsSection } from './OtherGroupsSection'
import { useAttendeeDetail } from './AttendeeDetailProvider'
import { ChangeGroupDialog } from './ChangeGroupDialog'
import { ConfirmRemoveAttendeeDialog } from './ConfirmRemoveAttendeeDialog'
import { formatMemberSince } from './attendance'
import { paymentPresentation } from './detail'
import { StudentAccessSection } from './StudentAccessSection'
import { useTranslation } from 'react-i18next'
export function AttendeeDetailView() {
const { groupId, groupName, attendee, attendeePending, attendeeFailed } = useAttendeeDetail()
const navigate = useNavigate()
const { t } = useTranslation(['attendeeDetail', 'common', 'groupDetail'])
const menuTriggerRef = useRef<HTMLButtonElement>(null)
const payment = attendee ? paymentPresentation(attendee.payment) : null
return (
<section className="mx-auto w-full max-w-md animate-fade-in lg:max-w-2xl">
<LargeTitle
title={attendee?.fullName ?? t('fallbackName')}
barContext={groupName ?? t('groupDetail:fallbackTitle')}
leading={
<Link
to="/groups/$groupId"
params={{ groupId }}
aria-label={t('backToGroup')}
className="relative z-10 hidden size-11 shrink-0 lg:inline-flex items-center justify-center rounded-xl text-primary transition-colors hover:bg-primary-soft active:scale-[0.96] motion-reduce:active:scale-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent"
>
<ArrowLeft className="size-5" aria-hidden="true" />
</Link>
}
barTrailing={<AttendeeActionsMenu triggerRef={menuTriggerRef} />}
titleLeading={
attendee ? (
<Avatar
name={attendee.fullName}
className="size-14 rounded-full bg-accent-soft text-base text-accent-fg ring-1 ring-border"
/>
) : null
}
>
{attendee && payment ? (
<div className="mt-3 flex flex-wrap items-center gap-2 text-sm text-secondary">
<Badge variant={payment.isDue ? 'warning' : 'success'} className="text-[11px]">
{payment.chipLabel}
</Badge>
<span>{t('since', { date: formatMemberSince(attendee.createdAt) })}</span>
</div>
) : null}
</LargeTitle>
{attendeePending ? (
<div className="flex items-center justify-center py-20">
<Loader2 className="size-8 animate-spin text-accent" />
</div>
) : null}
{attendeeFailed || (!attendeePending && !attendee) ? (
<div className="mt-6 rounded-2xl bg-danger-soft p-6">
<h2 className="text-lg font-bold text-danger-fg">{t('notFound.title')}</h2>
<p className="mt-2 text-sm text-primary">
{t('notFound.description')}
</p>
<Button
variant="ghost"
className="mt-4 px-0 text-accent-fg hover:bg-transparent hover:text-primary"
onClick={() => void navigate({ to: '/groups/$groupId', params: { groupId } })}
>
{t('backToGroup')}
</Button>
</div>
) : null}
{attendee ? (
<>
<div className="mt-5">
<AttendeeContactActions />
</div>
<div className="mt-6">
<AttendeeContactSection />
<OtherGroupsSection />
<StudentAccessSection />
<AttendeePaymentsSection />
<AttendeeAttendanceSection />
<AttendeeNotesSection />
<AbsenceLinkSection />
</div>
</>
) : null}
<ConfirmRemoveAttendeeDialog returnFocusRef={menuTriggerRef} />
<ChangeGroupDialog returnFocusRef={menuTriggerRef} />
</section>
)
}