development #14

Merged
jselesan merged 102 commits from development into main 2026-11-07 13:21:43 +00:00
929 changed files with 107520 additions and 1440 deletions
Showing only changes of commit 486fbaf2ca - Show all commits

View File

@@ -4,11 +4,13 @@ import { CheckCircle2, Loader2, MailWarning, Mail } from 'lucide-react'
import { Button } from '../../components/ui'
import { confirmStudentRecoveryEmail } from '../../lib/api'
import { StudentAuthShell } from './StudentAuthShell'
import { Trans, useTranslation } from 'react-i18next'
/* Confirming takes a tap (POST), like entering with a link: a mail scanner that
opens the URL doesn't confirm anything by itself. */
export function ConfirmRecoveryEmailView({ token }: { token: string }) {
const mutation = useMutation({ mutationFn: () => confirmStudentRecoveryEmail(token) })
const { t } = useTranslation('studentAccess')
return (
<StudentAuthShell>
@@ -19,13 +21,18 @@ export function ConfirmRecoveryEmailView({ token }: { token: string }) {
<CheckCircle2 className="size-7" aria-hidden="true" />
</div>
<div role="status">
<h1 className="text-2xl font-bold text-primary">Mail confirmado</h1>
<h1 className="text-2xl font-bold text-primary">{t('confirmEmail.doneTitle')}</h1>
<p className="mt-2 text-sm text-secondary">
Si algún día perdés el acceso, pedí un link a <strong className="text-primary">{mutation.data.email}</strong>.
<Trans
t={t}
i18nKey="confirmEmail.done"
values={{ email: mutation.data.email }}
components={{ strong: <strong className="text-primary" /> }}
/>
</p>
</div>
<Link to="/student" className="inline-flex h-12 w-full items-center justify-center rounded-xl bg-accent font-medium text-on-accent hover:bg-accent-strong">
Ir a gruperly
{t('confirmEmail.goToApp')}
</Link>
</>
) : mutation.isError ? (
@@ -34,9 +41,9 @@ export function ConfirmRecoveryEmailView({ token }: { token: string }) {
<MailWarning className="size-7" aria-hidden="true" />
</div>
<div role="alert">
<h1 className="text-2xl font-bold text-primary">Este link ya no sirve</h1>
<h1 className="text-2xl font-bold text-primary">{t('confirmEmail.expiredTitle')}</h1>
<p className="mt-2 text-sm text-secondary">
Ya fue usado o venció. Podés volver a cargar tu mail desde Perfil en la app.
{t('confirmEmail.expired')}
</p>
</div>
</>
@@ -46,12 +53,12 @@ export function ConfirmRecoveryEmailView({ token }: { token: string }) {
<Mail className="size-7" aria-hidden="true" />
</div>
<div>
<h1 className="text-2xl font-bold text-primary">Confirmá tu mail</h1>
<p className="mt-2 text-sm text-secondary">Lo vas a poder usar para pedir un link si perdés el acceso.</p>
<h1 className="text-2xl font-bold text-primary">{t('confirmEmail.title')}</h1>
<p className="mt-2 text-sm text-secondary">{t('confirmEmail.description')}</p>
</div>
<Button variant="primary" className="h-12 w-full text-base" onClick={() => mutation.mutate()} disabled={mutation.isPending}>
{mutation.isPending ? <Loader2 className="size-5 animate-spin" aria-hidden="true" /> : null}
Confirmar mail
{t('confirmEmail.confirm')}
</Button>
</>
)}

View File

@@ -4,6 +4,7 @@ import { Button } from '../../components/ui'
import { PasskeyLoginButton } from './PasskeyLoginButton'
import { RecoveryLinkForm } from './RecoveryLinkForm'
import { StudentAuthShell } from './StudentAuthShell'
import { useTranslation } from 'react-i18next'
type LinkUsedViewProps = {
/** `used`: a dead link (used, expired or never valid). `signed-out`: the
@@ -13,6 +14,7 @@ type LinkUsedViewProps = {
export function LinkUsedView({ variant }: LinkUsedViewProps) {
const [showEmail, setShowEmail] = useState(false)
const { t } = useTranslation('studentAccess')
const Icon = variant === 'used' ? Link2Off : LogIn
return (
@@ -23,12 +25,12 @@ export function LinkUsedView({ variant }: LinkUsedViewProps) {
<Icon className="size-7" aria-hidden="true" />
</div>
<h1 className="text-2xl font-bold text-primary">
{variant === 'used' ? 'Este link ya fue usado' : 'Volvé a entrar'}
{variant === 'used' ? t('linkUsed.usedTitle') : t('linkUsed.signedOutTitle')}
</h1>
<p className="mt-3 text-sm leading-relaxed text-secondary">
{variant === 'used'
? 'Los links de gruperly sirven una sola vez. Si ya entraste desde otro teléfono, seguí desde ahí. Si no fuiste vos, avisale a tu profe para que te mande uno nuevo: el anterior deja de funcionar.'
: 'No encontramos tu sesión en este teléfono. Pedile a tu profe un link nuevo o usá una de estas opciones.'}
? t('linkUsed.used')
: t('linkUsed.signedOut')}
</p>
</div>
@@ -39,10 +41,10 @@ export function LinkUsedView({ variant }: LinkUsedViewProps) {
) : (
<Button variant="outline" className="h-12 w-full text-base" onClick={() => setShowEmail(true)}>
<Mail className="size-5" aria-hidden="true" />
Pedir un link a mi mail
{t('linkUsed.askEmail')}
</Button>
)}
<p className="text-center text-xs text-secondary">Estas opciones funcionan solo si las activaste antes.</p>
<p className="text-center text-xs text-secondary">{t('linkUsed.note')}</p>
</div>
</section>
</StudentAuthShell>

View File

@@ -4,11 +4,13 @@ import { useQueryClient } from '@tanstack/react-query'
import { Fingerprint, Loader2 } from 'lucide-react'
import { Button } from '../../components/ui'
import { isPasskeyCancel, loginWithPasskey, supportsPasskeys } from './passkeys'
import { useTranslation } from 'react-i18next'
export function PasskeyLoginButton() {
const navigate = useNavigate()
const queryClient = useQueryClient()
const [pending, setPending] = useState(false)
const { t } = useTranslation('studentAccess')
const [failed, setFailed] = useState(false)
if (!supportsPasskeys()) return null
@@ -31,11 +33,11 @@ export function PasskeyLoginButton() {
<div className="space-y-2">
<Button variant="primary" className="h-12 w-full text-base" onClick={() => void handleClick()} disabled={pending}>
{pending ? <Loader2 className="size-5 animate-spin" /> : <Fingerprint className="size-5" />}
Entrar con Face ID o huella
{t('passkey.login')}
</Button>
{failed ? (
<p role="alert" className="text-center text-sm text-danger-fg">
No pudimos verificar tu Face ID o huella en este teléfono.
{t('passkey.error')}
</p>
) : null}
</div>

View File

@@ -3,11 +3,13 @@ import { useMutation } from '@tanstack/react-query'
import { Loader2, MailCheck } from 'lucide-react'
import { Button, Input, Label } from '../../components/ui'
import { ApiError, requestStudentRecoveryLink } from '../../lib/api'
import { Trans, useTranslation } from 'react-i18next'
/* "Pedir un link a mi mail". The answer is the same whether the email exists
or not, so the screen says it conditionally. */
export function RecoveryLinkForm() {
const [email, setEmail] = useState('')
const { t } = useTranslation('studentAccess')
const mutation = useMutation({ mutationFn: requestStudentRecoveryLink })
const handleSubmit = (event: FormEvent) => {
@@ -20,8 +22,12 @@ export function RecoveryLinkForm() {
<div role="status" className="flex gap-3 rounded-xl border border-border bg-primary-soft p-4 text-sm text-secondary">
<MailCheck className="size-5 shrink-0 text-accent-fg" aria-hidden="true" />
<p>
Si <strong className="text-primary">{email.trim()}</strong> es tu mail de recuperación, te mandamos un link
para entrar. Vence en 15 minutos.
<Trans
t={t}
i18nKey="recovery.sent"
values={{ email: email.trim() }}
components={{ strong: <strong className="text-primary" /> }}
/>
</p>
</div>
)
@@ -32,7 +38,7 @@ export function RecoveryLinkForm() {
return (
<form onSubmit={handleSubmit} className="space-y-3">
<div className="space-y-1.5">
<Label htmlFor="recovery-email">Tu mail de recuperación</Label>
<Label htmlFor="recovery-email">{t('recovery.label')}</Label>
<Input
id="recovery-email"
type="email"
@@ -47,12 +53,12 @@ export function RecoveryLinkForm() {
</div>
{mutation.isError ? (
<p role="alert" className="text-sm text-danger-fg">
{tooMany ? 'Pediste varios links seguidos. Probá de nuevo en 15 minutos.' : 'No pudimos enviar el pedido. Probá de nuevo.'}
{tooMany ? t('recovery.tooMany') : t('recovery.error')}
</p>
) : null}
<Button type="submit" variant="outline" className="h-12 w-full" disabled={mutation.isPending}>
{mutation.isPending ? <Loader2 className="size-5 animate-spin" /> : null}
Mandarme el link
{t('recovery.submit')}
</Button>
</form>
)

View File

@@ -3,22 +3,24 @@ import { Avatar, Button } from '../../components/ui'
import { LinkUsedView } from './LinkUsedView'
import { StudentAuthShell } from './StudentAuthShell'
import { useStudentLink } from './StudentLinkProvider'
import { useTranslation } from 'react-i18next'
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' },
]
{ icon: CalendarX2, text: 'link.capNotify' },
{ icon: Receipt, text: 'link.capReport' },
{ icon: CalendarDays, text: 'link.capClasses' },
] as const
export function StudentLinkView() {
const { info, infoPending, infoFailed, enter, entering, consumedElsewhere, enterFailed } = useStudentLink()
const { t } = useTranslation('studentAccess')
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>
<p className="text-sm text-secondary">{t('loading')}</p>
</div>
</StudentAuthShell>
)
@@ -44,13 +46,13 @@ export function StudentLinkView() {
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>
<h1 className="text-2xl font-bold text-primary">{t('link.greeting', { name: firstName })}</h1>
<p className="mt-2 text-sm leading-relaxed text-secondary">
{isRecovery
? 'Este es tu link para volver a entrar a gruperly.'
? t('link.recovery')
: info.teacherName && info.groupName
? `${info.teacherName} te invitó a ${info.groupName} en gruperly.`
: 'Te invitaron a gruperly.'}
? t('link.invitedBy', { teacher: info.teacherName, group: info.groupName })
: t('link.invited')}
</p>
</div>
@@ -59,7 +61,7 @@ export function StudentLinkView() {
{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}
{t(text)}
</li>
))}
</ul>
@@ -68,18 +70,17 @@ export function StudentLinkView() {
<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
{t('link.enter')}
</Button>
{enterFailed ? (
<p role="alert" className="text-center text-sm text-danger-fg">
No pudimos conectarte. Revisá tu conexión y probá de nuevo.
{t('link.error')}
</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.
{t('link.security', { name: firstName })}
</span>
</p>
</div>

View File

@@ -20,6 +20,7 @@ import type whatsapp from './locales/es-AR/whatsapp.json'
import type onboarding from './locales/es-AR/onboarding.json'
import type account from './locales/es-AR/account.json'
import type public from './locales/es-AR/public.json'
import type studentAccess from './locales/es-AR/studentAccess.json'
import type validation from './locales/es-AR/validation.json'
// es-AR es la fuente: una clave que no exista ahí rompe el typecheck.
@@ -34,6 +35,7 @@ declare module 'i18next' {
pwa: typeof pwa
settings: typeof settings
validation: typeof validation
'studentAccess': typeof studentAccess
'public': typeof public
'account': typeof account
'onboarding': typeof onboarding

View File

@@ -0,0 +1,44 @@
{
"loading": "Loading…",
"confirmEmail": {
"doneTitle": "Email confirmed",
"done": "If you ever lose access, request a link to <strong>{{email}}</strong>.",
"goToApp": "Go to gruperly",
"expiredTitle": "This link no longer works",
"expired": "It was already used or has expired. You can add your email again from Profile in the app.",
"title": "Confirm your email",
"description": "You'll be able to use it to request a link if you lose access.",
"confirm": "Confirm email"
},
"linkUsed": {
"usedTitle": "This link was already used",
"signedOutTitle": "Sign in again",
"used": "gruperly links work only once. If you already signed in from another phone, continue there. If it wasn't you, ask your teacher to send you a new one: the old one stops working.",
"signedOut": "We couldn't find your session on this phone. Ask your teacher for a new link or use one of these options.",
"askEmail": "Email me a link",
"note": "These options only work if you turned them on before."
},
"passkey": {
"login": "Sign in with Face ID or fingerprint",
"error": "We couldn't verify your Face ID or fingerprint on this phone."
},
"recovery": {
"sent": "If <strong>{{email}}</strong> is your recovery email, we sent you a sign-in link. It expires in 15 minutes.",
"label": "Your recovery email",
"tooMany": "You requested several links in a row. Try again in 15 minutes.",
"error": "We couldn't send the request. Please try again.",
"submit": "Send me the link"
},
"link": {
"greeting": "Hi, {{name}}",
"recovery": "This is your link to get back into gruperly.",
"invitedBy": "{{teacher}} invited you to {{group}} on gruperly.",
"invited": "You were invited to gruperly.",
"capNotify": "Let your teacher know if you'll miss a class",
"capReport": "Report payments with the receipt",
"capClasses": "See your upcoming classes",
"enter": "Continue",
"error": "We couldn't connect you. Check your connection and try again.",
"security": "No passwords: you'll stay signed in on this phone. This link is personal and works only once. If you're not {{name}}, don't continue."
}
}

View File

@@ -0,0 +1,44 @@
{
"loading": "Cargando…",
"confirmEmail": {
"doneTitle": "Mail confirmado",
"done": "Si algún día pierdes el acceso, pide un link a <strong>{{email}}</strong>.",
"goToApp": "Ir a gruperly",
"expiredTitle": "Este link ya no sirve",
"expired": "Ya se usó o venció. Puedes volver a registrar tu mail desde Perfil en la app.",
"title": "Confirma tu mail",
"description": "Podrás usarlo para pedir un link si pierdes el acceso.",
"confirm": "Confirmar mail"
},
"linkUsed": {
"usedTitle": "Este link ya fue usado",
"signedOutTitle": "Vuelve a entrar",
"used": "Los links de gruperly sirven una sola vez. Si ya entraste desde otro teléfono, sigue desde ahí. Si no fuiste tú, avísale a tu profe para que te envíe uno nuevo: el anterior deja de funcionar.",
"signedOut": "No encontramos tu sesión en este teléfono. Pídele a tu profe un link nuevo o usa una de estas opciones.",
"askEmail": "Pedir un link a mi mail",
"note": "Estas opciones funcionan solo si las activaste antes."
},
"passkey": {
"login": "Entrar con Face ID o huella",
"error": "No pudimos verificar tu Face ID o huella en este teléfono."
},
"recovery": {
"sent": "Si <strong>{{email}}</strong> es tu mail de recuperación, te enviamos un link para entrar. Vence en 15 minutos.",
"label": "Tu mail de recuperación",
"tooMany": "Pediste varios links seguidos. Inténtalo de nuevo en 15 minutos.",
"error": "No pudimos enviar la solicitud. Inténtalo de nuevo.",
"submit": "Enviarme el link"
},
"link": {
"greeting": "Hola, {{name}}",
"recovery": "Este es tu link para volver a entrar a gruperly.",
"invitedBy": "{{teacher}} te invitó a {{group}} en gruperly.",
"invited": "Te invitaron a gruperly.",
"capNotify": "Avisar si no vas a una clase",
"capReport": "Informar pagos con el comprobante",
"capClasses": "Ver tus próximas clases",
"enter": "Ingresar",
"error": "No pudimos conectarte. Revisa tu conexión e inténtalo de nuevo.",
"security": "Sin contraseñas: quedarás conectado/a en este teléfono. Este link es personal y sirve una sola vez. Si no eres {{name}}, no continúes."
}
}

View File

@@ -0,0 +1,44 @@
{
"loading": "Cargando…",
"confirmEmail": {
"doneTitle": "Mail confirmado",
"done": "Si algún día perdés el acceso, pedí un link a <strong>{{email}}</strong>.",
"goToApp": "Ir a gruperly",
"expiredTitle": "Este link ya no sirve",
"expired": "Ya fue usado o venció. Podés volver a cargar tu mail desde Perfil en la app.",
"title": "Confirmá tu mail",
"description": "Lo vas a poder usar para pedir un link si perdés el acceso.",
"confirm": "Confirmar mail"
},
"linkUsed": {
"usedTitle": "Este link ya fue usado",
"signedOutTitle": "Volvé a entrar",
"used": "Los links de gruperly sirven una sola vez. Si ya entraste desde otro teléfono, seguí desde ahí. Si no fuiste vos, avisale a tu profe para que te mande uno nuevo: el anterior deja de funcionar.",
"signedOut": "No encontramos tu sesión en este teléfono. Pedile a tu profe un link nuevo o usá una de estas opciones.",
"askEmail": "Pedir un link a mi mail",
"note": "Estas opciones funcionan solo si las activaste antes."
},
"passkey": {
"login": "Entrar con Face ID o huella",
"error": "No pudimos verificar tu Face ID o huella en este teléfono."
},
"recovery": {
"sent": "Si <strong>{{email}}</strong> es tu mail de recuperación, te mandamos un link para entrar. Vence en 15 minutos.",
"label": "Tu mail de recuperación",
"tooMany": "Pediste varios links seguidos. Probá de nuevo en 15 minutos.",
"error": "No pudimos enviar el pedido. Probá de nuevo.",
"submit": "Mandarme el link"
},
"link": {
"greeting": "Hola, {{name}}",
"recovery": "Este es tu link para volver a entrar a gruperly.",
"invitedBy": "{{teacher}} te invitó a {{group}} en gruperly.",
"invited": "Te invitaron a gruperly.",
"capNotify": "Avisar si no vas a una clase",
"capReport": "Informar pagos con el comprobante",
"capClasses": "Ver tus próximas clases",
"enter": "Ingresar",
"error": "No pudimos conectarte. Revisá tu conexión y probá de nuevo.",
"security": "Sin contraseñas: vas a quedar conectado/a en este teléfono. Este link es personal y sirve una sola vez. Si no sos {{name}}, no continúes."
}
}

View File

@@ -0,0 +1,44 @@
{
"loading": "Carregando…",
"confirmEmail": {
"doneTitle": "E-mail confirmado",
"done": "Se algum dia você perder o acesso, peça um link para <strong>{{email}}</strong>.",
"goToApp": "Ir para o gruperly",
"expiredTitle": "Este link não vale mais",
"expired": "Ele já foi usado ou expirou. Você pode cadastrar seu e-mail de novo em Perfil, no app.",
"title": "Confirme seu e-mail",
"description": "Você vai poder usá-lo para pedir um link se perder o acesso.",
"confirm": "Confirmar e-mail"
},
"linkUsed": {
"usedTitle": "Este link já foi usado",
"signedOutTitle": "Entre de novo",
"used": "Os links do gruperly valem uma única vez. Se você já entrou por outro celular, continue por lá. Se não foi você, avise seu professor para enviar um novo: o anterior deixa de funcionar.",
"signedOut": "Não encontramos sua sessão neste celular. Peça um novo link ao seu professor ou use uma destas opções.",
"askEmail": "Pedir um link no meu e-mail",
"note": "Estas opções só funcionam se você as ativou antes."
},
"passkey": {
"login": "Entrar com Face ID ou digital",
"error": "Não conseguimos verificar seu Face ID ou digital neste celular."
},
"recovery": {
"sent": "Se <strong>{{email}}</strong> for seu e-mail de recuperação, enviamos um link para entrar. Ele vence em 15 minutos.",
"label": "Seu e-mail de recuperação",
"tooMany": "Você pediu vários links seguidos. Tente novamente em 15 minutos.",
"error": "Não conseguimos enviar o pedido. Tente novamente.",
"submit": "Enviar o link"
},
"link": {
"greeting": "Olá, {{name}}",
"recovery": "Este é o seu link para entrar de novo no gruperly.",
"invitedBy": "{{teacher}} convidou você para {{group}} no gruperly.",
"invited": "Você foi convidado para o gruperly.",
"capNotify": "Avisar se não for a uma aula",
"capReport": "Informar pagamentos com o comprovante",
"capClasses": "Ver suas próximas aulas",
"enter": "Entrar",
"error": "Não conseguimos conectar você. Verifique sua conexão e tente novamente.",
"security": "Sem senhas: você fica conectado neste celular. Este link é pessoal e vale uma única vez. Se você não é {{name}}, não continue."
}
}