- `POST /groups/:gid/attendees/:aid/move` mueve al mismo attendee a otro grupo del profesor: conserva historial, cuotas (siguen del grupo anterior) y acceso a la app de alumnos. Cancela las faltas avisadas y libera lo reservado en clases futuras del grupo anterior. - Cupo y teléfono duplicado se validan con `checkCanJoinGroup`, compartido con el paso desde la lista de espera. - Ficha del miembro: "Cambiar de grupo" abre un diálogo con el selector de grupo destino y navega a la ficha en el grupo nuevo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
105 lines
4.2 KiB
TypeScript
105 lines
4.2 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 { useAttendeeDetail } from './AttendeeDetailProvider'
|
|
import { ChangeGroupDialog } from './ChangeGroupDialog'
|
|
import { ConfirmRemoveAttendeeDialog } from './ConfirmRemoveAttendeeDialog'
|
|
import { formatMemberSince } from './attendance'
|
|
import { paymentPresentation } from './detail'
|
|
import { StudentAccessSection } from './StudentAccessSection'
|
|
|
|
export function AttendeeDetailView() {
|
|
const { groupId, groupName, attendee, attendeePending, attendeeFailed } = useAttendeeDetail()
|
|
const navigate = useNavigate()
|
|
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 ?? 'Miembro'}
|
|
barContext={groupName ?? 'Grupo'}
|
|
leading={
|
|
<Link
|
|
to="/groups/$groupId"
|
|
params={{ groupId }}
|
|
aria-label="Volver al grupo"
|
|
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>Desde {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">Miembro no encontrado</h2>
|
|
<p className="mt-2 text-sm text-primary">
|
|
No se pudo cargar la información de este miembro.
|
|
</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 } })}
|
|
>
|
|
Volver al grupo
|
|
</Button>
|
|
</div>
|
|
) : null}
|
|
|
|
{attendee ? (
|
|
<>
|
|
<div className="mt-5">
|
|
<AttendeeContactActions />
|
|
</div>
|
|
|
|
<div className="mt-6">
|
|
<AttendeeContactSection />
|
|
<StudentAccessSection />
|
|
<AttendeePaymentsSection />
|
|
<AttendeeAttendanceSection />
|
|
<AttendeeNotesSection />
|
|
<AbsenceLinkSection />
|
|
</div>
|
|
</>
|
|
) : null}
|
|
|
|
<ConfirmRemoveAttendeeDialog returnFocusRef={menuTriggerRef} />
|
|
<ChangeGroupDialog returnFocusRef={menuTriggerRef} />
|
|
</section>
|
|
)
|
|
}
|