- Acceso del alumno o tutor con link de un solo uso (hash SHA-256, consumo atómico, el GET no consume), sesión propia de 90 días deslizante, passkeys opcionales (SimpleWebAuthn) y mail de recuperación con rate limit. - Lado alumno (/i/:token, /acceso, /alumno/*): inicio, clases, avisar falta, pagos, informar pago con comprobante (S3 privado, magic bytes) y perfil. - Lado profe: acceso a la app en la ficha del alumno (invitar/reinvitar), "Pagos para verificar" en Cobros con badge, faltas avisadas en la ficha de grupo y datos para transferir en Ajustes. - "Requiere atención" y el recordatorio de WhatsApp excluyen cuotas informadas. - Zona horaria por defecto: Buenos Aires. - Migración add_student_access, tests contra Postgres real (test:db) y docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
90 lines
3.6 KiB
TypeScript
90 lines
3.6 KiB
TypeScript
import { CalendarX2, Loader2, Lock, Receipt, CalendarDays } from 'lucide-react'
|
|
import { Avatar, Button } from '../../components/ui'
|
|
import { LinkUsedView } from './LinkUsedView'
|
|
import { StudentAuthShell } from './StudentAuthShell'
|
|
import { useStudentLink } from './StudentLinkProvider'
|
|
|
|
const CAPABILITIES = [
|
|
{ icon: CalendarX2, text: 'Avisar si no vas a una clase' },
|
|
{ icon: Receipt, text: 'Informar pagos con el comprobante' },
|
|
{ icon: CalendarDays, text: 'Ver tus próximas clases' },
|
|
]
|
|
|
|
export function StudentLinkView() {
|
|
const { info, infoPending, infoFailed, enter, entering, consumedElsewhere, enterFailed } = useStudentLink()
|
|
|
|
if (infoPending) {
|
|
return (
|
|
<StudentAuthShell>
|
|
<div className="flex flex-col items-center gap-3 py-20" role="status">
|
|
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
|
|
<p className="text-sm text-secondary">Cargando…</p>
|
|
</div>
|
|
</StudentAuthShell>
|
|
)
|
|
}
|
|
|
|
if (infoFailed || !info || info.status === 'invalid' || consumedElsewhere) {
|
|
return <LinkUsedView variant="used" />
|
|
}
|
|
|
|
const firstName = info.name.split(' ')[0] ?? info.name
|
|
const isRecovery = info.kind === 'recovery'
|
|
|
|
return (
|
|
<StudentAuthShell>
|
|
<section className="space-y-6 rounded-2xl border border-border bg-surface p-6 shadow-sm">
|
|
<div className="text-center">
|
|
<div className="mb-4 flex justify-center" aria-hidden="true">
|
|
{info.teacherName ? (
|
|
<Avatar name={info.teacherName} className="size-14 rounded-full bg-brand-night text-lg text-white ring-4 ring-surface" />
|
|
) : null}
|
|
<Avatar
|
|
name={info.name}
|
|
className={`size-14 rounded-full text-lg ring-4 ring-surface ${info.teacherName ? '-ml-3' : ''}`}
|
|
/>
|
|
</div>
|
|
<h1 className="text-2xl font-bold text-primary">Hola, {firstName}</h1>
|
|
<p className="mt-2 text-sm leading-relaxed text-secondary">
|
|
{isRecovery
|
|
? 'Este es tu link para volver a entrar a gruperly.'
|
|
: info.teacherName && info.groupName
|
|
? `${info.teacherName} te invitó a ${info.groupName} en gruperly.`
|
|
: 'Te invitaron a gruperly.'}
|
|
</p>
|
|
</div>
|
|
|
|
{isRecovery ? null : (
|
|
<ul className="space-y-2">
|
|
{CAPABILITIES.map(({ icon: Icon, text }) => (
|
|
<li key={text} className="flex items-center gap-3 rounded-xl bg-primary-soft px-4 py-3 text-sm text-primary">
|
|
<Icon className="size-5 shrink-0 text-accent-fg" aria-hidden="true" />
|
|
{text}
|
|
</li>
|
|
))}
|
|
</ul>
|
|
)}
|
|
|
|
<div className="space-y-3">
|
|
<Button variant="primary" className="h-12 w-full text-base" onClick={enter} disabled={entering}>
|
|
{entering ? <Loader2 className="size-5 animate-spin" aria-hidden="true" /> : null}
|
|
Ingresar
|
|
</Button>
|
|
{enterFailed ? (
|
|
<p role="alert" className="text-center text-sm text-danger-fg">
|
|
No pudimos conectarte. Revisá tu conexión y probá de nuevo.
|
|
</p>
|
|
) : null}
|
|
<p className="flex gap-2 text-xs leading-relaxed text-secondary">
|
|
<Lock className="mt-0.5 size-4 shrink-0" aria-hidden="true" />
|
|
<span>
|
|
Sin contraseñas: vas a quedar conectado/a en este teléfono. Este link es personal y sirve una sola vez.
|
|
Si no sos {firstName}, no continúes.
|
|
</span>
|
|
</p>
|
|
</div>
|
|
</section>
|
|
</StudentAuthShell>
|
|
)
|
|
}
|