feat(i18n): traducir la app de alumnos (con selector de idioma en Perfil)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-11-03 14:05:21 -03:00
parent 486fbaf2ca
commit 4d50b46399
27 changed files with 887 additions and 152 deletions

View File

@@ -5,9 +5,11 @@ import { Badge } from '../../components/ui'
import { formatPrice } from '../../lib/format'
import { feeLabel } from './format'
import { FeeStatusBadge } from './FeeStatusBadge'
import { useTranslation } from 'react-i18next'
/* "Tu cuota": only while there is something unpaid. */
export function FeeCard({ fees }: { fees: StudentFee[] }) {
const { t } = useTranslation(['student', 'common'])
if (fees.length === 0) return null
const first = fees[0] as StudentFee
const toReport = fees.filter((fee) => fee.status !== 'reported')
@@ -21,9 +23,9 @@ export function FeeCard({ fees }: { fees: StudentFee[] }) {
<article className="rounded-2xl border border-border bg-surface p-5">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">
<p className="text-xs font-semibold uppercase tracking-wide text-secondary">Tu cuota</p>
<p className="text-xs font-semibold uppercase tracking-wide text-secondary">{t('fee.yourFee')}</p>
<h2 className="mt-1 truncate text-lg font-bold text-primary">
{fees.length === 1 ? feeLabel(first) : `${fees.length} cuotas sin pagar`}
{fees.length === 1 ? feeLabel(first) : t('fee.unpaid', { count: fees.length })}
</h2>
<p className="mt-1 text-2xl font-bold text-primary">
{formatPrice(toReport.length > 0 ? total : first.amount, first.currency)}
@@ -32,19 +34,19 @@ export function FeeCard({ fees }: { fees: StudentFee[] }) {
{fees.length === 1 ? (
<FeeStatusBadge status={first.status} />
) : toReport.some((fee) => fee.status === 'overdue') ? (
<Badge variant="warning">Hay vencidas</Badge>
<Badge variant="warning">{t('fee.overdue')}</Badge>
) : null}
</div>
{toReport.length > 0 ? (
<div className="mt-4 space-y-2">
{single ? (
<a href={single.checkoutUrl ?? undefined} target="_blank" rel="noreferrer" className={primary}>
Pagar con Mercado Pago
{t('fee.payMp')}
<ExternalLink className="size-4" aria-hidden="true" />
</a>
) : payable.length > 1 ? (
<Link to="/student/payments" className={primary}>
Pagar con Mercado Pago
{t('fee.payMp')}
</Link>
) : null}
<Link
@@ -56,11 +58,11 @@ export function FeeCard({ fees }: { fees: StudentFee[] }) {
}
>
<Receipt className="size-5" aria-hidden="true" />
Informar pago
{t('fee.report')}
</Link>
</div>
) : (
<p className="mt-3 text-sm text-secondary">Tu profe tiene que confirmar el pago que informaste.</p>
<p className="mt-3 text-sm text-secondary">{t('fee.awaiting')}</p>
)}
</article>
)

View File

@@ -1,14 +1,11 @@
import type { StudentFeeStatus } from '@gruperly/shared'
import { Badge } from '../../components/ui'
import { useTranslation } from 'react-i18next'
const LABELS: Record<StudentFeeStatus, string> = {
pending: 'Pendiente',
overdue: 'Vencida',
reported: 'Informada',
}
// Color always goes with the word: amber overdue, blue reported.
export function FeeStatusBadge({ status }: { status: StudentFeeStatus }) {
const { t } = useTranslation('student')
const variant = status === 'overdue' ? 'warning' : status === 'reported' ? 'info' : 'neutral'
return <Badge variant={variant}>{LABELS[status]}</Badge>
return <Badge variant={variant}>{t(`feeStatus.${status}`)}</Badge>
}

View File

@@ -2,6 +2,7 @@ import { Link } from '@tanstack/react-router'
import type { StudentClass } from '@gruperly/shared'
import { CalendarX2, Check } from 'lucide-react'
import { dateParts, formatLongDate, formatRelativeDay, formatTime } from './format'
import { useTranslation } from 'react-i18next'
type NextClassCardProps = { item: StudentClass; timeZone: string }
@@ -9,11 +10,12 @@ type NextClassCardProps = { item: StudentClass; timeZone: string }
White on brand-night scores 15:1 in both themes. */
export function NextClassCard({ item, timeZone }: NextClassCardProps) {
const { day, month } = dateParts(item.startsAt, timeZone)
const { t } = useTranslation(['student', 'common'])
return (
<article className="rounded-2xl bg-brand-night p-5 text-white shadow-sm">
<p className="text-xs font-semibold uppercase tracking-wide text-brand-celeste">
Próxima clase · {formatRelativeDay(item.startsAt, timeZone)}
{t('home.nextClass', { when: formatRelativeDay(item.startsAt, timeZone) })}
</p>
<div className="mt-3 flex items-center gap-4">
<div className="min-w-0 flex-1">
@@ -30,7 +32,7 @@ export function NextClassCard({ item, timeZone }: NextClassCardProps) {
{item.notice ? (
<p className="mt-4 flex min-h-11 items-center gap-2 rounded-xl bg-white/10 px-4 text-sm font-medium">
<Check className="size-4" aria-hidden="true" />
Avisaste que no vas
{t('home.notified')}
</p>
) : (
<Link
@@ -39,7 +41,7 @@ export function NextClassCard({ item, timeZone }: NextClassCardProps) {
className="mt-4 flex min-h-12 items-center justify-center gap-2 rounded-xl bg-white font-semibold text-brand-night hover:bg-brand-cloud"
>
<CalendarX2 className="size-5" aria-hidden="true" />
No voy a ir
{t('home.notGoing')}
</Link>
)}
</article>

View File

@@ -6,21 +6,23 @@ import { Button, Label } from '../../components/ui'
import { cn } from '../../lib/utils'
import { FlowDone } from './FlowDone'
import { FlowFooter } from './FlowFooter'
import { ABSENCE_REASON_LABELS, firstName, formatShortDate, formatTime } from './format'
import { ABSENCE_REASONS, absenceReasonLabel, firstName, formatShortDate, formatTime } from './format'
import { SelectableRow } from './SelectableRow'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
const REASONS = Object.keys(ABSENCE_REASON_LABELS) as AbsenceReasonValue[]
const REASONS = ABSENCE_REASONS
export function NotifyAbsenceView({ preselected }: { preselected?: string }) {
const { student, classes, notifyAbsences } = useStudentApp()
const [selected, setSelected] = useState<string[]>(preselected ? [preselected] : [])
const [reason, setReason] = useState<AbsenceReasonValue | null>(null)
const [message, setMessage] = useState('')
const { t } = useTranslation(['student', 'common'])
if (!student || !classes) {
return (
<div className="flex justify-center py-20" role="status" aria-label="Cargando">
<div className="flex justify-center py-20" role="status" aria-label={t('loading')}>
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
</div>
)
@@ -30,14 +32,14 @@ export function NotifyAbsenceView({ preselected }: { preselected?: string }) {
if (notifyAbsences.isSuccess) {
return (
<FlowDone title={`Listo, le avisamos a ${teacher}`}>
<p className="text-sm text-secondary">Si cambiás de idea, podés deshacerlo desde Clases mientras la clase no haya empezado.</p>
<FlowDone title={t('notify.done', { teacher })}>
<p className="text-sm text-secondary">{t('notify.doneHint')}</p>
<div className="space-y-2 pt-2">
<Link to="/student" className="flex min-h-12 items-center justify-center rounded-xl bg-accent font-semibold text-on-accent hover:bg-accent-strong">
Volver al inicio
{t('backHome')}
</Link>
<Link to="/student/classes" className="flex min-h-12 items-center justify-center rounded-xl border border-border font-medium text-primary hover:bg-primary-soft">
Ver mis clases
{t('notify.seeClasses')}
</Link>
</div>
</FlowDone>
@@ -63,17 +65,17 @@ export function NotifyAbsenceView({ preselected }: { preselected?: string }) {
<div className="space-y-6">
<Link to="/student" className="hidden items-center gap-1 text-sm text-secondary hover:text-primary lg:inline-flex">
<ArrowLeft className="size-4" aria-hidden="true" />
Volver
{t('back')}
</Link>
<h1 className="text-2xl font-bold text-primary">Avisar que no voy</h1>
<h1 className="text-2xl font-bold text-primary">{t('notify.title')}</h1>
<section aria-labelledby="classes-label" className="space-y-2">
<h2 id="classes-label" className="text-sm font-semibold text-primary">
¿A qué clases no vas?
{t('notify.which')}
</h2>
{available.length === 0 ? (
<p className="rounded-xl border border-dashed border-border px-4 py-6 text-center text-sm text-secondary">
No hay clases para avisar.
{t('notify.none')}
</p>
) : (
<div className="space-y-2">
@@ -91,7 +93,7 @@ export function NotifyAbsenceView({ preselected }: { preselected?: string }) {
<section aria-labelledby="reason-label" className="space-y-2">
<h2 id="reason-label" className="text-sm font-semibold text-primary">
Motivo <span className="font-normal text-secondary">(opcional)</span>
{t('notify.reason')} <span className="font-normal text-secondary">{t('notify.optional')}</span>
</h2>
<div className="flex flex-wrap gap-2">
{REASONS.map((value) => (
@@ -105,14 +107,14 @@ export function NotifyAbsenceView({ preselected }: { preselected?: string }) {
reason === value ? 'border-accent bg-accent-soft text-accent-fg' : 'border-border bg-surface text-primary hover:bg-primary-soft',
)}
>
{ABSENCE_REASON_LABELS[value]}
{absenceReasonLabel(value)}
</button>
))}
</div>
</section>
<div className="space-y-1.5">
<Label htmlFor="absence-message">Mensaje para {teacher} (opcional)</Label>
<Label htmlFor="absence-message">{t('notify.message', { teacher })}</Label>
<textarea
id="absence-message"
value={message}
@@ -123,18 +125,18 @@ export function NotifyAbsenceView({ preselected }: { preselected?: string }) {
/>
</div>
<p className="text-xs text-secondary">Si avisás antes de la clase, la falta queda como justificada.</p>
<p className="text-xs text-secondary">{t('notify.hint')}</p>
{notifyAbsences.isError ? (
<p role="alert" className="text-sm text-danger-fg">
No pudimos mandar el aviso. Si alguna clase ya empezó, sacala y probá de nuevo.
{t('notify.error')}
</p>
) : null}
<FlowFooter>
<Button variant="primary" className="h-12 w-full text-base" disabled={count === 0 || notifyAbsences.isPending} onClick={submit}>
{notifyAbsences.isPending ? <Loader2 className="size-5 animate-spin" aria-hidden="true" /> : null}
{count === 0 ? 'Elegí al menos una clase' : count === 1 ? 'Avisar 1 clase' : `Avisar ${count} clases`}
{count === 0 ? t('notify.pick') : t('notify.submit', { count })}
</Button>
</FlowFooter>
</div>

View File

@@ -4,12 +4,14 @@ import { Button } from '../../components/ui'
import { cn } from '../../lib/utils'
import { isPasskeyCancel, supportsPasskeys } from '../student-access/passkeys'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
/* "Entrar con Face ID o huella". Not shown when the browser has no WebAuthn,
unless there's already a passkey to remove. */
export function PasskeyCard({ highlighted = false }: { highlighted?: boolean }) {
const { me, activatePasskey, removePasskeys } = useStudentApp()
const [failed, setFailed] = useState(false)
const { t } = useTranslation(['student', 'common'])
const hasPasskey = me?.account.hasPasskey ?? false
if (!supportsPasskeys() && !hasPasskey) return null
@@ -33,30 +35,30 @@ export function PasskeyCard({ highlighted = false }: { highlighted?: boolean })
</span>
<div className="min-w-0 flex-1">
<h2 id="passkey-title" className="text-base font-bold text-primary">
{hasPasskey ? 'Face ID activado' : 'Entrar con Face ID o huella'}
{hasPasskey ? t('passkey.active') : t('passkey.title')}
</h2>
<p className="mt-1 text-sm text-secondary">
{hasPasskey
? 'Si se cierra tu sesión, entrás con tu cara o tu huella, sin pedirle un link a tu profe.'
: 'Si se cierra tu sesión o cambiás de navegador, vas a poder volver a entrar sin pedirle un link a tu profe.'}
? t('passkey.activeHint')
: t('passkey.hint')}
</p>
</div>
</div>
{failed ? (
<p role="alert" className="mt-3 text-sm text-danger-fg">
No pudimos activarlo en este teléfono.
{t('passkey.error')}
</p>
) : null}
<div className="mt-4">
{hasPasskey ? (
<Button variant="outline" className="h-11 w-full" onClick={() => removePasskeys.mutate()} disabled={removePasskeys.isPending}>
{removePasskeys.isPending ? <Loader2 className="size-4 animate-spin" aria-hidden="true" /> : null}
Quitar Face ID o huella
{t('passkey.remove')}
</Button>
) : (
<Button variant="primary" className="h-11 w-full" onClick={activate} disabled={activatePasskey.isPending}>
{activatePasskey.isPending ? <Loader2 className="size-4 animate-spin" aria-hidden="true" /> : null}
Activar
{t('passkey.activate')}
</Button>
)}
</div>

View File

@@ -1,12 +1,14 @@
import type { StudentPaymentReport } from '@gruperly/shared'
import { CheckCircle2, XCircle } from 'lucide-react'
import { formatPrice } from '../../lib/format'
import { useTranslation } from 'react-i18next'
const RECENT_MS = 7 * 24 * 60 * 60 * 1000
/* In-app notice of the teacher's review: the latest report reviewed in the
last week (the student is also emailed if they confirmed a recovery email). */
export function PaymentReviewBanner({ reports }: { reports: StudentPaymentReport[] }) {
const { t } = useTranslation(['student', 'common'])
const latest = reports.find(
(report) => report.status !== 'reported' && report.reviewedAt && Date.now() - Date.parse(report.reviewedAt) < RECENT_MS,
)
@@ -17,7 +19,7 @@ export function PaymentReviewBanner({ reports }: { reports: StudentPaymentReport
return (
<p role="status" className="flex gap-3 rounded-2xl bg-success-soft px-4 py-3 text-sm text-primary">
<CheckCircle2 className="size-5 shrink-0 text-success" aria-hidden="true" />
<span>Tu profe confirmó tu pago de {amount}.</span>
<span>{t('review.confirmed', { amount })}</span>
</p>
)
}
@@ -25,8 +27,9 @@ export function PaymentReviewBanner({ reports }: { reports: StudentPaymentReport
<p role="status" className="flex gap-3 rounded-2xl bg-danger-soft px-4 py-3 text-sm text-primary">
<XCircle className="size-5 shrink-0 text-danger-fg" aria-hidden="true" />
<span>
Tu profe no pudo confirmar tu pago de {amount}.
{latest.rejectionReason ? ` Motivo: ${latest.rejectionReason}.` : ''} Podés volver a informarlo.
{t('review.rejected', { amount })}
{latest.rejectionReason ? t('review.reason', { reason: latest.rejectionReason }) : ''}
{t('review.retry')}
</span>
</p>
)

View File

@@ -2,6 +2,7 @@ import { useEffect, useId, useMemo, useState } from 'react'
import { FileText, Paperclip, X } from 'lucide-react'
import { RECEIPT_ACCEPT, RECEIPT_MAX_MB } from '@gruperly/shared'
import { formatFileSize } from './format'
import { useTranslation } from 'react-i18next'
const ACCEPTED = new Set(RECEIPT_ACCEPT.split(','))
// Safari's HEIC can't be previewed by other browsers: those show the file icon.
@@ -17,6 +18,7 @@ type ReceiptDropzoneProps = {
export function ReceiptDropzone({ file, onChange }: ReceiptDropzoneProps) {
const inputId = useId()
const [error, setError] = useState<string | null>(null)
const { t } = useTranslation(['student', 'common'])
const preview = useMemo(() => (file && PREVIEWABLE.has(file.type) ? URL.createObjectURL(file) : null), [file])
useEffect(() => () => {
@@ -26,11 +28,11 @@ export function ReceiptDropzone({ file, onChange }: ReceiptDropzoneProps) {
const handleFile = (next: File | undefined) => {
if (!next) return
if (next.size > RECEIPT_MAX_MB * 1024 * 1024) {
setError(`El archivo pesa más de ${RECEIPT_MAX_MB} MB.`)
setError(t('receipt.tooBig', { max: RECEIPT_MAX_MB }))
return
}
if (next.type && !ACCEPTED.has(next.type)) {
setError('Tiene que ser una captura (JPG, PNG, WEBP, HEIC) o un PDF.')
setError(t('receipt.badType'))
return
}
setError(null)
@@ -54,7 +56,7 @@ export function ReceiptDropzone({ file, onChange }: ReceiptDropzoneProps) {
<button
type="button"
onClick={() => onChange(null)}
aria-label="Quitar comprobante"
aria-label={t('receipt.remove')}
className="flex size-11 shrink-0 items-center justify-center rounded-xl text-foreground hover:bg-primary-soft hover:text-primary"
>
<X className="size-5" aria-hidden="true" />
@@ -70,8 +72,8 @@ export function ReceiptDropzone({ file, onChange }: ReceiptDropzoneProps) {
className="flex min-h-28 cursor-pointer flex-col items-center justify-center gap-2 rounded-2xl border-2 border-dashed border-border bg-surface px-4 py-6 text-center hover:border-accent focus-within:border-accent focus-within:ring-2 focus-within:ring-accent/30"
>
<Paperclip className="size-6 text-accent-fg" aria-hidden="true" />
<span className="text-sm font-semibold text-primary">Adjuntar captura o PDF</span>
<span className="text-xs text-secondary">Hasta {RECEIPT_MAX_MB} MB</span>
<span className="text-sm font-semibold text-primary">{t('receipt.attach')}</span>
<span className="text-xs text-secondary">{t('receipt.max', { max: RECEIPT_MAX_MB })}</span>
<input
id={inputId}
type="file"

View File

@@ -2,12 +2,14 @@ import { useState, type FormEvent } from 'react'
import { Loader2, Mail } from 'lucide-react'
import { Button, Input, Label } from '../../components/ui'
import { useStudentApp } from './StudentAppProvider'
import { Trans, useTranslation } from 'react-i18next'
/* Optional recovery email (Perfil). Saving it sends a confirmation link: until
it's confirmed it doesn't recover anything. */
export function RecoveryEmailCard() {
const { me, saveRecoveryEmail, removeRecoveryEmail } = useStudentApp()
const [editing, setEditing] = useState(false)
const { t } = useTranslation(['student', 'common'])
const [email, setEmail] = useState('')
const current = me?.account.recoveryEmail ?? null
const pending = me?.account.pendingRecoveryEmail ?? null
@@ -32,20 +34,20 @@ export function RecoveryEmailCard() {
</span>
<div className="min-w-0 flex-1">
<h2 id="recovery-title" className="text-base font-bold text-primary">
Mail de recuperación <span className="font-normal text-secondary">(opcional)</span>
{t('recovery.title')} <span className="font-normal text-secondary">{t('recovery.optional')}</span>
</h2>
{current ? (
<p className="mt-1 truncate text-sm text-secondary">
Confirmado: <span className="font-medium text-primary">{current}</span>
<Trans t={t} i18nKey="recovery.confirmed" values={{ email: current }} components={{ strong: <span className="font-medium text-primary" /> }} />
</p>
) : null}
{pending ? (
<p className="mt-1 text-sm text-secondary">
Te mandamos un link a <span className="font-medium text-primary">{pending}</span> para confirmarlo.
<Trans t={t} i18nKey="recovery.pending" values={{ email: pending }} components={{ strong: <span className="font-medium text-primary" /> }} />
</p>
) : null}
{!current && !pending ? (
<p className="mt-1 text-sm text-secondary">Para pedir un link de ingreso si perdés el acceso.</p>
<p className="mt-1 text-sm text-secondary">{t('recovery.hint')}</p>
) : null}
</div>
</div>
@@ -53,7 +55,7 @@ export function RecoveryEmailCard() {
{showForm ? (
<form onSubmit={submit} className="mt-4 space-y-3">
<div className="space-y-1.5">
<Label htmlFor="profile-recovery-email">Tu mail</Label>
<Label htmlFor="profile-recovery-email">{t('recovery.label')}</Label>
<Input
id="profile-recovery-email"
type="email"
@@ -68,28 +70,28 @@ export function RecoveryEmailCard() {
</div>
{saveRecoveryEmail.isError ? (
<p role="alert" className="text-sm text-danger-fg">
No pudimos guardar el mail. Probá de nuevo en un rato.
{t('recovery.error')}
</p>
) : null}
<div className="flex gap-2">
{editing ? (
<Button variant="outline" className="h-11 flex-1" onClick={() => setEditing(false)}>
Cancelar
{t('common:actions.cancel')}
</Button>
) : null}
<Button type="submit" variant="primary" className="h-11 flex-1" disabled={saveRecoveryEmail.isPending}>
{saveRecoveryEmail.isPending ? <Loader2 className="size-4 animate-spin" aria-hidden="true" /> : null}
Guardar
{t('common:actions.save')}
</Button>
</div>
</form>
) : (
<div className="mt-4 flex gap-2">
<Button variant="outline" className="h-11 flex-1" onClick={() => setEditing(true)}>
Cambiar
{t('recovery.change')}
</Button>
<Button variant="ghost" className="h-11 flex-1" onClick={() => removeRecoveryEmail.mutate()} disabled={removeRecoveryEmail.isPending}>
Quitar
{t('recovery.remove')}
</Button>
</div>
)}

View File

@@ -13,16 +13,19 @@ import { ReceiptDropzone } from './ReceiptDropzone'
import { SelectableRow } from './SelectableRow'
import { useStudentApp } from './StudentAppProvider'
import { TransferDetailsCard } from './TransferDetailsCard'
import { useTranslation } from 'react-i18next'
import { errorMessage } from '../../i18n'
export function ReportPaymentView() {
const { student, fees, reportPayment } = useStudentApp()
const [selected, setSelected] = useState<string[] | null>(null)
const [file, setFile] = useState<File | null>(null)
const [note, setNote] = useState('')
const { t } = useTranslation(['student', 'common'])
if (!student || !fees) {
return (
<div className="flex justify-center py-20" role="status" aria-label="Cargando">
<div className="flex justify-center py-20" role="status" aria-label={t('loading')}>
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
</div>
)
@@ -32,12 +35,12 @@ export function ReportPaymentView() {
if (reportPayment.isSuccess) {
return (
<FlowDone title="Pago informado">
<FlowDone title={t('report.done')}>
<p className="text-sm text-secondary">
{teacher} va a revisar el comprobante. Te avisamos acá cuando lo confirme.
{t('report.doneHint', { teacher })}
</p>
<Link to="/student" className="flex min-h-12 items-center justify-center rounded-xl bg-accent font-semibold text-on-accent hover:bg-accent-strong">
Volver al inicio
{t('backHome')}
</Link>
</FlowDone>
)
@@ -58,26 +61,26 @@ export function ReportPaymentView() {
const errorText =
reportPayment.error instanceof ApiError && reportPayment.error.status === 409
? 'Ya informaste alguna de estas cuotas.'
? t('report.alreadyReported')
: reportPayment.error instanceof ApiError && reportPayment.error.status === 400
? reportPayment.error.problem?.detail ?? 'Revisá el comprobante.'
: 'No pudimos enviar el pago. Probá de nuevo.'
? errorMessage(reportPayment.error, t('report.checkReceipt'))
: t('report.error')
return (
<div className="space-y-6">
<Link to="/student/payments" className="hidden items-center gap-1 text-sm text-secondary hover:text-primary lg:inline-flex">
<ArrowLeft className="size-4" aria-hidden="true" />
Volver
{t('back')}
</Link>
<h1 className="text-2xl font-bold text-primary">Informar pago</h1>
<h1 className="text-2xl font-bold text-primary">{t('report.title')}</h1>
<section aria-labelledby="fees-label" className="space-y-2">
<h2 id="fees-label" className="text-sm font-semibold text-primary">
¿Qué cuotas pagaste?
{t('report.which')}
</h2>
{reportable.length === 0 ? (
<p className="rounded-xl border border-dashed border-border px-4 py-6 text-center text-sm text-secondary">
No tenés cuotas para informar.
{t('report.none')}
</p>
) : (
<div className="space-y-2">
@@ -91,7 +94,7 @@ export function ReportPaymentView() {
<span className="block text-sm font-medium text-primary">{feeLabel(fee)}</span>
<span className="mt-1 flex items-center gap-2 text-xs text-secondary">
<FeeStatusBadge status={fee.status} />
Vence {formatDueDate(fee.dueDate)}
{t('report.due', { date: formatDueDate(fee.dueDate) })}
</span>
</SelectableRow>
))}
@@ -103,27 +106,27 @@ export function ReportPaymentView() {
<section aria-labelledby="receipt-label" className="space-y-2">
<h2 id="receipt-label" className="text-sm font-semibold text-primary">
Comprobante
{t('report.receipt')}
</h2>
<ReceiptDropzone file={file} onChange={setFile} />
</section>
<div className="space-y-1.5">
<Label htmlFor="report-note">Nota para {teacher} (opcional)</Label>
<Label htmlFor="report-note">{t('report.note', { teacher })}</Label>
<textarea
id="report-note"
value={note}
onChange={(event) => setNote(event.target.value)}
maxLength={REPORTED_PAYMENT_NOTE_MAX}
rows={3}
placeholder="Ej.: pagué desde la cuenta de mi mamá"
placeholder={t('report.notePlaceholder')}
className="w-full rounded-xl border border-border bg-surface px-3 py-2 text-base text-primary placeholder:text-foreground/50 focus:border-accent focus:outline-none focus:ring-2 focus:ring-accent/30 sm:text-sm"
/>
</div>
<p className="flex gap-2 text-xs text-secondary">
<Info className="mt-0.5 size-4 shrink-0" aria-hidden="true" />
{teacher} va a confirmar el pago. Mientras tanto figura como Informado.
{t('report.hint', { teacher })}
</p>
{reportPayment.isError ? (
@@ -140,7 +143,11 @@ export function ReportPaymentView() {
onClick={submit}
>
{reportPayment.isPending ? <Loader2 className="size-5 animate-spin" aria-hidden="true" /> : null}
{chosen.length === 0 ? 'Elegí al menos una cuota' : !file ? 'Adjuntá el comprobante' : `Enviar · ${formatPrice(total, currency)}`}
{chosen.length === 0
? t('report.pickFee')
: !file
? t('report.attach')
: t('report.submit', { amount: formatPrice(total, currency) })}
</Button>
</FlowFooter>
</div>

View File

@@ -1,13 +1,15 @@
import { Link, useLocation } from '@tanstack/react-router'
import { cn } from '../../lib/utils'
import { isStudentNavItemActive, STUDENT_NAV_ITEMS } from './student-nav-items'
import { useTranslation } from 'react-i18next'
export function StudentBottomNav() {
const location = useLocation()
const { t } = useTranslation(['student', 'common'])
return (
<nav
aria-label="Secciones"
aria-label={t('nav.label')}
className="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-surface/95 pb-[env(safe-area-inset-bottom)] backdrop-blur"
>
<div className="mx-auto grid max-w-md grid-cols-4">
@@ -31,7 +33,7 @@ export function StudentBottomNav() {
>
<Icon className="size-5" strokeWidth={isActive ? 2.25 : 2} aria-hidden="true" />
</span>
<span className="leading-none">{label}</span>
<span className="leading-none">{t(label)}</span>
</Link>
)
})}

View File

@@ -1,26 +1,28 @@
import { Link } from '@tanstack/react-router'
import { CalendarX2, Loader2, Undo2 } from 'lucide-react'
import { Badge, Button, useToast } from '../../components/ui'
import { ABSENCE_REASON_LABELS, formatShortDate, formatTime } from './format'
import { absenceReasonLabel, formatShortDate, formatTime } from './format'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
/* Upcoming classes. A notified class can be undone while it hasn't started. */
export function StudentClassesView() {
const { classes, classesPending, cancelAbsence } = useStudentApp()
const toast = useToast()
const { t } = useTranslation(['student', 'common'])
const upcoming = (classes?.classes ?? []).filter((item) => !item.started)
const undo = (noticeId: string) => {
cancelAbsence.mutate(noticeId, {
onSuccess: () => toast.success('Listo, quedaste anotado/a otra vez.'),
onError: () => toast.error('No pudimos deshacer el aviso. Si la clase ya empezó, ya no se puede.'),
onSuccess: () => toast.success(t('classes.undone')),
onError: () => toast.error(t('classes.undoError')),
})
}
return (
<div className="space-y-5">
<div className="flex items-center justify-between gap-3">
<h1 className="text-2xl font-bold text-primary">Clases</h1>
<h1 className="text-2xl font-bold text-primary">{t('classes.title')}</h1>
</div>
<Link
@@ -28,16 +30,16 @@ export function StudentClassesView() {
className="flex min-h-12 items-center justify-center gap-2 rounded-xl bg-accent font-semibold text-on-accent hover:bg-accent-strong"
>
<CalendarX2 className="size-5" aria-hidden="true" />
Avisar que no voy
{t('classes.notify')}
</Link>
{classesPending || !classes ? (
<div className="flex justify-center py-8" role="status" aria-label="Cargando clases">
<div className="flex justify-center py-8" role="status" aria-label={t('loadingClasses')}>
<Loader2 className="size-6 animate-spin text-accent" aria-hidden="true" />
</div>
) : upcoming.length === 0 ? (
<p className="rounded-xl border border-dashed border-border px-4 py-6 text-center text-sm text-secondary">
No hay clases programadas en las próximas semanas.
{t('classes.empty')}
</p>
) : (
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
@@ -49,21 +51,21 @@ export function StudentClassesView() {
</p>
<p className="truncate text-xs text-secondary">
{item.groupName}
{item.notice?.reason ? ` · ${ABSENCE_REASON_LABELS[item.notice.reason]}` : ''}
{item.notice?.reason ? ` · ${absenceReasonLabel(item.notice.reason)}` : ''}
</p>
</div>
{item.notice ? (
<div className="flex shrink-0 items-center gap-2">
<Badge variant="neutral">Avisaste</Badge>
<Badge variant="neutral">{t('classes.notified')}</Badge>
<Button
variant="outline"
className="h-11"
onClick={() => undo(item.notice?.id as string)}
disabled={cancelAbsence.isPending}
aria-label={`Deshacer el aviso del ${formatShortDate(item.startsAt, classes.timeZone)}`}
aria-label={t('classes.undoLabel', { date: formatShortDate(item.startsAt, classes.timeZone) })}
>
<Undo2 className="size-4" aria-hidden="true" />
Deshacer
{t('classes.undo')}
</Button>
</div>
) : null}

View File

@@ -6,9 +6,11 @@ import { PaymentReviewBanner } from './PaymentReviewBanner'
import { useStudentApp } from './StudentAppProvider'
import { TeacherNoticeCard } from './TeacherNoticeCard'
import { WeekClassesList } from './WeekClassesList'
import { useTranslation } from 'react-i18next'
export function StudentHomeView() {
const { student, classes, classesPending, fees } = useStudentApp()
const { t } = useTranslation(['student', 'common'])
if (!student) return null
const allClasses = classes?.classes ?? []
@@ -18,12 +20,12 @@ export function StudentHomeView() {
return (
<div className="space-y-6">
<h1 className="text-2xl font-bold text-primary">Hola, {firstName(student.fullName)}</h1>
<h1 className="text-2xl font-bold text-primary">{t('home.greeting', { name: firstName(student.fullName) })}</h1>
{fees ? <PaymentReviewBanner reports={fees.reports} /> : null}
{classesPending ? (
<div className="flex justify-center py-8" role="status" aria-label="Cargando clases">
<div className="flex justify-center py-8" role="status" aria-label={t('loadingClasses')}>
<Loader2 className="size-6 animate-spin text-accent" aria-hidden="true" />
</div>
) : nextClass && classes ? (

View File

@@ -6,6 +6,7 @@ import { StudentBottomNav } from './StudentBottomNav'
import { StudentPicker } from './StudentPicker'
import { STUDENT_FLOW_PATHS } from './student-nav-items'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
/* Shell of the student app: same mobile-first column (`max-w-md`) as the
teacher's, with its own nav. It never mounts the teacher's header, sidebar or
@@ -13,6 +14,7 @@ import { useStudentApp } from './StudentAppProvider'
export function StudentLayout() {
const { me, mePending, student } = useStudentApp()
const location = useLocation()
const { t } = useTranslation(['student', 'common'])
const isFlow = STUDENT_FLOW_PATHS.some((path) => location.pathname.startsWith(path))
return (
@@ -31,14 +33,14 @@ export function StudentLayout() {
)}
>
{mePending || !me ? (
<div className="flex justify-center py-20" role="status" aria-label="Cargando">
<div className="flex justify-center py-20" role="status" aria-label={t('loading')}>
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
</div>
) : !student && !location.pathname.startsWith('/student/profile') ? (
<div className="mt-10 space-y-3 rounded-2xl border border-border bg-surface p-6 text-center">
<UserX className="mx-auto size-8 text-foreground" aria-hidden="true" />
<h1 className="text-lg font-bold text-primary">No tenés grupos activos</h1>
<p className="text-sm text-secondary">Si creés que es un error, hablá con tu profe.</p>
<h1 className="text-lg font-bold text-primary">{t('noGroups.title')}</h1>
<p className="text-sm text-secondary">{t('noGroups.description')}</p>
</div>
) : (
<Outlet />

View File

@@ -6,19 +6,23 @@ import { formatPrice } from '../../lib/format'
import { FeeStatusBadge } from './FeeStatusBadge'
import { feeLabel, formatDueDate } from './format'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
import { useIntlLocale } from '../../i18n'
const REPORT_BADGE: Record<StudentPaymentReport['status'], { label: string; variant: 'info' | 'success' | 'danger' }> = {
reported: { label: 'Informado', variant: 'info' },
confirmed: { label: 'Confirmado', variant: 'success' },
rejected: { label: 'Rechazado', variant: 'danger' },
const REPORT_BADGE: Record<StudentPaymentReport['status'], 'info' | 'success' | 'danger'> = {
reported: 'info',
confirmed: 'success',
rejected: 'danger',
}
export function StudentPaymentsView() {
const { fees, feesPending } = useStudentApp()
const { t } = useTranslation(['student', 'common'])
const locale = useIntlLocale()
if (feesPending || !fees) {
return (
<div className="flex justify-center py-20" role="status" aria-label="Cargando pagos">
<div className="flex justify-center py-20" role="status" aria-label={t('loadingPayments')}>
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
</div>
)
@@ -28,15 +32,15 @@ export function StudentPaymentsView() {
return (
<div className="space-y-6">
<h1 className="text-2xl font-bold text-primary">Pagos</h1>
<h1 className="text-2xl font-bold text-primary">{t('payments.title')}</h1>
<section aria-labelledby="unpaid-title" className="space-y-3">
<h2 id="unpaid-title" className="text-base font-bold text-primary">
Cuotas sin pagar
{t('payments.unpaid')}
</h2>
{fees.fees.length === 0 ? (
<p className="rounded-xl border border-dashed border-border px-4 py-6 text-center text-sm text-secondary">
Estás al día. 🎉
{t('payments.upToDate')}
</p>
) : (
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
@@ -45,7 +49,7 @@ export function StudentPaymentsView() {
<div className="flex items-center justify-between gap-3">
<div className="min-w-0">
<p className="truncate text-sm font-medium text-primary">{feeLabel(fee)}</p>
<p className="text-xs text-secondary">Vence {formatDueDate(fee.dueDate)}</p>
<p className="text-xs text-secondary">{t('payments.due', { date: formatDueDate(fee.dueDate) })}</p>
</div>
<div className="flex shrink-0 flex-col items-end gap-1">
<span className="text-sm font-semibold text-primary">{formatPrice(fee.amount, fee.currency)}</span>
@@ -59,7 +63,7 @@ export function StudentPaymentsView() {
rel="noreferrer"
className="inline-flex min-h-11 items-center gap-1 text-sm font-medium text-accent-fg hover:underline"
>
Pagar con Mercado Pago
{t('payments.payMp')}
<ExternalLink className="size-4" aria-hidden="true" />
</a>
) : null}
@@ -73,7 +77,7 @@ export function StudentPaymentsView() {
className="flex min-h-12 items-center justify-center gap-2 rounded-xl bg-accent font-semibold text-on-accent hover:bg-accent-strong"
>
<Receipt className="size-5" aria-hidden="true" />
Informar pago
{t('payments.report')}
</Link>
) : null}
</section>
@@ -81,7 +85,7 @@ export function StudentPaymentsView() {
{fees.reports.length > 0 ? (
<section aria-labelledby="reports-title" className="space-y-3">
<h2 id="reports-title" className="text-base font-bold text-primary">
Pagos informados
{t('payments.reported')}
</h2>
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
{fees.reports.map((report) => (
@@ -92,19 +96,21 @@ export function StudentPaymentsView() {
{report.fees.map((fee) => feeLabel(fee)).join(', ')}
</p>
<p className="text-xs text-secondary">
Informado el {new Date(report.createdAt).toLocaleDateString('es-AR', { day: 'numeric', month: 'short' })}
{t('payments.reportedOn', {
date: new Date(report.createdAt).toLocaleDateString(locale, { day: 'numeric', month: 'short' }),
})}
</p>
</div>
<div className="flex shrink-0 flex-col items-end gap-1">
<span className="text-sm font-semibold text-primary">{formatPrice(report.totalAmount, report.currency)}</span>
<Badge variant={REPORT_BADGE[report.status].variant}>{REPORT_BADGE[report.status].label}</Badge>
<Badge variant={REPORT_BADGE[report.status]}>{t(`payments.status.${report.status}`)}</Badge>
</div>
</div>
{report.note ? (
<p className="mt-2 whitespace-pre-line break-words text-xs text-secondary">Tu nota: {report.note}</p>
<p className="mt-2 whitespace-pre-line break-words text-xs text-secondary">{t('payments.yourNote', { note: report.note })}</p>
) : null}
{report.status === 'rejected' && report.rejectionReason ? (
<p className="mt-2 rounded-lg bg-danger-soft px-3 py-2 text-xs text-primary">Motivo: {report.rejectionReason}</p>
<p className="mt-2 rounded-lg bg-danger-soft px-3 py-2 text-xs text-primary">{t('payments.reason', { reason: report.rejectionReason })}</p>
) : null}
</li>
))}

View File

@@ -4,12 +4,14 @@ import { Avatar } from '../../components/ui'
import { cn } from '../../lib/utils'
import { firstName } from './format'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
/* Selector of the attendee the screens show, only when the account has more
than one (a guardian with several children). */
export function StudentPicker() {
const { me, student, selectStudent } = useStudentApp()
const [open, setOpen] = useState(false)
const { t } = useTranslation(['student', 'common'])
const containerRef = useRef<HTMLDivElement>(null)
useEffect(() => {
@@ -37,7 +39,7 @@ export function StudentPicker() {
onClick={() => setOpen((value) => !value)}
aria-haspopup="listbox"
aria-expanded={open}
aria-label={`Alumno: ${student.fullName}. Cambiar`}
aria-label={t('picker.label', { name: student.fullName })}
className="flex min-h-11 items-center gap-2 rounded-xl px-2 hover:bg-primary-soft"
>
<Avatar name={student.fullName} className="size-8 rounded-full text-xs" />
@@ -47,7 +49,7 @@ export function StudentPicker() {
{open ? (
<ul
role="listbox"
aria-label="Elegí el alumno"
aria-label={t('picker.listLabel')}
className="absolute right-0 top-full z-50 mt-2 w-64 rounded-xl border border-border bg-surface p-1 shadow-xl"
>
{students.map((item) => {

View File

@@ -3,14 +3,17 @@ import { Avatar, Button } from '../../components/ui'
import { PasskeyCard } from './PasskeyCard'
import { RecoveryEmailCard } from './RecoveryEmailCard'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
import { LanguageCard } from '../settings/LanguageCard'
export function StudentProfileView() {
const { me, logout, loggingOut } = useStudentApp()
const { t } = useTranslation(['student', 'common'])
if (!me) return null
return (
<div className="space-y-6">
<h1 className="text-2xl font-bold text-primary">Perfil</h1>
<h1 className="text-2xl font-bold text-primary">{t('profile.title')}</h1>
<section className="flex items-center gap-3 rounded-2xl border border-border bg-surface p-4">
<Avatar name={me.account.name} className="size-12 rounded-full text-base" />
@@ -24,10 +27,11 @@ export function StudentProfileView() {
<PasskeyCard />
<RecoveryEmailCard />
<LanguageCard />
<Button variant="outline" className="h-12 w-full" onClick={logout} disabled={loggingOut}>
<LogOut className="size-5" aria-hidden="true" />
Cerrar sesión en este teléfono
{t('profile.logout')}
</Button>
</div>
)

View File

@@ -1,16 +1,18 @@
import { Megaphone } from 'lucide-react'
import { useTranslation } from 'react-i18next'
/* "Avisos del profe": gruperly doesn't publish announcements yet, so this is
the empty state the feature will fill. */
export function TeacherNoticeCard({ teacherName }: { teacherName: string }) {
const { t } = useTranslation(['student', 'common'])
return (
<section aria-labelledby="notices-title" className="space-y-3">
<h2 id="notices-title" className="text-base font-bold text-primary">
Avisos del profe
{t('home.notices')}
</h2>
<div className="flex gap-3 rounded-2xl border border-dashed border-border px-4 py-5 text-sm text-secondary">
<Megaphone className="size-5 shrink-0" aria-hidden="true" />
<p>Cuando {teacherName} publique un aviso, lo vas a ver acá.</p>
<p>{t('home.noticesEmpty', { teacher: teacherName })}</p>
</div>
</section>
)

View File

@@ -1,18 +1,20 @@
import type { TransferDetails } from '@gruperly/shared'
import { Check, Copy } from 'lucide-react'
import { useCopyToClipboard } from '../attendee-detail/useCopyToClipboard'
import { Trans, useTranslation } from 'react-i18next'
export function TransferDetailsCard({ transfer }: { transfer: TransferDetails }) {
const { copied, copy } = useCopyToClipboard()
const { t } = useTranslation(['student', 'common'])
return (
<section aria-labelledby="transfer-title" className="rounded-2xl border border-border bg-primary-soft p-4">
<h2 id="transfer-title" className="text-sm font-semibold text-primary">
Datos para transferir
{t('transfer.title')}
</h2>
<div className="mt-3 flex items-center justify-between gap-3">
<div className="min-w-0">
<p className="text-xs text-secondary">Alias</p>
<p className="text-xs text-secondary">{t('transfer.alias')}</p>
<p className="truncate font-mono text-base font-semibold text-primary">{transfer.alias}</p>
</div>
<button
@@ -21,12 +23,17 @@ export function TransferDetailsCard({ transfer }: { transfer: TransferDetails })
className="flex min-h-11 shrink-0 items-center gap-2 rounded-xl border border-border bg-surface px-3 text-sm font-medium text-primary hover:bg-primary-soft"
>
{copied ? <Check className="size-4 text-success" aria-hidden="true" /> : <Copy className="size-4" aria-hidden="true" />}
<span aria-live="polite">{copied ? 'Copiado' : 'Copiar'}</span>
<span aria-live="polite">{copied ? t('transfer.copied') : t('transfer.copy')}</span>
</button>
</div>
{transfer.holder ? (
<p className="mt-2 text-sm text-secondary">
Titular: <span className="font-medium text-primary">{transfer.holder}</span>
<Trans
t={t}
i18nKey="transfer.holder"
values={{ holder: transfer.holder }}
components={{ strong: <span className="font-medium text-primary" /> }}
/>
</p>
) : null}
</section>

View File

@@ -1,20 +1,22 @@
import type { StudentClass } from '@gruperly/shared'
import { cn } from '../../lib/utils'
import { formatShortDate, formatTime } from './format'
import { useTranslation } from 'react-i18next'
type WeekClassesListProps = { classes: StudentClass[]; timeZone: string }
/* "Esta semana": past classes dimmed, notified ones struck through with
"Avisaste" next to them (the word, not only the strike, carries it). */
export function WeekClassesList({ classes, timeZone }: WeekClassesListProps) {
const { t } = useTranslation(['student', 'common'])
return (
<section aria-labelledby="week-title" className="space-y-3">
<h2 id="week-title" className="text-base font-bold text-primary">
Esta semana
{t('home.thisWeek')}
</h2>
{classes.length === 0 ? (
<p className="rounded-xl border border-dashed border-border px-4 py-6 text-center text-sm text-secondary">
No tenés clases esta semana.
{t('home.noWeekClasses')}
</p>
) : (
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
@@ -27,9 +29,9 @@ export function WeekClassesList({ classes, timeZone }: WeekClassesListProps) {
</p>
</div>
{item.notice ? (
<span className="shrink-0 rounded-full bg-primary-soft px-2.5 py-0.5 text-xs font-medium text-primary">Avisaste</span>
<span className="shrink-0 rounded-full bg-primary-soft px-2.5 py-0.5 text-xs font-medium text-primary">{t('home.notifiedTag')}</span>
) : item.started ? (
<span className="shrink-0 text-xs text-secondary">Pasó</span>
<span className="shrink-0 text-xs text-secondary">{t('home.past')}</span>
) : null}
</li>
))}

View File

@@ -5,12 +5,14 @@ import { Button, Input, Label } from '../../components/ui'
import { FlowFooter } from './FlowFooter'
import { PasskeyCard } from './PasskeyCard'
import { useStudentApp } from './StudentAppProvider'
import { useTranslation } from 'react-i18next'
/* First sign-in only. Both options are skippable: "Ahora no" goes straight in. */
export function WelcomeView() {
const navigate = useNavigate()
const { finishWelcome, saveRecoveryEmail } = useStudentApp()
const [email, setEmail] = useState('')
const { t } = useTranslation(['student', 'common'])
const goHome = () =>
finishWelcome.mutate(undefined, { onSettled: () => void navigate({ to: '/student', replace: true }) })
@@ -32,9 +34,9 @@ export function WelcomeView() {
<div className="mx-auto flex size-16 items-center justify-center rounded-full bg-success-soft text-success">
<CheckCircle2 className="size-8" aria-hidden="true" />
</div>
<h1 className="mt-4 text-2xl font-bold text-primary">¡Listo, ya estás adentro!</h1>
<h1 className="mt-4 text-2xl font-bold text-primary">{t('welcome.title')}</h1>
<p className="mt-2 text-sm leading-relaxed text-secondary">
Vas a quedar conectado/a en este teléfono. Si querés, sumá una de estas opciones para no perder el acceso.
{t('welcome.description')}
</p>
</div>
@@ -42,11 +44,11 @@ export function WelcomeView() {
<section aria-labelledby="welcome-email-title" className="rounded-2xl border border-border bg-surface p-5">
<h2 id="welcome-email-title" className="text-base font-bold text-primary">
Mail de recuperación <span className="font-normal text-secondary">(opcional)</span>
{t('recovery.title')} <span className="font-normal text-secondary">{t('recovery.optional')}</span>
</h2>
<p className="mt-1 text-sm text-secondary">Te mandamos un link para confirmarlo.</p>
<p className="mt-1 text-sm text-secondary">{t('welcome.emailHint')}</p>
<div className="mt-3 space-y-1.5">
<Label htmlFor="welcome-email">Tu mail</Label>
<Label htmlFor="welcome-email">{t('recovery.label')}</Label>
<Input
id="welcome-email"
type="email"
@@ -59,7 +61,7 @@ export function WelcomeView() {
</div>
{saveRecoveryEmail.isError ? (
<p role="alert" className="mt-2 text-sm text-danger-fg">
Revisá el mail o seguí sin cargarlo.
{t('welcome.emailError')}
</p>
) : null}
</section>
@@ -67,11 +69,11 @@ export function WelcomeView() {
<FlowFooter>
<div className="flex gap-2">
<Button variant="outline" className="h-12 flex-1" onClick={goHome} disabled={busy}>
Ahora no
{t('welcome.later')}
</Button>
<Button variant="primary" className="h-12 flex-1" onClick={handleContinue} disabled={busy}>
{busy ? <Loader2 className="size-5 animate-spin" aria-hidden="true" /> : null}
Continuar
{t('welcome.continue')}
</Button>
</div>
</FlowFooter>

View File

@@ -1,4 +1,5 @@
import type { AbsenceReasonValue, StudentFee } from '@gruperly/shared'
import { i18n } from '../../i18n/instance'
/* Dates of the student app are shown on the teacher's clock (the class time
zone the API returns), not the phone's: "18:00" is when the class starts. */
@@ -18,59 +19,58 @@ export function daysFromToday(iso: string, timeZone: string, now: Date = new Dat
export function formatRelativeDay(iso: string, timeZone: string, now: Date = new Date()): string {
const days = daysFromToday(iso, timeZone, now)
if (days === 0) return 'hoy'
if (days === 1) return 'mañana'
if (days === -1) return 'ayer'
return new Intl.DateTimeFormat('es-AR', { timeZone, weekday: 'long' }).format(new Date(iso))
if (days === 0) return i18n.t('student:today')
if (days === 1) return i18n.t('student:tomorrow')
if (days === -1) return i18n.t('student:yesterday')
return new Intl.DateTimeFormat(i18n.language, { timeZone, weekday: 'long' }).format(new Date(iso))
}
/** "Miércoles 28 de octubre" */
export function formatLongDate(iso: string, timeZone: string): string {
const text = new Intl.DateTimeFormat('es-AR', { timeZone, weekday: 'long', day: 'numeric', month: 'long' }).format(new Date(iso))
const text = new Intl.DateTimeFormat(i18n.language, { timeZone, weekday: 'long', day: 'numeric', month: 'long' }).format(new Date(iso))
return text.charAt(0).toUpperCase() + text.slice(1)
}
/** "mié 28 oct" */
export function formatShortDate(iso: string, timeZone: string): string {
return new Intl.DateTimeFormat('es-AR', { timeZone, weekday: 'short', day: 'numeric', month: 'short' })
return new Intl.DateTimeFormat(i18n.language, { timeZone, weekday: 'short', day: 'numeric', month: 'short' })
.format(new Date(iso))
.replace(/\./g, '')
}
export function formatTime(iso: string, timeZone: string): string {
return new Intl.DateTimeFormat('es-AR', { timeZone, hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(new Date(iso))
return new Intl.DateTimeFormat(i18n.language, { timeZone, hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(new Date(iso))
}
/** Day of month and short month, for the mini date card: { day: '28', month: 'oct' }. */
export function dateParts(iso: string, timeZone: string): { day: string; month: string } {
const date = new Date(iso)
return {
day: new Intl.DateTimeFormat('es-AR', { timeZone, day: 'numeric' }).format(date),
month: new Intl.DateTimeFormat('es-AR', { timeZone, month: 'short' }).format(date).replace('.', ''),
day: new Intl.DateTimeFormat(i18n.language, { timeZone, day: 'numeric' }).format(date),
month: new Intl.DateTimeFormat(i18n.language, { timeZone, month: 'short' }).format(date).replace('.', ''),
}
}
/** Fee title: its description, or the month it is due ("Noviembre"). */
export function feeLabel(fee: Pick<StudentFee, 'description' | 'dueDate'>): string {
if (fee.description) return fee.description
const month = new Intl.DateTimeFormat('es-AR', { month: 'long', timeZone: 'UTC' }).format(new Date(fee.dueDate))
const month = new Intl.DateTimeFormat(i18n.language, { month: 'long', timeZone: 'UTC' }).format(new Date(fee.dueDate))
return month.charAt(0).toUpperCase() + month.slice(1)
}
export function formatDueDate(iso: string): string {
return new Intl.DateTimeFormat('es-AR', { day: 'numeric', month: 'short', timeZone: 'UTC' }).format(new Date(iso)).replace('.', '')
return new Intl.DateTimeFormat(i18n.language, { day: 'numeric', month: 'short', timeZone: 'UTC' }).format(new Date(iso)).replace('.', '')
}
export function formatFileSize(bytes: number): string {
if (bytes < 1024 * 1024) return `${Math.max(1, Math.round(bytes / 1024))} KB`
return `${(bytes / (1024 * 1024)).toFixed(1).replace('.', ',')} MB`
return `${new Intl.NumberFormat(i18n.language, { maximumFractionDigits: 1, minimumFractionDigits: 1 }).format(bytes / (1024 * 1024))} MB`
}
export const ABSENCE_REASON_LABELS: Record<AbsenceReasonValue, string> = {
health: 'Salud',
travel: 'Viaje',
work_study: 'Trabajo o estudio',
other: 'Otro',
export const ABSENCE_REASONS: readonly AbsenceReasonValue[] = ['health', 'travel', 'work_study', 'other']
export function absenceReasonLabel(reason: AbsenceReasonValue): string {
return i18n.t(`student:reason.${reason}`)
}
export function firstName(fullName: string): string {

View File

@@ -1,13 +1,18 @@
import { CalendarDays, Home, User, Wallet, type LucideIcon } from 'lucide-react'
type StudentNavItem = { label: string; to: string; icon: LucideIcon }
/** `label`: key in the `student` namespace (`nav.*`). */
type StudentNavItem = {
label: 'nav.home' | 'nav.classes' | 'nav.payments' | 'nav.profile'
to: string
icon: LucideIcon
}
// Bottom nav of the student app: the single source for StudentBottomNav.
export const STUDENT_NAV_ITEMS: StudentNavItem[] = [
{ label: 'Inicio', to: '/student', icon: Home },
{ label: 'Clases', to: '/student/classes', icon: CalendarDays },
{ label: 'Pagos', to: '/student/payments', icon: Wallet },
{ label: 'Perfil', to: '/student/profile', icon: User },
{ label: 'nav.home', to: '/student', icon: Home },
{ label: 'nav.classes', to: '/student/classes', icon: CalendarDays },
{ label: 'nav.payments', to: '/student/payments', icon: Wallet },
{ label: 'nav.profile', to: '/student/profile', icon: User },
]
/* Flow screens with their own fixed bottom button: no nav there. */