feat: app de alumnos sin contraseña (invitación de un solo uso, avisos de falta y pagos informados)
- 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>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
"@fontsource-variable/inter": "^5.3.0",
|
||||
"@gruperly/shared": "workspace:*",
|
||||
"@hookform/resolvers": "^3.9.0",
|
||||
"@simplewebauthn/browser": "13.3.0",
|
||||
"@tanstack/react-query": "^5.62.0",
|
||||
"@tanstack/react-router": "^1.170.38",
|
||||
"better-auth": "1.7.2",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Link, useLocation } from '@tanstack/react-router'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { NavBadge } from './NavBadge'
|
||||
import { isNavItemActive, NAV_ITEMS } from './nav-items'
|
||||
|
||||
export function BottomNav() {
|
||||
@@ -8,7 +9,7 @@ export function BottomNav() {
|
||||
return (
|
||||
<nav className="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-surface/95 pb-[env(safe-area-inset-bottom)] backdrop-blur lg:hidden">
|
||||
<div className="mx-auto grid max-w-md grid-cols-4">
|
||||
{NAV_ITEMS.map(({ label, to, icon: Icon }) => {
|
||||
{NAV_ITEMS.map(({ label, to, icon: Icon, badge }) => {
|
||||
const isActive = isNavItemActive(location.pathname, to)
|
||||
return (
|
||||
<Link
|
||||
@@ -24,11 +25,12 @@ export function BottomNav() {
|
||||
color + background, not only by the text tone. */}
|
||||
<span
|
||||
className={cn(
|
||||
'flex size-8 items-center justify-center rounded-lg transition-colors duration-150',
|
||||
'relative flex size-8 items-center justify-center rounded-lg transition-colors duration-150',
|
||||
isActive && 'bg-accent-soft',
|
||||
)}
|
||||
>
|
||||
<Icon className="size-5" strokeWidth={isActive ? 2.25 : 2} />
|
||||
{badge ? <NavBadge kind={badge} className="absolute -right-2.5 -top-1.5" /> : null}
|
||||
</span>
|
||||
<span className="leading-none">{label}</span>
|
||||
</Link>
|
||||
|
||||
20
apps/web/src/components/layout/NavBadge.tsx
Normal file
20
apps/web/src/components/layout/NavBadge.tsx
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useReportedPaymentsCount } from '../../features/payments/reportedPayments'
|
||||
import { cn } from '../../lib/utils'
|
||||
|
||||
/* Counter of a nav item: today only "Pagos para verificar" on Cobros. The
|
||||
number is in the accessible name too (sr-only), not only in the dot. */
|
||||
export function NavBadge({ kind, className }: { kind: 'reported-payments'; className?: string }) {
|
||||
const count = useReportedPaymentsCount()
|
||||
if (kind !== 'reported-payments' || count === 0) return null
|
||||
return (
|
||||
<span
|
||||
className={cn(
|
||||
'flex min-w-5 items-center justify-center rounded-full bg-accent px-1.5 text-[11px] font-semibold leading-5 text-on-accent',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{count > 99 ? '99+' : count}
|
||||
<span className="sr-only"> pagos para verificar</span>
|
||||
</span>
|
||||
)
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Link, useLocation } from '@tanstack/react-router'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { Logo } from '../brand'
|
||||
import { NavBadge } from './NavBadge'
|
||||
import { isNavItemActive, NAV_ITEMS } from './nav-items'
|
||||
|
||||
export function Sidebar({ immersive = false }: { immersive?: boolean }) {
|
||||
@@ -23,7 +24,7 @@ export function Sidebar({ immersive = false }: { immersive?: boolean }) {
|
||||
</Link>
|
||||
|
||||
<nav className="flex flex-col gap-1">
|
||||
{NAV_ITEMS.map(({ label, to, icon: Icon }) => {
|
||||
{NAV_ITEMS.map(({ label, to, icon: Icon, badge }) => {
|
||||
const isActive = isNavItemActive(location.pathname, to)
|
||||
return (
|
||||
<Link
|
||||
@@ -39,6 +40,7 @@ export function Sidebar({ immersive = false }: { immersive?: boolean }) {
|
||||
>
|
||||
<Icon className="size-5" strokeWidth={isActive ? 2.2 : 2} />
|
||||
{label}
|
||||
{badge ? <NavBadge kind={badge} className="ml-auto" /> : null}
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -4,12 +4,14 @@ export type NavItem = {
|
||||
label: string
|
||||
to: string
|
||||
icon: LucideIcon
|
||||
/** Counter shown on the item (see NavBadge). */
|
||||
badge?: 'reported-payments'
|
||||
}
|
||||
|
||||
export const NAV_ITEMS: NavItem[] = [
|
||||
{ label: 'Inicio', to: '/', icon: Home },
|
||||
{ label: 'Grupos', to: '/groups', icon: Users },
|
||||
{ label: 'Cobros', to: '/payments', icon: Wallet },
|
||||
{ label: 'Cobros', to: '/payments', icon: Wallet, badge: 'reported-payments' },
|
||||
{ label: 'Ajustes', to: '/settings', icon: Settings },
|
||||
]
|
||||
|
||||
|
||||
@@ -8,3 +8,4 @@ export { type Toast, ToastProvider, type ToastType, useToast } from './toast'
|
||||
export { Tooltip, type TooltipProps } from './tooltip'
|
||||
|
||||
export { Switch, type SwitchProps } from './switch'
|
||||
export { Sheet, type SheetProps } from './sheet'
|
||||
|
||||
83
apps/web/src/components/ui/sheet.tsx
Normal file
83
apps/web/src/components/ui/sheet.tsx
Normal file
@@ -0,0 +1,83 @@
|
||||
import { useEffect, useId, useRef, type ReactNode } from 'react'
|
||||
import { X } from 'lucide-react'
|
||||
import { cn } from '../../lib/utils'
|
||||
|
||||
export type SheetProps = {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
title: string
|
||||
description?: string
|
||||
children: ReactNode
|
||||
className?: string
|
||||
}
|
||||
|
||||
/* Bottom sheet on mobile (anchored to the bottom edge, above the home
|
||||
indicator) and a centered dialog from `sm` up. Escape and the backdrop close
|
||||
it; focus moves into the panel on open and goes back where it was on close. */
|
||||
export function Sheet({ isOpen, onClose, title, description, children, className }: SheetProps) {
|
||||
const titleId = useId()
|
||||
const descriptionId = useId()
|
||||
const panelRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOpen) return
|
||||
const previous = document.activeElement as HTMLElement | null
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') onClose()
|
||||
}
|
||||
window.addEventListener('keydown', handleKeyDown)
|
||||
document.body.style.overflow = 'hidden'
|
||||
panelRef.current?.focus()
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown)
|
||||
document.body.style.overflow = 'unset'
|
||||
previous?.focus?.()
|
||||
}
|
||||
}, [isOpen, onClose])
|
||||
|
||||
if (!isOpen) return null
|
||||
|
||||
return (
|
||||
<div
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby={titleId}
|
||||
aria-describedby={description ? descriptionId : undefined}
|
||||
className="fixed inset-0 z-50 flex items-end justify-center sm:items-center sm:p-4"
|
||||
>
|
||||
<div className="fixed inset-0 animate-fade-in bg-black/60 backdrop-blur-xs" onClick={onClose} aria-hidden="true" />
|
||||
<div
|
||||
ref={panelRef}
|
||||
tabIndex={-1}
|
||||
className={cn(
|
||||
'relative max-h-[90dvh] w-full overflow-y-auto rounded-t-2xl border border-border bg-surface p-5 pb-[calc(1.25rem+env(safe-area-inset-bottom))] shadow-2xl outline-none animate-fade-in sm:max-w-md sm:rounded-2xl sm:pb-5',
|
||||
className,
|
||||
)}
|
||||
>
|
||||
{/* Grab handle: a visual cue only, the sheet closes with X, Escape or the backdrop. */}
|
||||
<div className="mx-auto mb-3 h-1 w-10 rounded-full bg-border sm:hidden" aria-hidden="true" />
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h2 id={titleId} className="text-lg font-bold text-primary">
|
||||
{title}
|
||||
</h2>
|
||||
{description ? (
|
||||
<p id={descriptionId} className="mt-1 text-sm text-foreground">
|
||||
{description}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onClose}
|
||||
className="-mr-2 -mt-2 flex size-11 shrink-0 items-center justify-center rounded-xl text-foreground hover:bg-primary-soft hover:text-primary"
|
||||
aria-label="Cerrar"
|
||||
>
|
||||
<X className="size-5" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="mt-4">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import { useAttendeeDetail } from './AttendeeDetailProvider'
|
||||
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()
|
||||
@@ -86,6 +87,7 @@ export function AttendeeDetailView() {
|
||||
|
||||
<div className="mt-6">
|
||||
<AttendeeContactSection />
|
||||
<StudentAccessSection />
|
||||
<AttendeePaymentsSection />
|
||||
<AttendeeAttendanceSection />
|
||||
<AttendeeNotesSection />
|
||||
|
||||
141
apps/web/src/features/attendee-detail/InviteToAppSheet.tsx
Normal file
141
apps/web/src/features/attendee-detail/InviteToAppSheet.tsx
Normal file
@@ -0,0 +1,141 @@
|
||||
import { useState } from 'react'
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
||||
import type { StudentInvitationDto } from '@gruperly/shared'
|
||||
import { Check, Copy, Loader2, Lock, MessageCircle } from 'lucide-react'
|
||||
import { Sheet } from '../../components/ui'
|
||||
import { inviteStudent } from '../../lib/api'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { ACTION_BUTTON_CLASS, PRIMARY_ACTION_CLASS } from './actionButton'
|
||||
import { invitationMessage } from './studentAccess'
|
||||
|
||||
type InviteToAppSheetProps = {
|
||||
isOpen: boolean
|
||||
onClose: () => void
|
||||
groupId: string
|
||||
groupName: string
|
||||
attendeeId: string
|
||||
fullName: string
|
||||
hasPhone: boolean
|
||||
/** Reinviting closes the current access: the copy says so. */
|
||||
reinvite: boolean
|
||||
}
|
||||
|
||||
/* "Invitar a la app". The link is generated on the first send/copy (not on
|
||||
open): generating it revokes any previous access, so just looking at the
|
||||
sheet must not do that. Within the same sheet the link is reused. */
|
||||
export function InviteToAppSheet({
|
||||
isOpen,
|
||||
onClose,
|
||||
groupId,
|
||||
groupName,
|
||||
attendeeId,
|
||||
fullName,
|
||||
hasPhone,
|
||||
reinvite,
|
||||
}: InviteToAppSheetProps) {
|
||||
const queryClient = useQueryClient()
|
||||
const [invitation, setInvitation] = useState<StudentInvitationDto | null>(null)
|
||||
const [copied, setCopied] = useState(false)
|
||||
const firstName = fullName.split(' ')[0] ?? fullName
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: () => inviteStudent(groupId, attendeeId),
|
||||
onSuccess: (result) => {
|
||||
setInvitation(result)
|
||||
queryClient.setQueryData(['student-access', groupId, attendeeId], result.access)
|
||||
},
|
||||
})
|
||||
|
||||
const ensureInvitation = async () => invitation ?? (await mutation.mutateAsync())
|
||||
|
||||
const handleClose = () => {
|
||||
setInvitation(null)
|
||||
setCopied(false)
|
||||
mutation.reset()
|
||||
onClose()
|
||||
}
|
||||
|
||||
const sendWhatsapp = async () => {
|
||||
// Opened synchronously, inside the tap: a window opened after an await is
|
||||
// blocked by Safari. It's pointed at WhatsApp once the link exists.
|
||||
const popup = window.open('', '_blank')
|
||||
try {
|
||||
const result = await ensureInvitation()
|
||||
const text = encodeURIComponent(invitationMessage(firstName, groupName, result.url))
|
||||
const target = result.whatsappPhone
|
||||
? `https://wa.me/${result.whatsappPhone.replace(/\D/g, '')}?text=${text}`
|
||||
: `https://wa.me/?text=${text}`
|
||||
if (popup) popup.location.href = target
|
||||
else window.location.href = target
|
||||
} catch {
|
||||
popup?.close()
|
||||
}
|
||||
}
|
||||
|
||||
const copyLink = async () => {
|
||||
try {
|
||||
// ClipboardItem with a promise keeps the user gesture while the link is
|
||||
// generated (Safari drops it after an await); writeText is the fallback.
|
||||
if (!invitation && typeof ClipboardItem !== 'undefined' && navigator.clipboard?.write) {
|
||||
const blob = ensureInvitation().then((result) => new Blob([result.url], { type: 'text/plain' }))
|
||||
await navigator.clipboard.write([new ClipboardItem({ 'text/plain': blob })])
|
||||
} else {
|
||||
const result = await ensureInvitation()
|
||||
await navigator.clipboard.writeText(result.url)
|
||||
}
|
||||
setCopied(true)
|
||||
} catch {
|
||||
setCopied(false)
|
||||
}
|
||||
}
|
||||
|
||||
const preview = invitationMessage(firstName, groupName, invitation?.url ?? '🔗 link personal')
|
||||
|
||||
return (
|
||||
<Sheet
|
||||
isOpen={isOpen}
|
||||
onClose={handleClose}
|
||||
title={reinvite ? 'Reinvitar a la app' : 'Invitar a la app'}
|
||||
description={
|
||||
reinvite
|
||||
? `Mandale un link nuevo a ${firstName}. El acceso anterior deja de funcionar.`
|
||||
: `${firstName} va a poder avisar faltas, informar pagos y ver sus próximas clases. Sin contraseñas ni datos nuevos.`
|
||||
}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<div className="rounded-2xl rounded-tl-sm bg-success-soft px-4 py-3 text-sm text-primary" aria-label="Vista previa del mensaje">
|
||||
{preview}
|
||||
</div>
|
||||
|
||||
<p className="flex gap-2 rounded-xl bg-primary-soft px-3 py-2.5 text-xs leading-relaxed text-secondary">
|
||||
<Lock className="mt-0.5 size-4 shrink-0 text-primary" aria-hidden="true" />
|
||||
El link es personal, sirve una sola vez y vence en 72 horas. Queda conectado el primer teléfono que lo abra.
|
||||
</p>
|
||||
|
||||
{mutation.isError ? (
|
||||
<p role="alert" className="text-sm text-danger-fg">
|
||||
No pudimos generar el link. Probá de nuevo.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
{hasPhone ? (
|
||||
<button type="button" onClick={() => void sendWhatsapp()} disabled={mutation.isPending} className={PRIMARY_ACTION_CLASS}>
|
||||
{mutation.isPending ? <Loader2 className="size-4 animate-spin" aria-hidden="true" /> : <MessageCircle className="size-4" aria-hidden="true" />}
|
||||
Enviar por WhatsApp
|
||||
</button>
|
||||
) : null}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void copyLink()}
|
||||
disabled={mutation.isPending}
|
||||
className={cn(hasPhone ? ACTION_BUTTON_CLASS : PRIMARY_ACTION_CLASS, 'w-full')}
|
||||
>
|
||||
{copied ? <Check className="size-4" aria-hidden="true" /> : <Copy className="size-4" aria-hidden="true" />}
|
||||
<span aria-live="polite">{copied ? 'Link copiado' : 'Copiar link'}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</Sheet>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import { useState } from 'react'
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { MessageCircle, Smartphone, UserPlus } from 'lucide-react'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { getStudentAccess } from '../../lib/api'
|
||||
import { useAttendeeDetail } from './AttendeeDetailProvider'
|
||||
import { ACTION_BUTTON_CLASS, PRIMARY_ACTION_CLASS } from './actionButton'
|
||||
import { InviteToAppSheet } from './InviteToAppSheet'
|
||||
import { Section } from './Section'
|
||||
import { accessBadge, formatAgo, formatSince } from './studentAccess'
|
||||
|
||||
/* "Acceso a la app": passive state, nothing to manage. The only action is
|
||||
inviting (or reinviting, which closes the previous access). */
|
||||
export function StudentAccessSection() {
|
||||
const { groupId, groupName, attendee } = useAttendeeDetail()
|
||||
const [sheetOpen, setSheetOpen] = useState(false)
|
||||
|
||||
const accessQuery = useQuery({
|
||||
queryKey: ['student-access', groupId, attendee?.id],
|
||||
queryFn: () => getStudentAccess(groupId, attendee?.id as string),
|
||||
enabled: Boolean(attendee),
|
||||
})
|
||||
|
||||
if (!attendee) return null
|
||||
const access = accessQuery.data
|
||||
const badge = access ? accessBadge(access) : null
|
||||
const invited = access ? access.status !== 'not_invited' : false
|
||||
const hasPhone = Boolean(attendee.phone || attendee.guardianPhone)
|
||||
|
||||
return (
|
||||
<Section title="Acceso a la app" trailing={badge ? <Badge variant={badge.variant}>{badge.label}</Badge> : null}>
|
||||
<div className="space-y-3 px-3">
|
||||
{access?.status === 'active'
|
||||
? access.devices.map((device) => (
|
||||
<div key={device.createdAt} className="flex items-start gap-3 rounded-xl bg-primary-soft px-3 py-2.5">
|
||||
<Smartphone className="mt-0.5 size-5 shrink-0 text-primary" aria-hidden="true" />
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-medium text-primary">{device.device}</p>
|
||||
<p className="text-xs text-secondary">
|
||||
Desde el {formatSince(device.createdAt)} · último uso {formatAgo(device.lastUsedAt)}
|
||||
{access.hasPasskey ? ' · Face ID' : ''}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
: null}
|
||||
|
||||
{access?.status === 'not_invited' ? (
|
||||
<p className="text-sm text-secondary">Para que avise faltas e informe pagos desde su teléfono.</p>
|
||||
) : null}
|
||||
|
||||
{invited ? (
|
||||
<p className="text-xs text-secondary">
|
||||
¿Te dice que no puede entrar? Mandale un link nuevo: cierra el acceso anterior.
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{access ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setSheetOpen(true)}
|
||||
className={invited ? `${ACTION_BUTTON_CLASS} w-full` : PRIMARY_ACTION_CLASS}
|
||||
>
|
||||
{invited ? <MessageCircle className="size-4" aria-hidden="true" /> : <UserPlus className="size-4" aria-hidden="true" />}
|
||||
{invited ? (hasPhone ? 'Reinvitar por WhatsApp' : 'Reinvitar') : 'Invitar a la app'}
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<InviteToAppSheet
|
||||
isOpen={sheetOpen}
|
||||
onClose={() => setSheetOpen(false)}
|
||||
groupId={groupId}
|
||||
groupName={groupName ?? 'tu grupo'}
|
||||
attendeeId={attendee.id}
|
||||
fullName={attendee.fullName}
|
||||
hasPhone={hasPhone}
|
||||
reinvite={invited}
|
||||
/>
|
||||
</Section>
|
||||
)
|
||||
}
|
||||
39
apps/web/src/features/attendee-detail/studentAccess.ts
Normal file
39
apps/web/src/features/attendee-detail/studentAccess.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import type { StudentAccessDto } from '@gruperly/shared'
|
||||
import type { BadgeVariant } from '../../components/ui'
|
||||
|
||||
const HOUR_MS = 3_600_000
|
||||
const DAY_MS = 24 * HOUR_MS
|
||||
|
||||
export function accessBadge(access: StudentAccessDto, now: Date = new Date()): { label: string; variant: BadgeVariant } {
|
||||
switch (access.status) {
|
||||
case 'active':
|
||||
return { label: 'Activo', variant: 'success' }
|
||||
case 'invited': {
|
||||
const hours = access.invitationExpiresAt
|
||||
? Math.max(1, Math.ceil((Date.parse(access.invitationExpiresAt) - now.getTime()) / HOUR_MS))
|
||||
: null
|
||||
return { label: hours ? `Invitado · vence en ${hours} h` : 'Invitado', variant: 'info' }
|
||||
}
|
||||
case 'expired':
|
||||
return { label: 'Vencido', variant: 'warning' }
|
||||
default:
|
||||
return { label: 'Sin invitar', variant: 'neutral' }
|
||||
}
|
||||
}
|
||||
|
||||
/** "hace 5 min", "hace 3 h", "ayer", "hace 4 días". */
|
||||
export function formatAgo(iso: string, now: Date = new Date()): string {
|
||||
const diff = Math.max(0, now.getTime() - Date.parse(iso))
|
||||
if (diff < HOUR_MS) return `hace ${Math.max(1, Math.round(diff / 60_000))} min`
|
||||
if (diff < DAY_MS) return `hace ${Math.round(diff / HOUR_MS)} h`
|
||||
const days = Math.round(diff / DAY_MS)
|
||||
return days === 1 ? 'ayer' : `hace ${days} días`
|
||||
}
|
||||
|
||||
export function formatSince(iso: string): string {
|
||||
return new Date(iso).toLocaleDateString('es-AR', { day: 'numeric', month: 'long' })
|
||||
}
|
||||
|
||||
export function invitationMessage(firstName: string, groupName: string, url: string): string {
|
||||
return `¡Hola ${firstName}! Te invito a gruperly para avisar faltas e informar pagos de ${groupName}. ${url}`
|
||||
}
|
||||
56
apps/web/src/features/groups/detail/AbsenceNoticesCard.tsx
Normal file
56
apps/web/src/features/groups/detail/AbsenceNoticesCard.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { AbsenceReasonValue } from '@gruperly/shared'
|
||||
import { Avatar, Badge } from '../../../components/ui'
|
||||
import { getGroupAbsenceNotices } from '../../../lib/api'
|
||||
import { useGroupDetail } from './GroupDetailProvider'
|
||||
|
||||
const REASON_LABELS: Record<AbsenceReasonValue, string> = {
|
||||
health: 'Salud',
|
||||
travel: 'Viaje',
|
||||
work_study: 'Trabajo o estudio',
|
||||
other: 'Otro',
|
||||
}
|
||||
|
||||
function classLabel(iso: string): string {
|
||||
return new Date(iso)
|
||||
.toLocaleString('es-AR', { weekday: 'short', day: 'numeric', hour: '2-digit', minute: '2-digit', hourCycle: 'h23' })
|
||||
.replace(/\./g, '')
|
||||
}
|
||||
|
||||
/* "Faltas avisadas · esta semana": what students said from the app. Only shown
|
||||
when there is something to show, so it doesn't push the members list down. */
|
||||
export function AbsenceNoticesCard() {
|
||||
const { groupId } = useGroupDetail()
|
||||
const query = useQuery({
|
||||
queryKey: ['absence-notices', groupId],
|
||||
queryFn: () => getGroupAbsenceNotices(groupId),
|
||||
})
|
||||
const notices = query.data?.data ?? []
|
||||
if (notices.length === 0) return null
|
||||
|
||||
return (
|
||||
<section aria-labelledby="absence-notices-title" className="rounded-xl border border-border bg-surface">
|
||||
<h2 id="absence-notices-title" className="px-4 pt-4 text-sm font-semibold text-primary">
|
||||
Faltas avisadas · esta semana
|
||||
</h2>
|
||||
<ul className="divide-y divide-border">
|
||||
{notices.map((notice) => (
|
||||
<li key={notice.id} className="flex items-start gap-3 px-4 py-3">
|
||||
<Avatar name={notice.attendee.fullName} className="size-9 rounded-full bg-accent-soft text-accent-fg" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<p className="truncate text-sm font-medium text-primary">{notice.attendee.fullName}</p>
|
||||
<Badge variant="success">Justificada</Badge>
|
||||
</div>
|
||||
<p className="text-xs capitalize text-secondary">
|
||||
{classLabel(notice.startsAt)}
|
||||
{notice.reason ? ` · ${REASON_LABELS[notice.reason]}` : ''}
|
||||
</p>
|
||||
{notice.message ? <p className="mt-1 text-sm text-primary">“{notice.message}”</p> : null}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -18,6 +18,7 @@ import { PreRegistrationDetailModal } from './PreRegistrationDetailModal'
|
||||
import { RemoveAttendeeModal } from './RemoveAttendeeModal'
|
||||
import { useGroupDetail } from './GroupDetailProvider'
|
||||
import { WaitlistEntryDetailModal } from './WaitlistEntryDetailModal'
|
||||
import { AbsenceNoticesCard } from './AbsenceNoticesCard'
|
||||
|
||||
export function GroupDetailView() {
|
||||
const {
|
||||
@@ -70,6 +71,7 @@ export function GroupDetailView() {
|
||||
) : (
|
||||
<>
|
||||
<GroupInfoCard />
|
||||
<AbsenceNoticesCard />
|
||||
<GroupAutomationsCard />
|
||||
<MembersWaitlistSection />
|
||||
</>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ChevronLeft, ChevronRight, Loader2, Wallet } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { PaymentRow } from './PaymentRow'
|
||||
import { ReportedPaymentsSection } from './ReportedPaymentsSection'
|
||||
import { usePayments } from './PaymentsProvider'
|
||||
|
||||
const STATUS_FILTERS: readonly { value: 'ALL' | PaymentStatus; label: string }[] = [
|
||||
@@ -43,6 +44,8 @@ export function PaymentsView() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ReportedPaymentsSection />
|
||||
|
||||
{/* Filtros: el grupo primera (cada cobro cuelga de un grupo) y el estado. */}
|
||||
<div className="mt-5 space-y-3">
|
||||
<label className="block">
|
||||
|
||||
55
apps/web/src/features/payments/ReceiptViewer.tsx
Normal file
55
apps/web/src/features/payments/ReceiptViewer.tsx
Normal file
@@ -0,0 +1,55 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { ExternalLink, FileText, Loader2 } from 'lucide-react'
|
||||
import { Sheet } from '../../components/ui'
|
||||
import { getReceiptUrl } from '../../lib/api'
|
||||
|
||||
const INLINE_IMAGES = new Set(['image/jpeg', 'image/png', 'image/webp'])
|
||||
|
||||
type ReceiptViewerProps = { reportId: string | null; title: string; onClose: () => void }
|
||||
|
||||
/* The file is private: each open asks for a fresh signed URL (5 minutes). */
|
||||
export function ReceiptViewer({ reportId, title, onClose }: ReceiptViewerProps) {
|
||||
const query = useQuery({
|
||||
queryKey: ['receipt-url', reportId],
|
||||
queryFn: () => getReceiptUrl(reportId as string),
|
||||
enabled: reportId !== null,
|
||||
staleTime: 0,
|
||||
gcTime: 0,
|
||||
})
|
||||
|
||||
return (
|
||||
<Sheet isOpen={reportId !== null} onClose={onClose} title="Comprobante" description={title}>
|
||||
{query.isPending ? (
|
||||
<div className="flex justify-center py-10" role="status" aria-label="Cargando comprobante">
|
||||
<Loader2 className="size-6 animate-spin text-accent" aria-hidden="true" />
|
||||
</div>
|
||||
) : query.isError || !query.data ? (
|
||||
<p role="alert" className="py-6 text-center text-sm text-danger-fg">
|
||||
No pudimos abrir el comprobante.
|
||||
</p>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{INLINE_IMAGES.has(query.data.mime) ? (
|
||||
<img src={query.data.url} alt={`Comprobante: ${query.data.name}`} className="max-h-[60dvh] w-full rounded-xl object-contain" />
|
||||
) : query.data.mime === 'application/pdf' ? (
|
||||
<iframe src={query.data.url} title={`Comprobante: ${query.data.name}`} className="h-[60dvh] w-full rounded-xl border border-border" />
|
||||
) : (
|
||||
<div className="flex items-center gap-3 rounded-xl bg-primary-soft p-4 text-sm text-primary">
|
||||
<FileText className="size-6 shrink-0" aria-hidden="true" />
|
||||
<span className="min-w-0 truncate">{query.data.name}</span>
|
||||
</div>
|
||||
)}
|
||||
<a
|
||||
href={query.data.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex min-h-11 items-center justify-center gap-2 rounded-xl border border-border text-sm font-medium text-primary hover:bg-primary-soft"
|
||||
>
|
||||
<ExternalLink className="size-4" aria-hidden="true" />
|
||||
Abrir en otra pestaña
|
||||
</a>
|
||||
</div>
|
||||
)}
|
||||
</Sheet>
|
||||
)
|
||||
}
|
||||
163
apps/web/src/features/payments/ReportedPaymentCard.tsx
Normal file
163
apps/web/src/features/payments/ReportedPaymentCard.tsx
Normal file
@@ -0,0 +1,163 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import type { ReportedPaymentDto } from '@gruperly/shared'
|
||||
import { Check, ChevronRight, FileText, Loader2, X } from 'lucide-react'
|
||||
import { Avatar, Button, Input, Label } from '../../components/ui'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
|
||||
const UNDO_MS = 6000
|
||||
|
||||
type Outcome = 'confirmed' | 'rejected'
|
||||
|
||||
type ReportedPaymentCardProps = {
|
||||
report: ReportedPaymentDto
|
||||
onOpenReceipt: () => void
|
||||
onConfirm: () => Promise<unknown>
|
||||
onReject: (reason: string | null) => Promise<unknown>
|
||||
onUndo: () => Promise<unknown>
|
||||
/** The undo window closed: the card leaves the list. */
|
||||
onSettled: () => void
|
||||
}
|
||||
|
||||
function feeName(fee: ReportedPaymentDto['fees'][number]): string {
|
||||
if (fee.description) return fee.description
|
||||
const month = new Date(fee.dueDate).toLocaleDateString('es-AR', { month: 'long', timeZone: 'UTC' })
|
||||
return month.charAt(0).toUpperCase() + month.slice(1)
|
||||
}
|
||||
|
||||
export function ReportedPaymentCard({ report, onOpenReceipt, onConfirm, onReject, onUndo, onSettled }: ReportedPaymentCardProps) {
|
||||
const [outcome, setOutcome] = useState<Outcome | null>(null)
|
||||
const [rejecting, setRejecting] = useState(false)
|
||||
const [reason, setReason] = useState('')
|
||||
const [busy, setBusy] = useState(false)
|
||||
const [failed, setFailed] = useState(false)
|
||||
const timer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
|
||||
useEffect(() => () => {
|
||||
if (timer.current) clearTimeout(timer.current)
|
||||
}, [])
|
||||
|
||||
const run = async (action: () => Promise<unknown>, next: Outcome | null) => {
|
||||
setBusy(true)
|
||||
setFailed(false)
|
||||
try {
|
||||
await action()
|
||||
setOutcome(next)
|
||||
setRejecting(false)
|
||||
if (timer.current) clearTimeout(timer.current)
|
||||
if (next) timer.current = setTimeout(onSettled, UNDO_MS)
|
||||
} catch {
|
||||
setFailed(true)
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const amount = formatPrice(report.totalAmount, report.currency)
|
||||
const reportedAt = new Date(report.createdAt).toLocaleString('es-AR', {
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
})
|
||||
|
||||
if (outcome) {
|
||||
return (
|
||||
<li role="status" className="flex items-center justify-between gap-3 rounded-2xl border border-border bg-surface p-4">
|
||||
<p className="flex min-w-0 items-center gap-2 text-sm text-primary">
|
||||
{outcome === 'confirmed' ? (
|
||||
<Check className="size-5 shrink-0 text-success" aria-hidden="true" />
|
||||
) : (
|
||||
<X className="size-5 shrink-0 text-danger-fg" aria-hidden="true" />
|
||||
)}
|
||||
<span className="truncate">
|
||||
{outcome === 'confirmed' ? 'Confirmado' : 'Rechazado'}: {report.attendee.fullName} · {amount}
|
||||
</span>
|
||||
</p>
|
||||
<Button variant="outline" className="h-11 shrink-0" onClick={() => void run(onUndo, null)} disabled={busy}>
|
||||
Deshacer
|
||||
</Button>
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<li className="rounded-2xl border border-border bg-surface p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<Avatar name={report.attendee.fullName} className="size-10 rounded-full bg-accent-soft text-accent-fg" />
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate font-semibold text-primary">{report.attendee.fullName}</p>
|
||||
<p className="truncate text-xs text-secondary">
|
||||
{report.group.name} · {reportedAt}
|
||||
</p>
|
||||
</div>
|
||||
<p className="shrink-0 text-base font-bold text-primary">{amount}</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onOpenReceipt}
|
||||
disabled={!report.receipt.available}
|
||||
className="mt-3 flex min-h-14 w-full items-center gap-3 rounded-xl bg-primary-soft p-2 text-left hover:bg-accent-soft disabled:opacity-60"
|
||||
>
|
||||
<span className="flex size-12 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface">
|
||||
{report.receipt.thumbnailUrl ? (
|
||||
<img src={report.receipt.thumbnailUrl} alt="" className="size-full object-cover" />
|
||||
) : (
|
||||
<FileText className="size-5 text-foreground" aria-hidden="true" />
|
||||
)}
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block text-sm font-medium text-primary">
|
||||
{report.receipt.available ? 'Ver comprobante' : 'Comprobante eliminado'}
|
||||
</span>
|
||||
<span className="block truncate text-xs text-secondary">{report.fees.map(feeName).join(', ')}</span>
|
||||
</span>
|
||||
<ChevronRight className="size-4 shrink-0 text-foreground" aria-hidden="true" />
|
||||
</button>
|
||||
|
||||
{rejecting ? (
|
||||
<form
|
||||
className="mt-3 space-y-2"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault()
|
||||
void run(() => onReject(reason.trim() || null), 'rejected')
|
||||
}}
|
||||
>
|
||||
<Label htmlFor={`reject-${report.id}`}>Motivo (opcional, lo ve el alumno)</Label>
|
||||
<Input id={`reject-${report.id}`} autoFocus maxLength={300} value={reason} onChange={(event) => setReason(event.target.value)} className="h-11" />
|
||||
<div className="flex gap-2">
|
||||
<Button variant="ghost" className="h-11 flex-1" onClick={() => setRejecting(false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
<Button type="submit" variant="outline" className="h-11 flex-1" disabled={busy}>
|
||||
{busy ? <Loader2 className="size-4 animate-spin" aria-hidden="true" /> : null}
|
||||
Rechazar pago
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<div className="mt-3 flex gap-2">
|
||||
<Button variant="outline" className="h-11 flex-1" onClick={() => setRejecting(true)} disabled={busy}>
|
||||
Rechazar
|
||||
</Button>
|
||||
<Button
|
||||
// Light fill, `primary` text (the green on its soft tint misses 4.5:1);
|
||||
// the green stays on the check, next to the word.
|
||||
className="h-11 flex-1 border border-success/40 bg-success-soft font-semibold text-primary hover:bg-success-soft/70"
|
||||
onClick={() => void run(onConfirm, 'confirmed')}
|
||||
disabled={busy}
|
||||
>
|
||||
{busy ? <Loader2 className="size-4 animate-spin" aria-hidden="true" /> : <Check className="size-4 text-success" strokeWidth={3} aria-hidden="true" />}
|
||||
Confirmar
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
{failed ? (
|
||||
<p role="alert" className="mt-2 text-sm text-danger-fg">
|
||||
No pudimos guardar el cambio. Probá de nuevo.
|
||||
</p>
|
||||
) : null}
|
||||
</li>
|
||||
)
|
||||
}
|
||||
52
apps/web/src/features/payments/ReportedPaymentsSection.tsx
Normal file
52
apps/web/src/features/payments/ReportedPaymentsSection.tsx
Normal file
@@ -0,0 +1,52 @@
|
||||
import { useState } from 'react'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import type { ReportedPaymentDto } from '@gruperly/shared'
|
||||
import { confirmReportedPayment, rejectReportedPayment, undoPaymentReview } from '../../lib/api'
|
||||
import { ReceiptViewer } from './ReceiptViewer'
|
||||
import { ReportedPaymentCard } from './ReportedPaymentCard'
|
||||
import { REPORTED_PAYMENTS_KEY, useReportedPayments } from './reportedPayments'
|
||||
|
||||
/* "Pagos para verificar": receipts the students reported. Confirming marks the
|
||||
fees as paid; a reviewed card stays a few seconds with "Deshacer" before it
|
||||
leaves the list. */
|
||||
export function ReportedPaymentsSection() {
|
||||
const queryClient = useQueryClient()
|
||||
const { data } = useReportedPayments()
|
||||
const [viewing, setViewing] = useState<ReportedPaymentDto | null>(null)
|
||||
const reports = data?.data ?? []
|
||||
|
||||
if (reports.length === 0) return null
|
||||
|
||||
// Fees and alerts moved: Cobros, Inicio and "Requiere atención" refetch.
|
||||
const refreshDerived = () => {
|
||||
void queryClient.invalidateQueries({ queryKey: ['payments'] })
|
||||
void queryClient.invalidateQueries({ queryKey: ['attention'] })
|
||||
}
|
||||
|
||||
return (
|
||||
<section aria-labelledby="to-verify-title" className="mt-5 space-y-3">
|
||||
<h2 id="to-verify-title" className="flex items-center gap-2 text-base font-bold text-primary">
|
||||
Pagos para verificar
|
||||
<span className="rounded-full bg-accent px-2 py-0.5 text-xs font-semibold text-on-accent">{reports.length}</span>
|
||||
</h2>
|
||||
<ul className="space-y-3">
|
||||
{reports.map((report) => (
|
||||
<ReportedPaymentCard
|
||||
key={report.id}
|
||||
report={report}
|
||||
onOpenReceipt={() => setViewing(report)}
|
||||
onConfirm={() => confirmReportedPayment(report.id).then(refreshDerived)}
|
||||
onReject={(reason) => rejectReportedPayment(report.id, reason).then(refreshDerived)}
|
||||
onUndo={() => undoPaymentReview(report.id).then(refreshDerived)}
|
||||
onSettled={() => void queryClient.invalidateQueries({ queryKey: REPORTED_PAYMENTS_KEY })}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
<ReceiptViewer
|
||||
reportId={viewing?.id ?? null}
|
||||
title={viewing ? `${viewing.attendee.fullName} · ${viewing.group.name}` : ''}
|
||||
onClose={() => setViewing(null)}
|
||||
/>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
20
apps/web/src/features/payments/reportedPayments.ts
Normal file
20
apps/web/src/features/payments/reportedPayments.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { getReportedPayments } from '../../lib/api'
|
||||
|
||||
/* Shared by Cobros ("Pagos para verificar") and the badge of the Cobros tab. */
|
||||
export const REPORTED_PAYMENTS_KEY = ['reported-payments'] as const
|
||||
|
||||
export function useReportedPayments(enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: REPORTED_PAYMENTS_KEY,
|
||||
queryFn: getReportedPayments,
|
||||
enabled,
|
||||
// The thumbnails are signed for 5 minutes: refresh before they expire.
|
||||
staleTime: 60_000,
|
||||
refetchInterval: 4 * 60_000,
|
||||
})
|
||||
}
|
||||
|
||||
export function useReportedPaymentsCount(): number {
|
||||
return useReportedPayments().data?.data.length ?? 0
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { PlanSettingsCard } from '../billing'
|
||||
import { MpStatusCard } from '../mp'
|
||||
import { WhatsappStatusCard } from '../whatsapp'
|
||||
import { AppearanceCard } from './AppearanceCard'
|
||||
import { TransferDetailsSettingsCard } from './TransferDetailsSettingsCard'
|
||||
import { useCallbackFeedbackToast } from './useCallbackFeedbackToast'
|
||||
|
||||
export function SettingsView() {
|
||||
@@ -42,6 +43,8 @@ export function SettingsView() {
|
||||
|
||||
<MpStatusCard />
|
||||
|
||||
<TransferDetailsSettingsCard />
|
||||
|
||||
<WhatsappStatusCard />
|
||||
|
||||
<AppearanceCard />
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { Landmark, Loader2 } from 'lucide-react'
|
||||
import { Button, Input, Label, useToast } from '../../components/ui'
|
||||
import { getTransferDetails, updateTransferDetails } from '../../lib/api'
|
||||
|
||||
const KEY = ['transfer-details'] as const
|
||||
|
||||
/* Alias and holder students see in "Informar pago". Optional: without an alias
|
||||
the card for transfers just isn't shown to them. */
|
||||
export function TransferDetailsSettingsCard() {
|
||||
const queryClient = useQueryClient()
|
||||
const toast = useToast()
|
||||
const query = useQuery({ queryKey: KEY, queryFn: getTransferDetails })
|
||||
const [editing, setEditing] = useState(false)
|
||||
const [alias, setAlias] = useState('')
|
||||
const [holder, setHolder] = useState('')
|
||||
|
||||
const mutation = useMutation({
|
||||
mutationFn: updateTransferDetails,
|
||||
onSuccess: (data) => {
|
||||
queryClient.setQueryData(KEY, data)
|
||||
setEditing(false)
|
||||
toast.success('Datos para transferir guardados')
|
||||
},
|
||||
onError: () => toast.error('No pudimos guardar los datos'),
|
||||
})
|
||||
|
||||
const startEditing = () => {
|
||||
setAlias(query.data?.alias ?? '')
|
||||
setHolder(query.data?.holder ?? '')
|
||||
setEditing(true)
|
||||
}
|
||||
|
||||
const submit = (event: FormEvent) => {
|
||||
event.preventDefault()
|
||||
mutation.mutate({ alias: alias.trim() || null, holder: holder.trim() || null })
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="rounded-xl border border-border bg-surface">
|
||||
<div className="flex items-start gap-3 px-4 py-3">
|
||||
<span className="rounded-lg bg-primary-soft p-2" aria-hidden="true">
|
||||
<Landmark className="size-4 text-primary" />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium text-primary">Datos para transferir</p>
|
||||
<p className="text-xs text-secondary">Los ven tus alumnos cuando informan un pago</p>
|
||||
</div>
|
||||
{!editing ? (
|
||||
<Button variant="outline" size="sm" className="h-11 shrink-0" onClick={startEditing} disabled={query.isPending}>
|
||||
{query.data?.alias ? 'Editar' : 'Agregar'}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{editing ? (
|
||||
<form onSubmit={submit} className="space-y-3 border-t border-border px-4 py-4">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="transfer-alias">Alias o CBU/CVU</Label>
|
||||
<Input id="transfer-alias" autoFocus maxLength={60} value={alias} onChange={(event) => setAlias(event.target.value)} />
|
||||
</div>
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="transfer-holder">Titular</Label>
|
||||
<Input id="transfer-holder" maxLength={120} value={holder} onChange={(event) => setHolder(event.target.value)} />
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="ghost" className="h-11 flex-1" onClick={() => setEditing(false)}>
|
||||
Cancelar
|
||||
</Button>
|
||||
<Button type="submit" variant="primary" className="h-11 flex-1" disabled={mutation.isPending}>
|
||||
{mutation.isPending ? <Loader2 className="size-4 animate-spin" aria-hidden="true" /> : null}
|
||||
Guardar
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
) : query.data?.alias ? (
|
||||
<dl className="space-y-1 border-t border-border px-4 py-3 text-sm">
|
||||
<div className="flex justify-between gap-3">
|
||||
<dt className="text-secondary">Alias</dt>
|
||||
<dd className="truncate font-mono font-medium text-primary">{query.data.alias}</dd>
|
||||
</div>
|
||||
{query.data.holder ? (
|
||||
<div className="flex justify-between gap-3">
|
||||
<dt className="text-secondary">Titular</dt>
|
||||
<dd className="truncate font-medium text-primary">{query.data.holder}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
</dl>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { useMutation } from '@tanstack/react-query'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { CheckCircle2, Loader2, MailWarning, Mail } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { confirmStudentRecoveryEmail } from '../../lib/api'
|
||||
import { StudentAuthShell } from './StudentAuthShell'
|
||||
|
||||
/* 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) })
|
||||
|
||||
return (
|
||||
<StudentAuthShell>
|
||||
<section className="space-y-6 rounded-2xl border border-border bg-surface p-6 text-center shadow-sm">
|
||||
{mutation.isSuccess ? (
|
||||
<>
|
||||
<div className="mx-auto flex size-14 items-center justify-center rounded-full bg-success-soft text-success">
|
||||
<CheckCircle2 className="size-7" aria-hidden="true" />
|
||||
</div>
|
||||
<div role="status">
|
||||
<h1 className="text-2xl font-bold text-primary">Mail confirmado</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>.
|
||||
</p>
|
||||
</div>
|
||||
<Link to="/alumno" 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
|
||||
</Link>
|
||||
</>
|
||||
) : mutation.isError ? (
|
||||
<>
|
||||
<div className="mx-auto flex size-14 items-center justify-center rounded-full bg-primary-soft text-primary">
|
||||
<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>
|
||||
<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.
|
||||
</p>
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<div className="mx-auto flex size-14 items-center justify-center rounded-full bg-accent-soft text-accent-fg">
|
||||
<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>
|
||||
</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
|
||||
</Button>
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
</StudentAuthShell>
|
||||
)
|
||||
}
|
||||
50
apps/web/src/features/student-access/LinkUsedView.tsx
Normal file
50
apps/web/src/features/student-access/LinkUsedView.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
import { useState } from 'react'
|
||||
import { Link2Off, LogIn, Mail } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { PasskeyLoginButton } from './PasskeyLoginButton'
|
||||
import { RecoveryLinkForm } from './RecoveryLinkForm'
|
||||
import { StudentAuthShell } from './StudentAuthShell'
|
||||
|
||||
type LinkUsedViewProps = {
|
||||
/** `used`: a dead link (used, expired or never valid). `signed-out`: the
|
||||
* student opened the app without a session on this phone. */
|
||||
variant: 'used' | 'signed-out'
|
||||
}
|
||||
|
||||
export function LinkUsedView({ variant }: LinkUsedViewProps) {
|
||||
const [showEmail, setShowEmail] = useState(false)
|
||||
const Icon = variant === 'used' ? Link2Off : LogIn
|
||||
|
||||
return (
|
||||
<StudentAuthShell>
|
||||
<section className="space-y-6 rounded-2xl border border-border bg-surface p-6 shadow-sm">
|
||||
<div className="text-center">
|
||||
<div className="mx-auto mb-4 flex size-14 items-center justify-center rounded-full bg-primary-soft text-primary">
|
||||
<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'}
|
||||
</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.'}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="space-y-3">
|
||||
<PasskeyLoginButton />
|
||||
{showEmail ? (
|
||||
<RecoveryLinkForm />
|
||||
) : (
|
||||
<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
|
||||
</Button>
|
||||
)}
|
||||
<p className="text-center text-xs text-secondary">Estas opciones funcionan solo si las activaste antes.</p>
|
||||
</div>
|
||||
</section>
|
||||
</StudentAuthShell>
|
||||
)
|
||||
}
|
||||
43
apps/web/src/features/student-access/PasskeyLoginButton.tsx
Normal file
43
apps/web/src/features/student-access/PasskeyLoginButton.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { Fingerprint, Loader2 } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { isPasskeyCancel, loginWithPasskey, supportsPasskeys } from './passkeys'
|
||||
|
||||
export function PasskeyLoginButton() {
|
||||
const navigate = useNavigate()
|
||||
const queryClient = useQueryClient()
|
||||
const [pending, setPending] = useState(false)
|
||||
const [failed, setFailed] = useState(false)
|
||||
|
||||
if (!supportsPasskeys()) return null
|
||||
|
||||
const handleClick = async () => {
|
||||
setPending(true)
|
||||
setFailed(false)
|
||||
try {
|
||||
await loginWithPasskey()
|
||||
await queryClient.invalidateQueries({ queryKey: ['student'] })
|
||||
await navigate({ to: '/alumno', replace: true })
|
||||
} catch (error) {
|
||||
if (!isPasskeyCancel(error)) setFailed(true)
|
||||
} finally {
|
||||
setPending(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<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
|
||||
</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.
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
59
apps/web/src/features/student-access/RecoveryLinkForm.tsx
Normal file
59
apps/web/src/features/student-access/RecoveryLinkForm.tsx
Normal file
@@ -0,0 +1,59 @@
|
||||
import { useState, type FormEvent } from 'react'
|
||||
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'
|
||||
|
||||
/* "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 mutation = useMutation({ mutationFn: requestStudentRecoveryLink })
|
||||
|
||||
const handleSubmit = (event: FormEvent) => {
|
||||
event.preventDefault()
|
||||
if (email.trim()) mutation.mutate(email.trim())
|
||||
}
|
||||
|
||||
if (mutation.isSuccess) {
|
||||
return (
|
||||
<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.
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const tooMany = mutation.error instanceof ApiError && mutation.error.status === 429
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="recovery-email">Tu mail de recuperación</Label>
|
||||
<Input
|
||||
id="recovery-email"
|
||||
type="email"
|
||||
inputMode="email"
|
||||
autoComplete="email"
|
||||
autoFocus
|
||||
required
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
className="h-12"
|
||||
/>
|
||||
</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.'}
|
||||
</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
|
||||
</Button>
|
||||
</form>
|
||||
)
|
||||
}
|
||||
19
apps/web/src/features/student-access/StudentAuthShell.tsx
Normal file
19
apps/web/src/features/student-access/StudentAuthShell.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { Logo } from '../../components/brand'
|
||||
import { ThemeToggle } from '../../components/layout/ThemeToggle'
|
||||
|
||||
/* Frame of the public student pages (link, recovery). The logo is not a link:
|
||||
the app's home is the teacher's login, not a place for the student. */
|
||||
export function StudentAuthShell({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="flex min-h-dvh flex-col bg-background text-primary">
|
||||
<header className="flex items-center justify-between border-b border-border bg-surface/80 px-4 py-3 backdrop-blur-md">
|
||||
<Logo className="h-7 w-auto" />
|
||||
<ThemeToggle />
|
||||
</header>
|
||||
<main className="flex flex-1 items-start justify-center px-4 py-8 sm:items-center">
|
||||
<div className="w-full max-w-md">{children}</div>
|
||||
</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
64
apps/web/src/features/student-access/StudentLinkProvider.tsx
Normal file
64
apps/web/src/features/student-access/StudentLinkProvider.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import { createContext, useContext, type ReactNode } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import type { StudentLinkInfo } from '@gruperly/shared'
|
||||
import { ApiError, consumeStudentLink, getStudentLinkInfo } from '../../lib/api'
|
||||
|
||||
type StudentLinkContextValue = {
|
||||
info: StudentLinkInfo | undefined
|
||||
infoPending: boolean
|
||||
infoFailed: boolean
|
||||
enter: () => void
|
||||
entering: boolean
|
||||
/** The POST found the link dead (another device won, or it just expired). */
|
||||
consumedElsewhere: boolean
|
||||
enterFailed: boolean
|
||||
}
|
||||
|
||||
const StudentLinkContext = createContext<StudentLinkContextValue | null>(null)
|
||||
|
||||
/* The GET only shows who the link is for; entering is the POST, behind a real
|
||||
button, so a WhatsApp preview or a link scanner never burns it. */
|
||||
export function StudentLinkProvider({ token, children }: { token: string; children: ReactNode }) {
|
||||
const navigate = useNavigate()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const infoQuery = useQuery({
|
||||
queryKey: ['student-link', token],
|
||||
queryFn: () => getStudentLinkInfo(token),
|
||||
staleTime: Infinity,
|
||||
retry: false,
|
||||
})
|
||||
|
||||
const consume = useMutation({
|
||||
mutationFn: () => consumeStudentLink(token),
|
||||
onSuccess: async ({ firstLogin }) => {
|
||||
queryClient.removeQueries({ queryKey: ['student'] })
|
||||
await navigate({ to: firstLogin ? '/alumno/bienvenida' : '/alumno', replace: true })
|
||||
},
|
||||
})
|
||||
|
||||
const consumedElsewhere = consume.error instanceof ApiError && consume.error.status === 410
|
||||
|
||||
return (
|
||||
<StudentLinkContext.Provider
|
||||
value={{
|
||||
info: infoQuery.data,
|
||||
infoPending: infoQuery.isPending,
|
||||
infoFailed: infoQuery.isError,
|
||||
enter: () => consume.mutate(),
|
||||
entering: consume.isPending || consume.isSuccess,
|
||||
consumedElsewhere,
|
||||
enterFailed: consume.isError && !consumedElsewhere,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</StudentLinkContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export function useStudentLink() {
|
||||
const context = useContext(StudentLinkContext)
|
||||
if (!context) throw new Error('useStudentLink must be used within StudentLinkProvider')
|
||||
return context
|
||||
}
|
||||
89
apps/web/src/features/student-access/StudentLinkView.tsx
Normal file
89
apps/web/src/features/student-access/StudentLinkView.tsx
Normal file
@@ -0,0 +1,89 @@
|
||||
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>
|
||||
)
|
||||
}
|
||||
51
apps/web/src/features/student-access/passkeys.ts
Normal file
51
apps/web/src/features/student-access/passkeys.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import {
|
||||
browserSupportsWebAuthn,
|
||||
startAuthentication,
|
||||
startRegistration,
|
||||
type PublicKeyCredentialCreationOptionsJSON,
|
||||
type PublicKeyCredentialRequestOptionsJSON,
|
||||
} from '@simplewebauthn/browser'
|
||||
import {
|
||||
getStudentPasskeyLoginOptions,
|
||||
getStudentPasskeyRegistrationOptions,
|
||||
verifyStudentPasskeyLogin,
|
||||
verifyStudentPasskeyRegistration,
|
||||
} from '../../lib/api'
|
||||
|
||||
/* Passkeys ("Face ID o huella"). Without WebAuthn in the browser the option is
|
||||
not shown at all. */
|
||||
export function supportsPasskeys(): boolean {
|
||||
try {
|
||||
return browserSupportsWebAuthn()
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
/** The person closed the system dialog: not an error worth a message. */
|
||||
export function isPasskeyCancel(error: unknown): boolean {
|
||||
const name = (error as { name?: string } | null)?.name
|
||||
return name === 'NotAllowedError' || name === 'AbortError'
|
||||
}
|
||||
|
||||
export async function registerPasskey() {
|
||||
const { challengeId, options } = await getStudentPasskeyRegistrationOptions()
|
||||
const response = await startRegistration({
|
||||
optionsJSON: options as unknown as PublicKeyCredentialCreationOptionsJSON,
|
||||
})
|
||||
return verifyStudentPasskeyRegistration({
|
||||
challengeId,
|
||||
response: response as unknown as Record<string, unknown>,
|
||||
})
|
||||
}
|
||||
|
||||
export async function loginWithPasskey() {
|
||||
const { challengeId, options } = await getStudentPasskeyLoginOptions()
|
||||
const response = await startAuthentication({
|
||||
optionsJSON: options as unknown as PublicKeyCredentialRequestOptionsJSON,
|
||||
})
|
||||
return verifyStudentPasskeyLogin({
|
||||
challengeId,
|
||||
response: response as unknown as Record<string, unknown>,
|
||||
})
|
||||
}
|
||||
47
apps/web/src/features/student-app/FeeCard.tsx
Normal file
47
apps/web/src/features/student-app/FeeCard.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import type { StudentFee } from '@gruperly/shared'
|
||||
import { Receipt } from 'lucide-react'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
import { feeLabel } from './format'
|
||||
import { FeeStatusBadge } from './FeeStatusBadge'
|
||||
|
||||
/* "Tu cuota": only while there is something unpaid. */
|
||||
export function FeeCard({ fees }: { fees: StudentFee[] }) {
|
||||
if (fees.length === 0) return null
|
||||
const first = fees[0] as StudentFee
|
||||
const toReport = fees.filter((fee) => fee.status !== 'reported')
|
||||
const total = toReport.reduce((sum, fee) => sum + fee.amount, 0)
|
||||
|
||||
return (
|
||||
<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>
|
||||
<h2 className="mt-1 truncate text-lg font-bold text-primary">
|
||||
{fees.length === 1 ? feeLabel(first) : `${fees.length} cuotas sin pagar`}
|
||||
</h2>
|
||||
<p className="mt-1 text-2xl font-bold text-primary">
|
||||
{formatPrice(toReport.length > 0 ? total : first.amount, first.currency)}
|
||||
</p>
|
||||
</div>
|
||||
{fees.length === 1 ? (
|
||||
<FeeStatusBadge status={first.status} />
|
||||
) : toReport.some((fee) => fee.status === 'overdue') ? (
|
||||
<Badge variant="warning">Hay vencidas</Badge>
|
||||
) : null}
|
||||
</div>
|
||||
{toReport.length > 0 ? (
|
||||
<Link
|
||||
to="/alumno/informar-pago"
|
||||
className="mt-4 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
|
||||
</Link>
|
||||
) : (
|
||||
<p className="mt-3 text-sm text-secondary">Tu profe tiene que confirmar el pago que informaste.</p>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
14
apps/web/src/features/student-app/FeeStatusBadge.tsx
Normal file
14
apps/web/src/features/student-app/FeeStatusBadge.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { StudentFeeStatus } from '@gruperly/shared'
|
||||
import { Badge } from '../../components/ui'
|
||||
|
||||
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 variant = status === 'overdue' ? 'warning' : status === 'reported' ? 'info' : 'neutral'
|
||||
return <Badge variant={variant}>{LABELS[status]}</Badge>
|
||||
}
|
||||
14
apps/web/src/features/student-app/FlowDone.tsx
Normal file
14
apps/web/src/features/student-app/FlowDone.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { CheckCircle2 } from 'lucide-react'
|
||||
|
||||
export function FlowDone({ title, children }: { title: string; children?: ReactNode }) {
|
||||
return (
|
||||
<div role="status" className="space-y-4 py-10 text-center">
|
||||
<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="text-2xl font-bold text-primary">{title}</h1>
|
||||
{children}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
10
apps/web/src/features/student-app/FlowFooter.tsx
Normal file
10
apps/web/src/features/student-app/FlowFooter.tsx
Normal file
@@ -0,0 +1,10 @@
|
||||
import type { ReactNode } from 'react'
|
||||
|
||||
/* Fixed action at the bottom of a flow screen, above the home indicator. */
|
||||
export function FlowFooter({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className="fixed inset-x-0 bottom-0 z-40 border-t border-border bg-surface/95 px-4 pt-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] backdrop-blur">
|
||||
<div className="mx-auto max-w-md">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
47
apps/web/src/features/student-app/NextClassCard.tsx
Normal file
47
apps/web/src/features/student-app/NextClassCard.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
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'
|
||||
|
||||
type NextClassCardProps = { item: StudentClass; timeZone: string }
|
||||
|
||||
/* "Próxima clase": the dark brand card is the one strong surface of the home.
|
||||
White on brand-night scores 15:1 in both themes. */
|
||||
export function NextClassCard({ item, timeZone }: NextClassCardProps) {
|
||||
const { day, month } = dateParts(item.startsAt, timeZone)
|
||||
|
||||
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)}
|
||||
</p>
|
||||
<div className="mt-3 flex items-center gap-4">
|
||||
<div className="min-w-0 flex-1">
|
||||
<h2 className="truncate text-xl font-bold">{item.groupName}</h2>
|
||||
<p className="mt-1 text-sm text-white/85">
|
||||
{formatLongDate(item.startsAt, timeZone)} · {formatTime(item.startsAt, timeZone)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex size-16 shrink-0 flex-col items-center justify-center rounded-xl bg-white/10" aria-hidden="true">
|
||||
<span className="text-2xl font-bold leading-none">{day}</span>
|
||||
<span className="mt-1 text-xs uppercase text-white/85">{month}</span>
|
||||
</div>
|
||||
</div>
|
||||
{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
|
||||
</p>
|
||||
) : (
|
||||
<Link
|
||||
to="/alumno/avisar"
|
||||
search={{ clase: item.startsAt }}
|
||||
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
|
||||
</Link>
|
||||
)}
|
||||
</article>
|
||||
)
|
||||
}
|
||||
142
apps/web/src/features/student-app/NotifyAbsenceView.tsx
Normal file
142
apps/web/src/features/student-app/NotifyAbsenceView.tsx
Normal file
@@ -0,0 +1,142 @@
|
||||
import { useState } from 'react'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import type { AbsenceReasonValue } from '@gruperly/shared'
|
||||
import { ArrowLeft, Loader2 } from 'lucide-react'
|
||||
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 { SelectableRow } from './SelectableRow'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
const REASONS = Object.keys(ABSENCE_REASON_LABELS) as AbsenceReasonValue[]
|
||||
|
||||
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('')
|
||||
|
||||
if (!student || !classes) {
|
||||
return (
|
||||
<div className="flex justify-center py-20" role="status" aria-label="Cargando">
|
||||
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const teacher = firstName(student.teacherName)
|
||||
|
||||
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>
|
||||
<div className="space-y-2 pt-2">
|
||||
<Link to="/alumno" 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
|
||||
</Link>
|
||||
<Link to="/alumno/clases" 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
|
||||
</Link>
|
||||
</div>
|
||||
</FlowDone>
|
||||
)
|
||||
}
|
||||
|
||||
// Classes not started and not notified yet.
|
||||
const available = classes.classes.filter((item) => !item.started && !item.notice)
|
||||
const toggle = (startsAt: string) =>
|
||||
setSelected((current) => (current.includes(startsAt) ? current.filter((value) => value !== startsAt) : [...current, startsAt]))
|
||||
const count = selected.filter((value) => available.some((item) => item.startsAt === value)).length
|
||||
|
||||
const submit = () => {
|
||||
if (count === 0) return
|
||||
notifyAbsences.mutate({
|
||||
startsAt: selected.filter((value) => available.some((item) => item.startsAt === value)),
|
||||
reason,
|
||||
message: message.trim() || null,
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Link to="/alumno" className="hidden items-center gap-1 text-sm text-secondary hover:text-primary lg:inline-flex">
|
||||
<ArrowLeft className="size-4" aria-hidden="true" />
|
||||
Volver
|
||||
</Link>
|
||||
<h1 className="text-2xl font-bold text-primary">Avisar que no voy</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?
|
||||
</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.
|
||||
</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{available.map((item) => (
|
||||
<SelectableRow key={item.startsAt} pressed={selected.includes(item.startsAt)} onToggle={() => toggle(item.startsAt)}>
|
||||
<span className="block text-sm font-medium capitalize text-primary">
|
||||
{formatShortDate(item.startsAt, classes.timeZone)} · {formatTime(item.startsAt, classes.timeZone)}
|
||||
</span>
|
||||
<span className="block truncate text-xs text-secondary">{item.groupName}</span>
|
||||
</SelectableRow>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<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>
|
||||
</h2>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{REASONS.map((value) => (
|
||||
<button
|
||||
key={value}
|
||||
type="button"
|
||||
aria-pressed={reason === value}
|
||||
onClick={() => setReason((current) => (current === value ? null : value))}
|
||||
className={cn(
|
||||
'min-h-11 rounded-full border px-4 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',
|
||||
reason === value ? 'border-accent bg-accent-soft text-accent-fg' : 'border-border bg-surface text-primary hover:bg-primary-soft',
|
||||
)}
|
||||
>
|
||||
{ABSENCE_REASON_LABELS[value]}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="absence-message">Mensaje para {teacher} (opcional)</Label>
|
||||
<textarea
|
||||
id="absence-message"
|
||||
value={message}
|
||||
onChange={(event) => setMessage(event.target.value)}
|
||||
maxLength={500}
|
||||
rows={3}
|
||||
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="text-xs text-secondary">Si avisás antes de la clase, la falta queda como justificada.</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.
|
||||
</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`}
|
||||
</Button>
|
||||
</FlowFooter>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
65
apps/web/src/features/student-app/PasskeyCard.tsx
Normal file
65
apps/web/src/features/student-app/PasskeyCard.tsx
Normal file
@@ -0,0 +1,65 @@
|
||||
import { useState } from 'react'
|
||||
import { CheckCircle2, Fingerprint, Loader2 } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { isPasskeyCancel, supportsPasskeys } from '../student-access/passkeys'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
/* "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 hasPasskey = me?.account.hasPasskey ?? false
|
||||
if (!supportsPasskeys() && !hasPasskey) return null
|
||||
|
||||
const activate = () => {
|
||||
setFailed(false)
|
||||
activatePasskey.mutate(undefined, {
|
||||
onError: (error) => {
|
||||
if (!isPasskeyCancel(error)) setFailed(true)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<section
|
||||
aria-labelledby="passkey-title"
|
||||
className={cn('rounded-2xl border p-5', highlighted ? 'border-accent bg-accent-soft' : 'border-border bg-surface')}
|
||||
>
|
||||
<div className="flex items-start gap-3">
|
||||
<span className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-surface text-accent-fg" aria-hidden="true">
|
||||
{hasPasskey ? <CheckCircle2 className="size-6 text-success" /> : <Fingerprint className="size-6" />}
|
||||
</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'}
|
||||
</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.'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{failed ? (
|
||||
<p role="alert" className="mt-3 text-sm text-danger-fg">
|
||||
No pudimos activarlo en este teléfono.
|
||||
</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
|
||||
</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
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
33
apps/web/src/features/student-app/PaymentReviewBanner.tsx
Normal file
33
apps/web/src/features/student-app/PaymentReviewBanner.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import type { StudentPaymentReport } from '@gruperly/shared'
|
||||
import { CheckCircle2, XCircle } from 'lucide-react'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
|
||||
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 latest = reports.find(
|
||||
(report) => report.status !== 'reported' && report.reviewedAt && Date.now() - Date.parse(report.reviewedAt) < RECENT_MS,
|
||||
)
|
||||
if (!latest) return null
|
||||
const amount = formatPrice(latest.totalAmount, latest.currency)
|
||||
|
||||
if (latest.status === 'confirmed') {
|
||||
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>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<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.
|
||||
</span>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
93
apps/web/src/features/student-app/ReceiptDropzone.tsx
Normal file
93
apps/web/src/features/student-app/ReceiptDropzone.tsx
Normal file
@@ -0,0 +1,93 @@
|
||||
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'
|
||||
|
||||
const ACCEPTED = new Set(RECEIPT_ACCEPT.split(','))
|
||||
// Safari's HEIC can't be previewed by other browsers: those show the file icon.
|
||||
const PREVIEWABLE = new Set(['image/jpeg', 'image/png', 'image/webp'])
|
||||
|
||||
type ReceiptDropzoneProps = {
|
||||
file: File | null
|
||||
onChange: (file: File | null) => void
|
||||
}
|
||||
|
||||
/* Attachment zone. The browser checks are only for a quick message: the API
|
||||
validates the real type (magic bytes) and size again. */
|
||||
export function ReceiptDropzone({ file, onChange }: ReceiptDropzoneProps) {
|
||||
const inputId = useId()
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
const preview = useMemo(() => (file && PREVIEWABLE.has(file.type) ? URL.createObjectURL(file) : null), [file])
|
||||
|
||||
useEffect(() => () => {
|
||||
if (preview) URL.revokeObjectURL(preview)
|
||||
}, [preview])
|
||||
|
||||
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.`)
|
||||
return
|
||||
}
|
||||
if (next.type && !ACCEPTED.has(next.type)) {
|
||||
setError('Tiene que ser una captura (JPG, PNG, WEBP, HEIC) o un PDF.')
|
||||
return
|
||||
}
|
||||
setError(null)
|
||||
onChange(next)
|
||||
}
|
||||
|
||||
if (file) {
|
||||
return (
|
||||
<div className="flex items-center gap-3 rounded-2xl border border-border bg-surface p-3">
|
||||
<div className="flex size-14 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-primary-soft">
|
||||
{preview ? (
|
||||
<img src={preview} alt="" className="size-full object-cover" />
|
||||
) : (
|
||||
<FileText className="size-6 text-foreground" aria-hidden="true" />
|
||||
)}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-medium text-primary">{file.name}</p>
|
||||
<p className="text-xs text-secondary">{formatFileSize(file.size)}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onChange(null)}
|
||||
aria-label="Quitar comprobante"
|
||||
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" />
|
||||
</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<label
|
||||
htmlFor={inputId}
|
||||
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>
|
||||
<input
|
||||
id={inputId}
|
||||
type="file"
|
||||
accept={RECEIPT_ACCEPT}
|
||||
className="sr-only"
|
||||
onChange={(event) => {
|
||||
handleFile(event.target.files?.[0])
|
||||
event.target.value = ''
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
{error ? (
|
||||
<p role="alert" className="text-sm text-danger-fg">
|
||||
{error}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
98
apps/web/src/features/student-app/RecoveryEmailCard.tsx
Normal file
98
apps/web/src/features/student-app/RecoveryEmailCard.tsx
Normal file
@@ -0,0 +1,98 @@
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { Loader2, Mail } from 'lucide-react'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
/* 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 [email, setEmail] = useState('')
|
||||
const current = me?.account.recoveryEmail ?? null
|
||||
const pending = me?.account.pendingRecoveryEmail ?? null
|
||||
const showForm = editing || (!current && !pending)
|
||||
|
||||
const submit = (event: FormEvent) => {
|
||||
event.preventDefault()
|
||||
if (!email.trim()) return
|
||||
saveRecoveryEmail.mutate(email.trim(), {
|
||||
onSuccess: () => {
|
||||
setEditing(false)
|
||||
setEmail('')
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<section aria-labelledby="recovery-title" className="rounded-2xl border border-border bg-surface p-5">
|
||||
<div className="flex items-start gap-3">
|
||||
<span className="flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary-soft text-primary" aria-hidden="true">
|
||||
<Mail className="size-5" />
|
||||
</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>
|
||||
</h2>
|
||||
{current ? (
|
||||
<p className="mt-1 truncate text-sm text-secondary">
|
||||
Confirmado: <span className="font-medium text-primary">{current}</span>
|
||||
</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.
|
||||
</p>
|
||||
) : null}
|
||||
{!current && !pending ? (
|
||||
<p className="mt-1 text-sm text-secondary">Para pedir un link de ingreso si perdés el acceso.</p>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{showForm ? (
|
||||
<form onSubmit={submit} className="mt-4 space-y-3">
|
||||
<div className="space-y-1.5">
|
||||
<Label htmlFor="profile-recovery-email">Tu mail</Label>
|
||||
<Input
|
||||
id="profile-recovery-email"
|
||||
type="email"
|
||||
inputMode="email"
|
||||
autoComplete="email"
|
||||
autoFocus={editing}
|
||||
required
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
className="h-11"
|
||||
/>
|
||||
</div>
|
||||
{saveRecoveryEmail.isError ? (
|
||||
<p role="alert" className="text-sm text-danger-fg">
|
||||
No pudimos guardar el mail. Probá de nuevo en un rato.
|
||||
</p>
|
||||
) : null}
|
||||
<div className="flex gap-2">
|
||||
{editing ? (
|
||||
<Button variant="outline" className="h-11 flex-1" onClick={() => setEditing(false)}>
|
||||
Cancelar
|
||||
</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
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
) : (
|
||||
<div className="mt-4 flex gap-2">
|
||||
<Button variant="outline" className="h-11 flex-1" onClick={() => setEditing(true)}>
|
||||
Cambiar
|
||||
</Button>
|
||||
<Button variant="ghost" className="h-11 flex-1" onClick={() => removeRecoveryEmail.mutate()} disabled={removeRecoveryEmail.isPending}>
|
||||
Quitar
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
133
apps/web/src/features/student-app/ReportPaymentView.tsx
Normal file
133
apps/web/src/features/student-app/ReportPaymentView.tsx
Normal file
@@ -0,0 +1,133 @@
|
||||
import { useState } from 'react'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ArrowLeft, Info, Loader2 } from 'lucide-react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { ApiError } from '../../lib/api'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
import { FeeStatusBadge } from './FeeStatusBadge'
|
||||
import { FlowDone } from './FlowDone'
|
||||
import { FlowFooter } from './FlowFooter'
|
||||
import { feeLabel, firstName, formatDueDate } from './format'
|
||||
import { ReceiptDropzone } from './ReceiptDropzone'
|
||||
import { SelectableRow } from './SelectableRow'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
import { TransferDetailsCard } from './TransferDetailsCard'
|
||||
|
||||
export function ReportPaymentView() {
|
||||
const { student, fees, reportPayment } = useStudentApp()
|
||||
const [selected, setSelected] = useState<string[] | null>(null)
|
||||
const [file, setFile] = useState<File | null>(null)
|
||||
|
||||
if (!student || !fees) {
|
||||
return (
|
||||
<div className="flex justify-center py-20" role="status" aria-label="Cargando">
|
||||
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const teacher = firstName(student.teacherName)
|
||||
|
||||
if (reportPayment.isSuccess) {
|
||||
return (
|
||||
<FlowDone title="Pago informado">
|
||||
<p className="text-sm text-secondary">
|
||||
{teacher} va a revisar el comprobante. Te avisamos acá cuando lo confirme.
|
||||
</p>
|
||||
<Link to="/alumno" 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
|
||||
</Link>
|
||||
</FlowDone>
|
||||
)
|
||||
}
|
||||
|
||||
const reportable = fees.fees.filter((fee) => fee.status !== 'reported')
|
||||
// Default: every fee pending or overdue, the common case of "pay what I owe".
|
||||
const chosen = selected ?? reportable.map((fee) => fee.id)
|
||||
const total = reportable.filter((fee) => chosen.includes(fee.id)).reduce((sum, fee) => sum + fee.amount, 0)
|
||||
const currency = reportable[0]?.currency
|
||||
const toggle = (id: string) =>
|
||||
setSelected(chosen.includes(id) ? chosen.filter((value) => value !== id) : [...chosen, id])
|
||||
|
||||
const submit = () => {
|
||||
if (chosen.length === 0 || !file) return
|
||||
reportPayment.mutate({ paymentIds: chosen, file })
|
||||
}
|
||||
|
||||
const errorText =
|
||||
reportPayment.error instanceof ApiError && reportPayment.error.status === 409
|
||||
? 'Ya informaste alguna de estas cuotas.'
|
||||
: reportPayment.error instanceof ApiError && reportPayment.error.status === 400
|
||||
? reportPayment.error.problem?.detail ?? 'Revisá el comprobante.'
|
||||
: 'No pudimos enviar el pago. Probá de nuevo.'
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Link to="/alumno/pagos" className="hidden items-center gap-1 text-sm text-secondary hover:text-primary lg:inline-flex">
|
||||
<ArrowLeft className="size-4" aria-hidden="true" />
|
||||
Volver
|
||||
</Link>
|
||||
<h1 className="text-2xl font-bold text-primary">Informar pago</h1>
|
||||
|
||||
<section aria-labelledby="fees-label" className="space-y-2">
|
||||
<h2 id="fees-label" className="text-sm font-semibold text-primary">
|
||||
¿Qué cuotas pagaste?
|
||||
</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.
|
||||
</p>
|
||||
) : (
|
||||
<div className="space-y-2">
|
||||
{reportable.map((fee) => (
|
||||
<SelectableRow
|
||||
key={fee.id}
|
||||
pressed={chosen.includes(fee.id)}
|
||||
onToggle={() => toggle(fee.id)}
|
||||
trailing={<span className="shrink-0 text-sm font-semibold text-primary">{formatPrice(fee.amount, fee.currency)}</span>}
|
||||
>
|
||||
<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)}
|
||||
</span>
|
||||
</SelectableRow>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
{fees.transfer ? <TransferDetailsCard transfer={fees.transfer} /> : null}
|
||||
|
||||
<section aria-labelledby="receipt-label" className="space-y-2">
|
||||
<h2 id="receipt-label" className="text-sm font-semibold text-primary">
|
||||
Comprobante
|
||||
</h2>
|
||||
<ReceiptDropzone file={file} onChange={setFile} />
|
||||
</section>
|
||||
|
||||
<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.
|
||||
</p>
|
||||
|
||||
{reportPayment.isError ? (
|
||||
<p role="alert" className="text-sm text-danger-fg">
|
||||
{errorText}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<FlowFooter>
|
||||
<Button
|
||||
variant="primary"
|
||||
className="h-12 w-full text-base"
|
||||
disabled={chosen.length === 0 || !file || reportPayment.isPending}
|
||||
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)}`}
|
||||
</Button>
|
||||
</FlowFooter>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
38
apps/web/src/features/student-app/SelectableRow.tsx
Normal file
38
apps/web/src/features/student-app/SelectableRow.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { ReactNode } from 'react'
|
||||
import { Check } from 'lucide-react'
|
||||
import { cn } from '../../lib/utils'
|
||||
|
||||
type SelectableRowProps = {
|
||||
pressed: boolean
|
||||
onToggle: () => void
|
||||
children: ReactNode
|
||||
trailing?: ReactNode
|
||||
}
|
||||
|
||||
/* Multiple choice as real toggle buttons (`aria-pressed`) with a visual
|
||||
checkbox: used for classes and fees. */
|
||||
export function SelectableRow({ pressed, onToggle, children, trailing }: SelectableRowProps) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
aria-pressed={pressed}
|
||||
onClick={onToggle}
|
||||
className={cn(
|
||||
'flex min-h-16 w-full items-center gap-3 rounded-xl border px-4 py-3 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent',
|
||||
pressed ? 'border-accent bg-accent-soft' : 'border-border bg-surface hover:bg-primary-soft',
|
||||
)}
|
||||
>
|
||||
<span
|
||||
aria-hidden="true"
|
||||
className={cn(
|
||||
'flex size-6 shrink-0 items-center justify-center rounded-md border-2',
|
||||
pressed ? 'border-accent bg-accent text-on-accent' : 'border-foreground/50',
|
||||
)}
|
||||
>
|
||||
{pressed ? <Check className="size-4" strokeWidth={3} /> : null}
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">{children}</span>
|
||||
{trailing}
|
||||
</button>
|
||||
)
|
||||
}
|
||||
201
apps/web/src/features/student-app/StudentAppProvider.tsx
Normal file
201
apps/web/src/features/student-app/StudentAppProvider.tsx
Normal file
@@ -0,0 +1,201 @@
|
||||
import { createContext, useCallback, useContext, useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import type {
|
||||
CreateAbsenceNotices,
|
||||
StudentClassesDto,
|
||||
StudentFeesDto,
|
||||
StudentMe,
|
||||
StudentProfile,
|
||||
} from '@gruperly/shared'
|
||||
import {
|
||||
ApiError,
|
||||
cancelStudentAbsence,
|
||||
getStudentClasses,
|
||||
getStudentFees,
|
||||
getStudentMe,
|
||||
logoutStudent,
|
||||
markStudentWelcomed,
|
||||
notifyStudentAbsences,
|
||||
removeStudentPasskeys,
|
||||
removeStudentRecoveryEmail,
|
||||
reportStudentPayment,
|
||||
setStudentRecoveryEmail,
|
||||
} from '../../lib/api'
|
||||
import { registerPasskey } from '../student-access/passkeys'
|
||||
|
||||
const SELECTED_KEY = 'student-selected-attendee'
|
||||
const ME_KEY = ['student', 'me'] as const
|
||||
|
||||
function readSelected(): string | null {
|
||||
try {
|
||||
return localStorage.getItem(SELECTED_KEY)
|
||||
} catch {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
type StudentAppContextValue = {
|
||||
me: StudentMe | undefined
|
||||
mePending: boolean
|
||||
/** The selected attendee (a guardian may have several). */
|
||||
student: StudentProfile | null
|
||||
selectStudent: (attendeeId: string) => void
|
||||
classes: StudentClassesDto | undefined
|
||||
classesPending: boolean
|
||||
fees: StudentFeesDto | undefined
|
||||
feesPending: boolean
|
||||
notifyAbsences: ReturnType<typeof useNotifyAbsences>
|
||||
cancelAbsence: ReturnType<typeof useCancelAbsence>
|
||||
reportPayment: ReturnType<typeof useReportPayment>
|
||||
activatePasskey: ReturnType<typeof useMeMutation<void>>
|
||||
removePasskeys: ReturnType<typeof useMeMutation<void>>
|
||||
saveRecoveryEmail: ReturnType<typeof useMeMutation<string>>
|
||||
removeRecoveryEmail: ReturnType<typeof useMeMutation<void>>
|
||||
finishWelcome: ReturnType<typeof useMeMutation<void>>
|
||||
logout: () => void
|
||||
loggingOut: boolean
|
||||
}
|
||||
|
||||
const StudentAppContext = createContext<StudentAppContextValue | null>(null)
|
||||
|
||||
function useMeMutation<TInput>(fn: (input: TInput) => Promise<StudentMe>) {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: fn,
|
||||
onSuccess: (me) => queryClient.setQueryData(ME_KEY, me),
|
||||
})
|
||||
}
|
||||
|
||||
function useNotifyAbsences(attendeeId: string | null) {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: (input: Omit<CreateAbsenceNotices, 'attendeeId'>) =>
|
||||
notifyStudentAbsences({ ...input, attendeeId: attendeeId ?? '' }),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['student', 'classes', attendeeId] }),
|
||||
})
|
||||
}
|
||||
|
||||
function useCancelAbsence(attendeeId: string | null) {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: cancelStudentAbsence,
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['student', 'classes', attendeeId] }),
|
||||
})
|
||||
}
|
||||
|
||||
function useReportPayment(attendeeId: string | null) {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: (input: { paymentIds: string[]; file: File }) =>
|
||||
reportStudentPayment({ ...input, attendeeId: attendeeId ?? '' }),
|
||||
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['student', 'fees', attendeeId] }),
|
||||
})
|
||||
}
|
||||
|
||||
/* State of the student app: the session ("me"), the selected attendee and its
|
||||
classes and fees. Without a session (401) it sends the student to /acceso. */
|
||||
export function StudentAppProvider({ children }: { children: ReactNode }) {
|
||||
const navigate = useNavigate()
|
||||
const queryClient = useQueryClient()
|
||||
const [selectedId, setSelectedId] = useState<string | null>(readSelected)
|
||||
|
||||
const meQuery = useQuery({ queryKey: ME_KEY, queryFn: getStudentMe, retry: false, staleTime: 60_000 })
|
||||
|
||||
useEffect(() => {
|
||||
if (meQuery.error instanceof ApiError && meQuery.error.status === 401) {
|
||||
void navigate({ to: '/acceso', replace: true })
|
||||
}
|
||||
}, [meQuery.error, navigate])
|
||||
|
||||
const students = meQuery.data?.students ?? []
|
||||
const student = students.find((item) => item.attendeeId === selectedId) ?? students[0] ?? null
|
||||
const attendeeId = student?.attendeeId ?? null
|
||||
|
||||
const selectStudent = useCallback((id: string) => {
|
||||
setSelectedId(id)
|
||||
try {
|
||||
localStorage.setItem(SELECTED_KEY, id)
|
||||
} catch {
|
||||
// Private mode: the choice just isn't remembered.
|
||||
}
|
||||
}, [])
|
||||
|
||||
const classesQuery = useQuery({
|
||||
queryKey: ['student', 'classes', attendeeId],
|
||||
queryFn: () => getStudentClasses(attendeeId as string),
|
||||
enabled: attendeeId !== null,
|
||||
})
|
||||
const feesQuery = useQuery({
|
||||
queryKey: ['student', 'fees', attendeeId],
|
||||
queryFn: () => getStudentFees(attendeeId as string),
|
||||
enabled: attendeeId !== null,
|
||||
})
|
||||
|
||||
const notifyAbsences = useNotifyAbsences(attendeeId)
|
||||
const cancelAbsence = useCancelAbsence(attendeeId)
|
||||
const reportPayment = useReportPayment(attendeeId)
|
||||
const activatePasskey = useMeMutation<void>(() => registerPasskey())
|
||||
const removePasskeys = useMeMutation<void>(() => removeStudentPasskeys())
|
||||
const saveRecoveryEmail = useMeMutation<string>((email) => setStudentRecoveryEmail(email))
|
||||
const removeRecoveryEmail = useMeMutation<void>(() => removeStudentRecoveryEmail())
|
||||
const finishWelcome = useMeMutation<void>(() => markStudentWelcomed())
|
||||
|
||||
const logoutMutation = useMutation({
|
||||
mutationFn: logoutStudent,
|
||||
onSettled: async () => {
|
||||
queryClient.removeQueries({ queryKey: ['student'] })
|
||||
await navigate({ to: '/acceso', replace: true })
|
||||
},
|
||||
})
|
||||
|
||||
const value = useMemo<StudentAppContextValue>(
|
||||
() => ({
|
||||
me: meQuery.data,
|
||||
mePending: meQuery.isPending,
|
||||
student,
|
||||
selectStudent,
|
||||
classes: classesQuery.data,
|
||||
classesPending: classesQuery.isPending,
|
||||
fees: feesQuery.data,
|
||||
feesPending: feesQuery.isPending,
|
||||
notifyAbsences,
|
||||
cancelAbsence,
|
||||
reportPayment,
|
||||
activatePasskey,
|
||||
removePasskeys,
|
||||
saveRecoveryEmail,
|
||||
removeRecoveryEmail,
|
||||
finishWelcome,
|
||||
logout: () => logoutMutation.mutate(),
|
||||
loggingOut: logoutMutation.isPending,
|
||||
}),
|
||||
[
|
||||
meQuery.data,
|
||||
meQuery.isPending,
|
||||
student,
|
||||
selectStudent,
|
||||
classesQuery.data,
|
||||
classesQuery.isPending,
|
||||
feesQuery.data,
|
||||
feesQuery.isPending,
|
||||
notifyAbsences,
|
||||
cancelAbsence,
|
||||
reportPayment,
|
||||
activatePasskey,
|
||||
removePasskeys,
|
||||
saveRecoveryEmail,
|
||||
removeRecoveryEmail,
|
||||
finishWelcome,
|
||||
logoutMutation,
|
||||
],
|
||||
)
|
||||
|
||||
return <StudentAppContext.Provider value={value}>{children}</StudentAppContext.Provider>
|
||||
}
|
||||
|
||||
export function useStudentApp() {
|
||||
const context = useContext(StudentAppContext)
|
||||
if (!context) throw new Error('useStudentApp must be used within StudentAppProvider')
|
||||
return context
|
||||
}
|
||||
41
apps/web/src/features/student-app/StudentBottomNav.tsx
Normal file
41
apps/web/src/features/student-app/StudentBottomNav.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
import { Link, useLocation } from '@tanstack/react-router'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { isStudentNavItemActive, STUDENT_NAV_ITEMS } from './student-nav-items'
|
||||
|
||||
export function StudentBottomNav() {
|
||||
const location = useLocation()
|
||||
|
||||
return (
|
||||
<nav
|
||||
aria-label="Secciones"
|
||||
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">
|
||||
{STUDENT_NAV_ITEMS.map(({ label, to, icon: Icon }) => {
|
||||
const isActive = isStudentNavItemActive(location.pathname, to)
|
||||
return (
|
||||
<Link
|
||||
key={to}
|
||||
to={to}
|
||||
aria-current={isActive ? 'page' : undefined}
|
||||
className={cn(
|
||||
'flex min-h-14 flex-col items-center justify-center gap-1 py-2 text-[11px] font-medium transition-colors',
|
||||
isActive ? 'text-accent-fg' : 'text-foreground/80 hover:text-primary',
|
||||
)}
|
||||
>
|
||||
<span
|
||||
className={cn(
|
||||
'flex size-8 items-center justify-center rounded-lg transition-colors duration-150',
|
||||
isActive && 'bg-accent-soft',
|
||||
)}
|
||||
>
|
||||
<Icon className="size-5" strokeWidth={isActive ? 2.25 : 2} aria-hidden="true" />
|
||||
</span>
|
||||
<span className="leading-none">{label}</span>
|
||||
</Link>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
76
apps/web/src/features/student-app/StudentClassesView.tsx
Normal file
76
apps/web/src/features/student-app/StudentClassesView.tsx
Normal file
@@ -0,0 +1,76 @@
|
||||
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 { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
/* 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 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.'),
|
||||
})
|
||||
}
|
||||
|
||||
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>
|
||||
</div>
|
||||
|
||||
<Link
|
||||
to="/alumno/avisar"
|
||||
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
|
||||
</Link>
|
||||
|
||||
{classesPending || !classes ? (
|
||||
<div className="flex justify-center py-8" role="status" aria-label="Cargando clases">
|
||||
<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.
|
||||
</p>
|
||||
) : (
|
||||
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
|
||||
{upcoming.map((item) => (
|
||||
<li key={item.startsAt} className="flex min-h-16 items-center justify-between gap-3 px-4 py-3">
|
||||
<div className="min-w-0">
|
||||
<p className="text-sm font-medium capitalize text-primary">
|
||||
{formatShortDate(item.startsAt, classes.timeZone)} · {formatTime(item.startsAt, classes.timeZone)}
|
||||
</p>
|
||||
<p className="truncate text-xs text-secondary">
|
||||
{item.groupName}
|
||||
{item.notice?.reason ? ` · ${ABSENCE_REASON_LABELS[item.notice.reason]}` : ''}
|
||||
</p>
|
||||
</div>
|
||||
{item.notice ? (
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<Badge variant="neutral">Avisaste</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)}`}
|
||||
>
|
||||
<Undo2 className="size-4" aria-hidden="true" />
|
||||
Deshacer
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
40
apps/web/src/features/student-app/StudentHomeView.tsx
Normal file
40
apps/web/src/features/student-app/StudentHomeView.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { FeeCard } from './FeeCard'
|
||||
import { firstName } from './format'
|
||||
import { NextClassCard } from './NextClassCard'
|
||||
import { PaymentReviewBanner } from './PaymentReviewBanner'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
import { TeacherNoticeCard } from './TeacherNoticeCard'
|
||||
import { WeekClassesList } from './WeekClassesList'
|
||||
|
||||
export function StudentHomeView() {
|
||||
const { student, classes, classesPending, fees } = useStudentApp()
|
||||
if (!student) return null
|
||||
|
||||
const allClasses = classes?.classes ?? []
|
||||
const nextClass = allClasses.find((item) => !item.started) ?? null
|
||||
const weekEnd = classes ? Date.parse(classes.weekEndsAt) : 0
|
||||
const thisWeek = allClasses.filter((item) => Date.parse(item.startsAt) < weekEnd)
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<h1 className="text-2xl font-bold text-primary">Hola, {firstName(student.fullName)}</h1>
|
||||
|
||||
{fees ? <PaymentReviewBanner reports={fees.reports} /> : null}
|
||||
|
||||
{classesPending ? (
|
||||
<div className="flex justify-center py-8" role="status" aria-label="Cargando clases">
|
||||
<Loader2 className="size-6 animate-spin text-accent" aria-hidden="true" />
|
||||
</div>
|
||||
) : nextClass && classes ? (
|
||||
<NextClassCard item={nextClass} timeZone={classes.timeZone} />
|
||||
) : null}
|
||||
|
||||
{fees ? <FeeCard fees={fees.fees} /> : null}
|
||||
|
||||
{classes ? <WeekClassesList classes={thisWeek} timeZone={classes.timeZone} /> : null}
|
||||
|
||||
<TeacherNoticeCard teacherName={student.teacherName} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
51
apps/web/src/features/student-app/StudentLayout.tsx
Normal file
51
apps/web/src/features/student-app/StudentLayout.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
import { Outlet, useLocation } from '@tanstack/react-router'
|
||||
import { Loader2, UserX } from 'lucide-react'
|
||||
import { Logo } from '../../components/brand'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { StudentBottomNav } from './StudentBottomNav'
|
||||
import { StudentPicker } from './StudentPicker'
|
||||
import { STUDENT_FLOW_PATHS } from './student-nav-items'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
/* 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
|
||||
guards. */
|
||||
export function StudentLayout() {
|
||||
const { me, mePending, student } = useStudentApp()
|
||||
const location = useLocation()
|
||||
const isFlow = STUDENT_FLOW_PATHS.some((path) => location.pathname.startsWith(path))
|
||||
|
||||
return (
|
||||
<div className="min-h-dvh bg-background text-primary">
|
||||
<header className="sticky top-0 z-40 border-b border-border bg-background/90 backdrop-blur">
|
||||
<div className="mx-auto flex h-16 max-w-md items-center justify-between px-4">
|
||||
<Logo className="h-7 w-auto" />
|
||||
<StudentPicker />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main
|
||||
className={cn(
|
||||
'mx-auto w-full max-w-md px-4 pt-5',
|
||||
isFlow ? 'pb-[calc(7rem+env(safe-area-inset-bottom))]' : 'pb-[calc(6rem+env(safe-area-inset-bottom))]',
|
||||
)}
|
||||
>
|
||||
{mePending || !me ? (
|
||||
<div className="flex justify-center py-20" role="status" aria-label="Cargando">
|
||||
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
|
||||
</div>
|
||||
) : !student && !location.pathname.startsWith('/alumno/perfil') ? (
|
||||
<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>
|
||||
</div>
|
||||
) : (
|
||||
<Outlet />
|
||||
)}
|
||||
</main>
|
||||
|
||||
{isFlow ? null : <StudentBottomNav />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
113
apps/web/src/features/student-app/StudentPaymentsView.tsx
Normal file
113
apps/web/src/features/student-app/StudentPaymentsView.tsx
Normal file
@@ -0,0 +1,113 @@
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import type { StudentPaymentReport } from '@gruperly/shared'
|
||||
import { ExternalLink, Loader2, Receipt } from 'lucide-react'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
import { FeeStatusBadge } from './FeeStatusBadge'
|
||||
import { feeLabel, formatDueDate } from './format'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
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' },
|
||||
}
|
||||
|
||||
export function StudentPaymentsView() {
|
||||
const { fees, feesPending } = useStudentApp()
|
||||
|
||||
if (feesPending || !fees) {
|
||||
return (
|
||||
<div className="flex justify-center py-20" role="status" aria-label="Cargando pagos">
|
||||
<Loader2 className="size-8 animate-spin text-accent" aria-hidden="true" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const canReport = fees.fees.some((fee) => fee.status !== 'reported')
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<h1 className="text-2xl font-bold text-primary">Pagos</h1>
|
||||
|
||||
<section aria-labelledby="unpaid-title" className="space-y-3">
|
||||
<h2 id="unpaid-title" className="text-base font-bold text-primary">
|
||||
Cuotas sin pagar
|
||||
</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. 🎉
|
||||
</p>
|
||||
) : (
|
||||
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
|
||||
{fees.fees.map((fee) => (
|
||||
<li key={fee.id} className="space-y-2 px-4 py-3">
|
||||
<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>
|
||||
</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>
|
||||
<FeeStatusBadge status={fee.status} />
|
||||
</div>
|
||||
</div>
|
||||
{fee.checkoutUrl && fee.status !== 'reported' ? (
|
||||
<a
|
||||
href={fee.checkoutUrl}
|
||||
target="_blank"
|
||||
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
|
||||
<ExternalLink className="size-4" aria-hidden="true" />
|
||||
</a>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
{canReport ? (
|
||||
<Link
|
||||
to="/alumno/informar-pago"
|
||||
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
|
||||
</Link>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
{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
|
||||
</h2>
|
||||
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
|
||||
{fees.reports.map((report) => (
|
||||
<li key={report.id} className="px-4 py-3">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-sm font-medium text-primary">
|
||||
{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' })}
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
{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>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
82
apps/web/src/features/student-app/StudentPicker.tsx
Normal file
82
apps/web/src/features/student-app/StudentPicker.tsx
Normal file
@@ -0,0 +1,82 @@
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { Check, ChevronDown } from 'lucide-react'
|
||||
import { Avatar } from '../../components/ui'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { firstName } from './format'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
/* 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 containerRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (!open) return
|
||||
const close = (event: MouseEvent | KeyboardEvent) => {
|
||||
if (event instanceof KeyboardEvent ? event.key === 'Escape' : !containerRef.current?.contains(event.target as Node)) {
|
||||
setOpen(false)
|
||||
}
|
||||
}
|
||||
document.addEventListener('mousedown', close)
|
||||
document.addEventListener('keydown', close)
|
||||
return () => {
|
||||
document.removeEventListener('mousedown', close)
|
||||
document.removeEventListener('keydown', close)
|
||||
}
|
||||
}, [open])
|
||||
|
||||
const students = me?.students ?? []
|
||||
if (!student || students.length < 2) return null
|
||||
|
||||
return (
|
||||
<div ref={containerRef} className="relative">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setOpen((value) => !value)}
|
||||
aria-haspopup="listbox"
|
||||
aria-expanded={open}
|
||||
aria-label={`Alumno: ${student.fullName}. Cambiar`}
|
||||
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" />
|
||||
<span className="max-w-[8rem] truncate text-sm font-medium text-primary">{firstName(student.fullName)}</span>
|
||||
<ChevronDown className="size-4 text-foreground" aria-hidden="true" />
|
||||
</button>
|
||||
{open ? (
|
||||
<ul
|
||||
role="listbox"
|
||||
aria-label="Elegí el alumno"
|
||||
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) => {
|
||||
const selected = item.attendeeId === student.attendeeId
|
||||
return (
|
||||
<li key={item.attendeeId} role="option" aria-selected={selected}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
selectStudent(item.attendeeId)
|
||||
setOpen(false)
|
||||
}}
|
||||
className={cn(
|
||||
'flex min-h-11 w-full items-center gap-3 rounded-lg px-3 py-2 text-left hover:bg-primary-soft',
|
||||
selected && 'bg-accent-soft',
|
||||
)}
|
||||
>
|
||||
<Avatar name={item.fullName} className="size-8 rounded-full text-xs" />
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-sm font-medium text-primary">{item.fullName}</span>
|
||||
<span className="block truncate text-xs text-secondary">{item.groupName}</span>
|
||||
</span>
|
||||
{selected ? <Check className="size-4 text-accent-fg" aria-hidden="true" /> : null}
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
34
apps/web/src/features/student-app/StudentProfileView.tsx
Normal file
34
apps/web/src/features/student-app/StudentProfileView.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import { LogOut } from 'lucide-react'
|
||||
import { Avatar, Button } from '../../components/ui'
|
||||
import { PasskeyCard } from './PasskeyCard'
|
||||
import { RecoveryEmailCard } from './RecoveryEmailCard'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
export function StudentProfileView() {
|
||||
const { me, logout, loggingOut } = useStudentApp()
|
||||
if (!me) return null
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<h1 className="text-2xl font-bold text-primary">Perfil</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" />
|
||||
<div className="min-w-0">
|
||||
<p className="truncate font-semibold text-primary">{me.account.name}</p>
|
||||
<p className="truncate text-sm text-secondary">
|
||||
{me.students.map((student) => `${student.groupName} · ${student.teacherName}`).join(' / ')}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<PasskeyCard />
|
||||
<RecoveryEmailCard />
|
||||
|
||||
<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
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
17
apps/web/src/features/student-app/TeacherNoticeCard.tsx
Normal file
17
apps/web/src/features/student-app/TeacherNoticeCard.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Megaphone } from 'lucide-react'
|
||||
|
||||
/* "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 }) {
|
||||
return (
|
||||
<section aria-labelledby="notices-title" className="space-y-3">
|
||||
<h2 id="notices-title" className="text-base font-bold text-primary">
|
||||
Avisos del profe
|
||||
</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>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
}
|
||||
34
apps/web/src/features/student-app/TransferDetailsCard.tsx
Normal file
34
apps/web/src/features/student-app/TransferDetailsCard.tsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import type { TransferDetails } from '@gruperly/shared'
|
||||
import { Check, Copy } from 'lucide-react'
|
||||
import { useCopyToClipboard } from '../attendee-detail/useCopyToClipboard'
|
||||
|
||||
export function TransferDetailsCard({ transfer }: { transfer: TransferDetails }) {
|
||||
const { copied, copy } = useCopyToClipboard()
|
||||
|
||||
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
|
||||
</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="truncate font-mono text-base font-semibold text-primary">{transfer.alias}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => copy(transfer.alias)}
|
||||
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>
|
||||
</button>
|
||||
</div>
|
||||
{transfer.holder ? (
|
||||
<p className="mt-2 text-sm text-secondary">
|
||||
Titular: <span className="font-medium text-primary">{transfer.holder}</span>
|
||||
</p>
|
||||
) : null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
40
apps/web/src/features/student-app/WeekClassesList.tsx
Normal file
40
apps/web/src/features/student-app/WeekClassesList.tsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import type { StudentClass } from '@gruperly/shared'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { formatShortDate, formatTime } from './format'
|
||||
|
||||
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) {
|
||||
return (
|
||||
<section aria-labelledby="week-title" className="space-y-3">
|
||||
<h2 id="week-title" className="text-base font-bold text-primary">
|
||||
Esta semana
|
||||
</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.
|
||||
</p>
|
||||
) : (
|
||||
<ul className="divide-y divide-border rounded-2xl border border-border bg-surface">
|
||||
{classes.map((item) => (
|
||||
<li key={item.startsAt} className={cn('flex min-h-14 items-center justify-between gap-3 px-4 py-3', item.started && !item.notice && 'opacity-70')}>
|
||||
<div className={cn('min-w-0', item.notice && 'line-through decoration-foreground/60')}>
|
||||
<p className="text-sm font-medium capitalize text-primary">{formatShortDate(item.startsAt, timeZone)}</p>
|
||||
<p className="text-xs text-secondary">
|
||||
{formatTime(item.startsAt, timeZone)} · {item.groupName}
|
||||
</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>
|
||||
) : item.started ? (
|
||||
<span className="shrink-0 text-xs text-secondary">Pasó</span>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
80
apps/web/src/features/student-app/WelcomeView.tsx
Normal file
80
apps/web/src/features/student-app/WelcomeView.tsx
Normal file
@@ -0,0 +1,80 @@
|
||||
import { useState } from 'react'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { CheckCircle2, Loader2 } from 'lucide-react'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { FlowFooter } from './FlowFooter'
|
||||
import { PasskeyCard } from './PasskeyCard'
|
||||
import { useStudentApp } from './StudentAppProvider'
|
||||
|
||||
/* 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 goHome = () =>
|
||||
finishWelcome.mutate(undefined, { onSettled: () => void navigate({ to: '/alumno', replace: true }) })
|
||||
|
||||
const handleContinue = () => {
|
||||
const value = email.trim()
|
||||
if (!value) {
|
||||
goHome()
|
||||
return
|
||||
}
|
||||
saveRecoveryEmail.mutate(value, { onSuccess: goHome })
|
||||
}
|
||||
|
||||
const busy = finishWelcome.isPending || saveRecoveryEmail.isPending
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="pt-2 text-center">
|
||||
<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>
|
||||
<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.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<PasskeyCard highlighted />
|
||||
|
||||
<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>
|
||||
</h2>
|
||||
<p className="mt-1 text-sm text-secondary">Te mandamos un link para confirmarlo.</p>
|
||||
<div className="mt-3 space-y-1.5">
|
||||
<Label htmlFor="welcome-email">Tu mail</Label>
|
||||
<Input
|
||||
id="welcome-email"
|
||||
type="email"
|
||||
inputMode="email"
|
||||
autoComplete="email"
|
||||
value={email}
|
||||
onChange={(event) => setEmail(event.target.value)}
|
||||
className="h-11"
|
||||
/>
|
||||
</div>
|
||||
{saveRecoveryEmail.isError ? (
|
||||
<p role="alert" className="mt-2 text-sm text-danger-fg">
|
||||
Revisá el mail o seguí sin cargarlo.
|
||||
</p>
|
||||
) : null}
|
||||
</section>
|
||||
|
||||
<FlowFooter>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" className="h-12 flex-1" onClick={goHome} disabled={busy}>
|
||||
Ahora no
|
||||
</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
|
||||
</Button>
|
||||
</div>
|
||||
</FlowFooter>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
78
apps/web/src/features/student-app/format.ts
Normal file
78
apps/web/src/features/student-app/format.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
import type { AbsenceReasonValue, StudentFee } from '@gruperly/shared'
|
||||
|
||||
/* 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. */
|
||||
|
||||
const DAY_MS = 86_400_000
|
||||
|
||||
function wallDate(date: Date, timeZone: string): string {
|
||||
return new Intl.DateTimeFormat('en-CA', { timeZone, year: 'numeric', month: '2-digit', day: '2-digit' }).format(date)
|
||||
}
|
||||
|
||||
/** Whole days between `now` and `iso` in `timeZone` (0 = today). */
|
||||
export function daysFromToday(iso: string, timeZone: string, now: Date = new Date()): number {
|
||||
const target = Date.parse(wallDate(new Date(iso), timeZone))
|
||||
const today = Date.parse(wallDate(now, timeZone))
|
||||
return Math.round((target - today) / DAY_MS)
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
/** "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))
|
||||
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' })
|
||||
.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))
|
||||
}
|
||||
|
||||
/** 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('.', ''),
|
||||
}
|
||||
}
|
||||
|
||||
/** 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))
|
||||
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('.', '')
|
||||
}
|
||||
|
||||
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`
|
||||
}
|
||||
|
||||
export const ABSENCE_REASON_LABELS: Record<AbsenceReasonValue, string> = {
|
||||
health: 'Salud',
|
||||
travel: 'Viaje',
|
||||
work_study: 'Trabajo o estudio',
|
||||
other: 'Otro',
|
||||
}
|
||||
|
||||
export function firstName(fullName: string): string {
|
||||
return fullName.trim().split(/\s+/)[0] ?? fullName
|
||||
}
|
||||
19
apps/web/src/features/student-app/student-nav-items.ts
Normal file
19
apps/web/src/features/student-app/student-nav-items.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { CalendarDays, Home, User, Wallet } from 'lucide-react'
|
||||
import type { NavItem } from '../../components/layout/nav-items'
|
||||
|
||||
// Bottom nav of the student app: the single source for StudentBottomNav.
|
||||
export const STUDENT_NAV_ITEMS: NavItem[] = [
|
||||
{ label: 'Inicio', to: '/alumno', icon: Home },
|
||||
{ label: 'Clases', to: '/alumno/clases', icon: CalendarDays },
|
||||
{ label: 'Pagos', to: '/alumno/pagos', icon: Wallet },
|
||||
{ label: 'Perfil', to: '/alumno/perfil', icon: User },
|
||||
]
|
||||
|
||||
/* Flow screens with their own fixed bottom button: no nav there. */
|
||||
export const STUDENT_FLOW_PATHS = ['/alumno/bienvenida', '/alumno/avisar', '/alumno/informar-pago']
|
||||
|
||||
export function isStudentNavItemActive(pathname: string, to: string): boolean {
|
||||
const path = pathname.replace(/\/$/, '') || '/'
|
||||
if (to === '/alumno') return path === '/alumno'
|
||||
return path === to || path.startsWith(`${to}/`)
|
||||
}
|
||||
@@ -52,6 +52,23 @@ import type {
|
||||
PaymentList,
|
||||
PaymentQuery,
|
||||
ProblemDetails,
|
||||
StudentLinkInfo,
|
||||
ConsumeStudentLinkResult,
|
||||
StudentMe,
|
||||
PasskeyOptionsResult,
|
||||
PasskeyVerify,
|
||||
StudentClassesDto,
|
||||
CreateAbsenceNotices,
|
||||
CreateAbsenceNoticesResult,
|
||||
StudentFeesDto,
|
||||
StudentAccessDto,
|
||||
StudentInvitationDto,
|
||||
ReportedPaymentList,
|
||||
ReportedPaymentDto,
|
||||
ReceiptUrlDto,
|
||||
TransferDetailsDto,
|
||||
UpdateTransferDetails,
|
||||
TeacherAbsenceNoticeList,
|
||||
PromoteGroupWaitlistEntryResult,
|
||||
PublicNotifyAbsence,
|
||||
RejectGroupPreRegistrationResult,
|
||||
@@ -92,7 +109,8 @@ type JsonBody = Record<string, unknown> | unknown[]
|
||||
|
||||
async function apiFetch<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const headers = new Headers(init?.headers)
|
||||
headers.set('Content-Type', 'application/json')
|
||||
// A FormData body sets its own multipart Content-Type (with the boundary).
|
||||
if (!(init?.body instanceof FormData)) headers.set('Content-Type', 'application/json')
|
||||
|
||||
const res = await fetch(`${API_URL}${path}`, {
|
||||
...init,
|
||||
@@ -113,6 +131,7 @@ async function apiFetch<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
throw new ApiError(res.status, problem)
|
||||
}
|
||||
|
||||
if (res.status === 204) return undefined as T
|
||||
return (await res.json()) as T
|
||||
}
|
||||
|
||||
@@ -412,3 +431,126 @@ export const getAdminAccounts = (params: AdminAccountQueryInput) => {
|
||||
|
||||
export const getAdminAccount = (accountId: string) =>
|
||||
apiFetch<AdminAccountDetail>(`/api/v1/admin/accounts/${encodeURIComponent(accountId)}`)
|
||||
|
||||
// — App del alumno (sesión propia, nunca la del profe) —
|
||||
|
||||
const STUDENT_API = '/api/v1/student-portal'
|
||||
|
||||
export const getStudentLinkInfo = (token: string) =>
|
||||
apiFetch<StudentLinkInfo>(`${STUDENT_API}/links/${encodeURIComponent(token)}`)
|
||||
|
||||
export const consumeStudentLink = (token: string) =>
|
||||
apiFetch<ConsumeStudentLinkResult>(`${STUDENT_API}/links/${encodeURIComponent(token)}/consume`, {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
export const getStudentMe = () => apiFetch<StudentMe>(`${STUDENT_API}/me`)
|
||||
|
||||
export const markStudentWelcomed = () => apiFetch<StudentMe>(`${STUDENT_API}/me/welcome`, { method: 'POST' })
|
||||
|
||||
export const logoutStudent = () => apiFetch<void>(`${STUDENT_API}/logout`, { method: 'POST' })
|
||||
|
||||
export const setStudentRecoveryEmail = (email: string) =>
|
||||
apiFetch<StudentMe>(`${STUDENT_API}/me/recovery-email`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ email }),
|
||||
})
|
||||
|
||||
export const removeStudentRecoveryEmail = () =>
|
||||
apiFetch<StudentMe>(`${STUDENT_API}/me/recovery-email`, { method: 'DELETE' })
|
||||
|
||||
export const confirmStudentRecoveryEmail = (token: string) =>
|
||||
apiFetch<{ email: string }>(`${STUDENT_API}/recovery-email/confirm`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ token }),
|
||||
})
|
||||
|
||||
export const requestStudentRecoveryLink = (email: string) =>
|
||||
apiFetch<{ accepted: true }>(`${STUDENT_API}/recovery`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email }),
|
||||
})
|
||||
|
||||
export const getStudentPasskeyRegistrationOptions = () =>
|
||||
apiFetch<PasskeyOptionsResult>(`${STUDENT_API}/passkeys/register/options`, { method: 'POST' })
|
||||
|
||||
export const verifyStudentPasskeyRegistration = (payload: PasskeyVerify) =>
|
||||
apiFetch<StudentMe>(`${STUDENT_API}/passkeys/register/verify`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const removeStudentPasskeys = () =>
|
||||
apiFetch<StudentMe>(`${STUDENT_API}/passkeys`, { method: 'DELETE' })
|
||||
|
||||
export const getStudentPasskeyLoginOptions = () =>
|
||||
apiFetch<PasskeyOptionsResult>(`${STUDENT_API}/passkeys/login/options`, { method: 'POST' })
|
||||
|
||||
export const verifyStudentPasskeyLogin = (payload: PasskeyVerify) =>
|
||||
apiFetch<ConsumeStudentLinkResult>(`${STUDENT_API}/passkeys/login/verify`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const getStudentClasses = (attendeeId: string) =>
|
||||
apiFetch<StudentClassesDto>(`${STUDENT_API}/classes?attendeeId=${encodeURIComponent(attendeeId)}`)
|
||||
|
||||
export const notifyStudentAbsences = (payload: CreateAbsenceNotices) =>
|
||||
apiFetch<CreateAbsenceNoticesResult>(`${STUDENT_API}/absences`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
export const cancelStudentAbsence = (noticeId: string) =>
|
||||
apiFetch<{ id: string }>(`${STUDENT_API}/absences/${encodeURIComponent(noticeId)}`, { method: 'DELETE' })
|
||||
|
||||
export const getStudentFees = (attendeeId: string) =>
|
||||
apiFetch<StudentFeesDto>(`${STUDENT_API}/fees?attendeeId=${encodeURIComponent(attendeeId)}`)
|
||||
|
||||
export const reportStudentPayment = (payload: { attendeeId: string; paymentIds: string[]; file: File }) => {
|
||||
const form = new FormData()
|
||||
form.set('attendeeId', payload.attendeeId)
|
||||
for (const id of payload.paymentIds) form.append('paymentIds', id)
|
||||
form.set('file', payload.file)
|
||||
return apiFetch<{ id: string }>(`${STUDENT_API}/payment-reports`, { method: 'POST', body: form })
|
||||
}
|
||||
|
||||
// — Acceso de alumnos a la app (lado profe) —
|
||||
|
||||
export const getStudentAccess = (groupId: string, attendeeId: string) =>
|
||||
apiFetch<StudentAccessDto>(`/api/v1/groups/${groupId}/attendees/${attendeeId}/student-access`)
|
||||
|
||||
/* Invitar o reinvitar: revoca el acceso anterior y devuelve el link nuevo (una
|
||||
sola vez: el backend guarda solo su hash). */
|
||||
export const inviteStudent = (groupId: string, attendeeId: string) =>
|
||||
apiFetch<StudentInvitationDto>(`/api/v1/groups/${groupId}/attendees/${attendeeId}/student-access/invite`, {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
export const getGroupAbsenceNotices = (groupId: string) =>
|
||||
apiFetch<TeacherAbsenceNoticeList>(`/api/v1/groups/${groupId}/absence-notices`)
|
||||
|
||||
export const getReportedPayments = () => apiFetch<ReportedPaymentList>('/api/v1/payments/reported')
|
||||
|
||||
export const getReceiptUrl = (reportId: string) =>
|
||||
apiFetch<ReceiptUrlDto>(`/api/v1/payments/reported/${reportId}/receipt`)
|
||||
|
||||
export const confirmReportedPayment = (reportId: string) =>
|
||||
apiFetch<ReportedPaymentDto>(`/api/v1/payments/reported/${reportId}/confirm`, { method: 'POST' })
|
||||
|
||||
export const rejectReportedPayment = (reportId: string, reason: string | null) =>
|
||||
apiFetch<ReportedPaymentDto>(`/api/v1/payments/reported/${reportId}/reject`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ reason }),
|
||||
})
|
||||
|
||||
export const undoPaymentReview = (reportId: string) =>
|
||||
apiFetch<ReportedPaymentDto>(`/api/v1/payments/reported/${reportId}/undo`, { method: 'POST' })
|
||||
|
||||
export const getTransferDetails = () => apiFetch<TransferDetailsDto>('/api/v1/payments/transfer-details')
|
||||
|
||||
export const updateTransferDetails = (payload: UpdateTransferDetails) =>
|
||||
apiFetch<TransferDetailsDto>('/api/v1/payments/transfer-details', {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
|
||||
import { Route as rootRouteImport } from './routes/__root'
|
||||
import { Route as AuthenticatedRouteImport } from './routes/_authenticated'
|
||||
import { Route as StudentRouteImport } from './routes/_student'
|
||||
import { Route as AdminRouteImport } from './routes/admin'
|
||||
import { Route as ForgotPasswordRouteImport } from './routes/forgot-password'
|
||||
import { Route as LoginRouteImport } from './routes/login'
|
||||
@@ -23,12 +24,22 @@ import { Route as AuthenticatedPaymentsRouteImport } from './routes/_authenticat
|
||||
import { Route as AuthenticatedProfileRouteImport } from './routes/_authenticated/profile'
|
||||
import { Route as AuthenticatedSecurityRouteImport } from './routes/_authenticated/security'
|
||||
import { Route as AuthenticatedSettingsRouteImport } from './routes/_authenticated/settings'
|
||||
import { Route as AccesoIndexRouteImport } from './routes/acceso.index'
|
||||
import { Route as AdminIndexRouteImport } from './routes/admin/index'
|
||||
import { Route as ITokenRouteImport } from './routes/i.$token'
|
||||
import { Route as JoinTokenRouteImport } from './routes/join.$token'
|
||||
import { Route as ReportAbsenceTokenRouteImport } from './routes/report-absence.$token'
|
||||
import { Route as AuthenticatedGroupsIndexRouteImport } from './routes/_authenticated/groups/index'
|
||||
import { Route as AuthenticatedGroupsAttentionRouteImport } from './routes/_authenticated/groups/attention'
|
||||
import { Route as AuthenticatedGroupsNewRouteImport } from './routes/_authenticated/groups/new'
|
||||
import { Route as StudentAlumnoIndexRouteImport } from './routes/_student/alumno.index'
|
||||
import { Route as StudentAlumnoAvisarRouteImport } from './routes/_student/alumno.avisar'
|
||||
import { Route as StudentAlumnoBienvenidaRouteImport } from './routes/_student/alumno.bienvenida'
|
||||
import { Route as StudentAlumnoClasesRouteImport } from './routes/_student/alumno.clases'
|
||||
import { Route as StudentAlumnoInformarPagoRouteImport } from './routes/_student/alumno.informar-pago'
|
||||
import { Route as StudentAlumnoPagosRouteImport } from './routes/_student/alumno.pagos'
|
||||
import { Route as StudentAlumnoPerfilRouteImport } from './routes/_student/alumno.perfil'
|
||||
import { Route as AccesoMailTokenRouteImport } from './routes/acceso.mail.$token'
|
||||
import { Route as AdminAccountsAccountIdRouteImport } from './routes/admin/accounts.$accountId'
|
||||
import { Route as AuthenticatedClassSessionIdAttendanceRouteImport } from './routes/_authenticated/class/$sessionId/attendance'
|
||||
import { Route as AuthenticatedGroupsGroupIdIndexRouteImport } from './routes/_authenticated/groups/$groupId/index'
|
||||
@@ -40,6 +51,10 @@ const AuthenticatedRoute = AuthenticatedRouteImport.update({
|
||||
id: '/_authenticated',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const StudentRoute = StudentRouteImport.update({
|
||||
id: '/_student',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const AdminRoute = AdminRouteImport.update({
|
||||
id: '/admin',
|
||||
path: '/admin',
|
||||
@@ -105,11 +120,21 @@ const AuthenticatedSettingsRoute = AuthenticatedSettingsRouteImport.update({
|
||||
path: '/settings',
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any)
|
||||
const AccesoIndexRoute = AccesoIndexRouteImport.update({
|
||||
id: '/acceso/',
|
||||
path: '/acceso/',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const AdminIndexRoute = AdminIndexRouteImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => AdminRoute,
|
||||
} as any)
|
||||
const ITokenRoute = ITokenRouteImport.update({
|
||||
id: '/i/$token',
|
||||
path: '/i/$token',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const JoinTokenRoute = JoinTokenRouteImport.update({
|
||||
id: '/join/$token',
|
||||
path: '/join/$token',
|
||||
@@ -137,6 +162,47 @@ const AuthenticatedGroupsNewRoute = AuthenticatedGroupsNewRouteImport.update({
|
||||
path: '/groups/new',
|
||||
getParentRoute: () => AuthenticatedRoute,
|
||||
} as any)
|
||||
const StudentAlumnoIndexRoute = StudentAlumnoIndexRouteImport.update({
|
||||
id: '/alumno/',
|
||||
path: '/alumno/',
|
||||
getParentRoute: () => StudentRoute,
|
||||
} as any)
|
||||
const StudentAlumnoAvisarRoute = StudentAlumnoAvisarRouteImport.update({
|
||||
id: '/alumno/avisar',
|
||||
path: '/alumno/avisar',
|
||||
getParentRoute: () => StudentRoute,
|
||||
} as any)
|
||||
const StudentAlumnoBienvenidaRoute = StudentAlumnoBienvenidaRouteImport.update({
|
||||
id: '/alumno/bienvenida',
|
||||
path: '/alumno/bienvenida',
|
||||
getParentRoute: () => StudentRoute,
|
||||
} as any)
|
||||
const StudentAlumnoClasesRoute = StudentAlumnoClasesRouteImport.update({
|
||||
id: '/alumno/clases',
|
||||
path: '/alumno/clases',
|
||||
getParentRoute: () => StudentRoute,
|
||||
} as any)
|
||||
const StudentAlumnoInformarPagoRoute =
|
||||
StudentAlumnoInformarPagoRouteImport.update({
|
||||
id: '/alumno/informar-pago',
|
||||
path: '/alumno/informar-pago',
|
||||
getParentRoute: () => StudentRoute,
|
||||
} as any)
|
||||
const StudentAlumnoPagosRoute = StudentAlumnoPagosRouteImport.update({
|
||||
id: '/alumno/pagos',
|
||||
path: '/alumno/pagos',
|
||||
getParentRoute: () => StudentRoute,
|
||||
} as any)
|
||||
const StudentAlumnoPerfilRoute = StudentAlumnoPerfilRouteImport.update({
|
||||
id: '/alumno/perfil',
|
||||
path: '/alumno/perfil',
|
||||
getParentRoute: () => StudentRoute,
|
||||
} as any)
|
||||
const AccesoMailTokenRoute = AccesoMailTokenRouteImport.update({
|
||||
id: '/acceso/mail/$token',
|
||||
path: '/acceso/mail/$token',
|
||||
getParentRoute: () => rootRouteImport,
|
||||
} as any)
|
||||
const AdminAccountsAccountIdRoute = AdminAccountsAccountIdRouteImport.update({
|
||||
id: '/accounts/$accountId',
|
||||
path: '/accounts/$accountId',
|
||||
@@ -187,13 +253,23 @@ export interface FileRoutesByFullPath {
|
||||
'/profile': typeof AuthenticatedProfileRoute
|
||||
'/security': typeof AuthenticatedSecurityRoute
|
||||
'/settings': typeof AuthenticatedSettingsRoute
|
||||
'/i/$token': typeof ITokenRoute
|
||||
'/join/$token': typeof JoinTokenRoute
|
||||
'/report-absence/$token': typeof ReportAbsenceTokenRoute
|
||||
'/acceso/': typeof AccesoIndexRoute
|
||||
'/admin/': typeof AdminIndexRoute
|
||||
'/groups/attention': typeof AuthenticatedGroupsAttentionRoute
|
||||
'/groups/new': typeof AuthenticatedGroupsNewRoute
|
||||
'/alumno/avisar': typeof StudentAlumnoAvisarRoute
|
||||
'/alumno/bienvenida': typeof StudentAlumnoBienvenidaRoute
|
||||
'/alumno/clases': typeof StudentAlumnoClasesRoute
|
||||
'/alumno/informar-pago': typeof StudentAlumnoInformarPagoRoute
|
||||
'/alumno/pagos': typeof StudentAlumnoPagosRoute
|
||||
'/alumno/perfil': typeof StudentAlumnoPerfilRoute
|
||||
'/acceso/mail/$token': typeof AccesoMailTokenRoute
|
||||
'/admin/accounts/$accountId': typeof AdminAccountsAccountIdRoute
|
||||
'/groups/': typeof AuthenticatedGroupsIndexRoute
|
||||
'/alumno/': typeof StudentAlumnoIndexRoute
|
||||
'/class/$sessionId/attendance': typeof AuthenticatedClassSessionIdAttendanceRoute
|
||||
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||
'/groups/$groupId/': typeof AuthenticatedGroupsGroupIdIndexRoute
|
||||
@@ -201,6 +277,7 @@ export interface FileRoutesByFullPath {
|
||||
'/groups/$groupId/attendees/new': typeof AuthenticatedGroupsGroupIdAttendeesNewRoute
|
||||
}
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof AuthenticatedIndexRoute
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/onboarding': typeof OnboardingRoute
|
||||
@@ -212,14 +289,23 @@ export interface FileRoutesByTo {
|
||||
'/profile': typeof AuthenticatedProfileRoute
|
||||
'/security': typeof AuthenticatedSecurityRoute
|
||||
'/settings': typeof AuthenticatedSettingsRoute
|
||||
'/i/$token': typeof ITokenRoute
|
||||
'/join/$token': typeof JoinTokenRoute
|
||||
'/report-absence/$token': typeof ReportAbsenceTokenRoute
|
||||
'/': typeof AuthenticatedIndexRoute
|
||||
'/acceso': typeof AccesoIndexRoute
|
||||
'/admin': typeof AdminIndexRoute
|
||||
'/groups/attention': typeof AuthenticatedGroupsAttentionRoute
|
||||
'/groups/new': typeof AuthenticatedGroupsNewRoute
|
||||
'/alumno/avisar': typeof StudentAlumnoAvisarRoute
|
||||
'/alumno/bienvenida': typeof StudentAlumnoBienvenidaRoute
|
||||
'/alumno/clases': typeof StudentAlumnoClasesRoute
|
||||
'/alumno/informar-pago': typeof StudentAlumnoInformarPagoRoute
|
||||
'/alumno/pagos': typeof StudentAlumnoPagosRoute
|
||||
'/alumno/perfil': typeof StudentAlumnoPerfilRoute
|
||||
'/acceso/mail/$token': typeof AccesoMailTokenRoute
|
||||
'/admin/accounts/$accountId': typeof AdminAccountsAccountIdRoute
|
||||
'/groups': typeof AuthenticatedGroupsIndexRoute
|
||||
'/alumno': typeof StudentAlumnoIndexRoute
|
||||
'/class/$sessionId/attendance': typeof AuthenticatedClassSessionIdAttendanceRoute
|
||||
'/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||
'/groups/$groupId': typeof AuthenticatedGroupsGroupIdIndexRoute
|
||||
@@ -229,6 +315,7 @@ export interface FileRoutesByTo {
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRouteImport
|
||||
'/_authenticated': typeof AuthenticatedRouteWithChildren
|
||||
'/_student': typeof StudentRouteWithChildren
|
||||
'/admin': typeof AdminRouteWithChildren
|
||||
'/forgot-password': typeof ForgotPasswordRoute
|
||||
'/login': typeof LoginRoute
|
||||
@@ -241,14 +328,24 @@ export interface FileRoutesById {
|
||||
'/_authenticated/profile': typeof AuthenticatedProfileRoute
|
||||
'/_authenticated/security': typeof AuthenticatedSecurityRoute
|
||||
'/_authenticated/settings': typeof AuthenticatedSettingsRoute
|
||||
'/i/$token': typeof ITokenRoute
|
||||
'/join/$token': typeof JoinTokenRoute
|
||||
'/report-absence/$token': typeof ReportAbsenceTokenRoute
|
||||
'/_authenticated/': typeof AuthenticatedIndexRoute
|
||||
'/acceso/': typeof AccesoIndexRoute
|
||||
'/admin/': typeof AdminIndexRoute
|
||||
'/_authenticated/groups/attention': typeof AuthenticatedGroupsAttentionRoute
|
||||
'/_authenticated/groups/new': typeof AuthenticatedGroupsNewRoute
|
||||
'/_student/alumno/avisar': typeof StudentAlumnoAvisarRoute
|
||||
'/_student/alumno/bienvenida': typeof StudentAlumnoBienvenidaRoute
|
||||
'/_student/alumno/clases': typeof StudentAlumnoClasesRoute
|
||||
'/_student/alumno/informar-pago': typeof StudentAlumnoInformarPagoRoute
|
||||
'/_student/alumno/pagos': typeof StudentAlumnoPagosRoute
|
||||
'/_student/alumno/perfil': typeof StudentAlumnoPerfilRoute
|
||||
'/acceso/mail/$token': typeof AccesoMailTokenRoute
|
||||
'/admin/accounts/$accountId': typeof AdminAccountsAccountIdRoute
|
||||
'/_authenticated/groups/': typeof AuthenticatedGroupsIndexRoute
|
||||
'/_student/alumno/': typeof StudentAlumnoIndexRoute
|
||||
'/_authenticated/class/$sessionId/attendance': typeof AuthenticatedClassSessionIdAttendanceRoute
|
||||
'/_authenticated/groups/$groupId/analytics': typeof AuthenticatedGroupsGroupIdAnalyticsRoute
|
||||
'/_authenticated/groups/$groupId/': typeof AuthenticatedGroupsGroupIdIndexRoute
|
||||
@@ -271,13 +368,23 @@ export interface FileRouteTypes {
|
||||
| '/profile'
|
||||
| '/security'
|
||||
| '/settings'
|
||||
| '/i/$token'
|
||||
| '/join/$token'
|
||||
| '/report-absence/$token'
|
||||
| '/acceso/'
|
||||
| '/admin/'
|
||||
| '/groups/attention'
|
||||
| '/groups/new'
|
||||
| '/alumno/avisar'
|
||||
| '/alumno/bienvenida'
|
||||
| '/alumno/clases'
|
||||
| '/alumno/informar-pago'
|
||||
| '/alumno/pagos'
|
||||
| '/alumno/perfil'
|
||||
| '/acceso/mail/$token'
|
||||
| '/admin/accounts/$accountId'
|
||||
| '/groups/'
|
||||
| '/alumno/'
|
||||
| '/class/$sessionId/attendance'
|
||||
| '/groups/$groupId/analytics'
|
||||
| '/groups/$groupId/'
|
||||
@@ -285,6 +392,7 @@ export interface FileRouteTypes {
|
||||
| '/groups/$groupId/attendees/new'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to:
|
||||
| '/'
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
| '/onboarding'
|
||||
@@ -296,14 +404,23 @@ export interface FileRouteTypes {
|
||||
| '/profile'
|
||||
| '/security'
|
||||
| '/settings'
|
||||
| '/i/$token'
|
||||
| '/join/$token'
|
||||
| '/report-absence/$token'
|
||||
| '/'
|
||||
| '/acceso'
|
||||
| '/admin'
|
||||
| '/groups/attention'
|
||||
| '/groups/new'
|
||||
| '/alumno/avisar'
|
||||
| '/alumno/bienvenida'
|
||||
| '/alumno/clases'
|
||||
| '/alumno/informar-pago'
|
||||
| '/alumno/pagos'
|
||||
| '/alumno/perfil'
|
||||
| '/acceso/mail/$token'
|
||||
| '/admin/accounts/$accountId'
|
||||
| '/groups'
|
||||
| '/alumno'
|
||||
| '/class/$sessionId/attendance'
|
||||
| '/groups/$groupId/analytics'
|
||||
| '/groups/$groupId'
|
||||
@@ -312,6 +429,7 @@ export interface FileRouteTypes {
|
||||
id:
|
||||
| '__root__'
|
||||
| '/_authenticated'
|
||||
| '/_student'
|
||||
| '/admin'
|
||||
| '/forgot-password'
|
||||
| '/login'
|
||||
@@ -324,14 +442,24 @@ export interface FileRouteTypes {
|
||||
| '/_authenticated/profile'
|
||||
| '/_authenticated/security'
|
||||
| '/_authenticated/settings'
|
||||
| '/i/$token'
|
||||
| '/join/$token'
|
||||
| '/report-absence/$token'
|
||||
| '/_authenticated/'
|
||||
| '/acceso/'
|
||||
| '/admin/'
|
||||
| '/_authenticated/groups/attention'
|
||||
| '/_authenticated/groups/new'
|
||||
| '/_student/alumno/avisar'
|
||||
| '/_student/alumno/bienvenida'
|
||||
| '/_student/alumno/clases'
|
||||
| '/_student/alumno/informar-pago'
|
||||
| '/_student/alumno/pagos'
|
||||
| '/_student/alumno/perfil'
|
||||
| '/acceso/mail/$token'
|
||||
| '/admin/accounts/$accountId'
|
||||
| '/_authenticated/groups/'
|
||||
| '/_student/alumno/'
|
||||
| '/_authenticated/class/$sessionId/attendance'
|
||||
| '/_authenticated/groups/$groupId/analytics'
|
||||
| '/_authenticated/groups/$groupId/'
|
||||
@@ -341,6 +469,7 @@ export interface FileRouteTypes {
|
||||
}
|
||||
export interface RootRouteChildren {
|
||||
AuthenticatedRoute: typeof AuthenticatedRouteWithChildren
|
||||
StudentRoute: typeof StudentRouteWithChildren
|
||||
AdminRoute: typeof AdminRouteWithChildren
|
||||
ForgotPasswordRoute: typeof ForgotPasswordRoute
|
||||
LoginRoute: typeof LoginRoute
|
||||
@@ -348,8 +477,11 @@ export interface RootRouteChildren {
|
||||
ResetPasswordRoute: typeof ResetPasswordRoute
|
||||
SignupRoute: typeof SignupRoute
|
||||
VerifyEmailRoute: typeof VerifyEmailRoute
|
||||
ITokenRoute: typeof ITokenRoute
|
||||
JoinTokenRoute: typeof JoinTokenRoute
|
||||
ReportAbsenceTokenRoute: typeof ReportAbsenceTokenRoute
|
||||
AccesoIndexRoute: typeof AccesoIndexRoute
|
||||
AccesoMailTokenRoute: typeof AccesoMailTokenRoute
|
||||
}
|
||||
|
||||
declare module '@tanstack/react-router' {
|
||||
@@ -361,6 +493,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthenticatedRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/_student': {
|
||||
id: '/_student'
|
||||
path: ''
|
||||
fullPath: '/'
|
||||
preLoaderRoute: typeof StudentRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/admin': {
|
||||
id: '/admin'
|
||||
path: '/admin'
|
||||
@@ -452,6 +591,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthenticatedSettingsRouteImport
|
||||
parentRoute: typeof AuthenticatedRoute
|
||||
}
|
||||
'/acceso/': {
|
||||
id: '/acceso/'
|
||||
path: '/acceso'
|
||||
fullPath: '/acceso/'
|
||||
preLoaderRoute: typeof AccesoIndexRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/admin/': {
|
||||
id: '/admin/'
|
||||
path: '/'
|
||||
@@ -459,6 +605,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AdminIndexRouteImport
|
||||
parentRoute: typeof AdminRoute
|
||||
}
|
||||
'/i/$token': {
|
||||
id: '/i/$token'
|
||||
path: '/i/$token'
|
||||
fullPath: '/i/$token'
|
||||
preLoaderRoute: typeof ITokenRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/join/$token': {
|
||||
id: '/join/$token'
|
||||
path: '/join/$token'
|
||||
@@ -494,6 +647,62 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthenticatedGroupsNewRouteImport
|
||||
parentRoute: typeof AuthenticatedRoute
|
||||
}
|
||||
'/_student/alumno/': {
|
||||
id: '/_student/alumno/'
|
||||
path: '/alumno'
|
||||
fullPath: '/alumno/'
|
||||
preLoaderRoute: typeof StudentAlumnoIndexRouteImport
|
||||
parentRoute: typeof StudentRoute
|
||||
}
|
||||
'/_student/alumno/avisar': {
|
||||
id: '/_student/alumno/avisar'
|
||||
path: '/alumno/avisar'
|
||||
fullPath: '/alumno/avisar'
|
||||
preLoaderRoute: typeof StudentAlumnoAvisarRouteImport
|
||||
parentRoute: typeof StudentRoute
|
||||
}
|
||||
'/_student/alumno/bienvenida': {
|
||||
id: '/_student/alumno/bienvenida'
|
||||
path: '/alumno/bienvenida'
|
||||
fullPath: '/alumno/bienvenida'
|
||||
preLoaderRoute: typeof StudentAlumnoBienvenidaRouteImport
|
||||
parentRoute: typeof StudentRoute
|
||||
}
|
||||
'/_student/alumno/clases': {
|
||||
id: '/_student/alumno/clases'
|
||||
path: '/alumno/clases'
|
||||
fullPath: '/alumno/clases'
|
||||
preLoaderRoute: typeof StudentAlumnoClasesRouteImport
|
||||
parentRoute: typeof StudentRoute
|
||||
}
|
||||
'/_student/alumno/informar-pago': {
|
||||
id: '/_student/alumno/informar-pago'
|
||||
path: '/alumno/informar-pago'
|
||||
fullPath: '/alumno/informar-pago'
|
||||
preLoaderRoute: typeof StudentAlumnoInformarPagoRouteImport
|
||||
parentRoute: typeof StudentRoute
|
||||
}
|
||||
'/_student/alumno/pagos': {
|
||||
id: '/_student/alumno/pagos'
|
||||
path: '/alumno/pagos'
|
||||
fullPath: '/alumno/pagos'
|
||||
preLoaderRoute: typeof StudentAlumnoPagosRouteImport
|
||||
parentRoute: typeof StudentRoute
|
||||
}
|
||||
'/_student/alumno/perfil': {
|
||||
id: '/_student/alumno/perfil'
|
||||
path: '/alumno/perfil'
|
||||
fullPath: '/alumno/perfil'
|
||||
preLoaderRoute: typeof StudentAlumnoPerfilRouteImport
|
||||
parentRoute: typeof StudentRoute
|
||||
}
|
||||
'/acceso/mail/$token': {
|
||||
id: '/acceso/mail/$token'
|
||||
path: '/acceso/mail/$token'
|
||||
fullPath: '/acceso/mail/$token'
|
||||
preLoaderRoute: typeof AccesoMailTokenRouteImport
|
||||
parentRoute: typeof rootRouteImport
|
||||
}
|
||||
'/admin/accounts/$accountId': {
|
||||
id: '/admin/accounts/$accountId'
|
||||
path: '/accounts/$accountId'
|
||||
@@ -581,6 +790,29 @@ const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
||||
AuthenticatedRouteChildren,
|
||||
)
|
||||
|
||||
interface StudentRouteChildren {
|
||||
StudentAlumnoAvisarRoute: typeof StudentAlumnoAvisarRoute
|
||||
StudentAlumnoBienvenidaRoute: typeof StudentAlumnoBienvenidaRoute
|
||||
StudentAlumnoClasesRoute: typeof StudentAlumnoClasesRoute
|
||||
StudentAlumnoInformarPagoRoute: typeof StudentAlumnoInformarPagoRoute
|
||||
StudentAlumnoPagosRoute: typeof StudentAlumnoPagosRoute
|
||||
StudentAlumnoPerfilRoute: typeof StudentAlumnoPerfilRoute
|
||||
StudentAlumnoIndexRoute: typeof StudentAlumnoIndexRoute
|
||||
}
|
||||
|
||||
const StudentRouteChildren: StudentRouteChildren = {
|
||||
StudentAlumnoAvisarRoute: StudentAlumnoAvisarRoute,
|
||||
StudentAlumnoBienvenidaRoute: StudentAlumnoBienvenidaRoute,
|
||||
StudentAlumnoClasesRoute: StudentAlumnoClasesRoute,
|
||||
StudentAlumnoInformarPagoRoute: StudentAlumnoInformarPagoRoute,
|
||||
StudentAlumnoPagosRoute: StudentAlumnoPagosRoute,
|
||||
StudentAlumnoPerfilRoute: StudentAlumnoPerfilRoute,
|
||||
StudentAlumnoIndexRoute: StudentAlumnoIndexRoute,
|
||||
}
|
||||
|
||||
const StudentRouteWithChildren =
|
||||
StudentRoute._addFileChildren(StudentRouteChildren)
|
||||
|
||||
interface AdminRouteChildren {
|
||||
AdminIndexRoute: typeof AdminIndexRoute
|
||||
AdminAccountsAccountIdRoute: typeof AdminAccountsAccountIdRoute
|
||||
@@ -595,6 +827,7 @@ const AdminRouteWithChildren = AdminRoute._addFileChildren(AdminRouteChildren)
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
AuthenticatedRoute: AuthenticatedRouteWithChildren,
|
||||
StudentRoute: StudentRouteWithChildren,
|
||||
AdminRoute: AdminRouteWithChildren,
|
||||
ForgotPasswordRoute: ForgotPasswordRoute,
|
||||
LoginRoute: LoginRoute,
|
||||
@@ -602,8 +835,11 @@ const rootRouteChildren: RootRouteChildren = {
|
||||
ResetPasswordRoute: ResetPasswordRoute,
|
||||
SignupRoute: SignupRoute,
|
||||
VerifyEmailRoute: VerifyEmailRoute,
|
||||
ITokenRoute: ITokenRoute,
|
||||
JoinTokenRoute: JoinTokenRoute,
|
||||
ReportAbsenceTokenRoute: ReportAbsenceTokenRoute,
|
||||
AccesoIndexRoute: AccesoIndexRoute,
|
||||
AccesoMailTokenRoute: AccesoMailTokenRoute,
|
||||
}
|
||||
export const routeTree = rootRouteImport
|
||||
._addFileChildren(rootRouteChildren)
|
||||
|
||||
12
apps/web/src/routes/_student.tsx
Normal file
12
apps/web/src/routes/_student.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { StudentAppProvider } from '../features/student-app/StudentAppProvider'
|
||||
import { StudentLayout } from '../features/student-app/StudentLayout'
|
||||
|
||||
// Student app: its own session and layout, outside `_authenticated` (teacher).
|
||||
export const Route = createFileRoute('/_student')({
|
||||
component: () => (
|
||||
<StudentAppProvider>
|
||||
<StudentLayout />
|
||||
</StudentAppProvider>
|
||||
),
|
||||
})
|
||||
13
apps/web/src/routes/_student/alumno.avisar.tsx
Normal file
13
apps/web/src/routes/_student/alumno.avisar.tsx
Normal file
@@ -0,0 +1,13 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { NotifyAbsenceView } from '../../features/student-app/NotifyAbsenceView'
|
||||
|
||||
function NotifyAbsenceRoute() {
|
||||
const { clase } = Route.useSearch()
|
||||
return <NotifyAbsenceView preselected={clase} />
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/_student/alumno/avisar')({
|
||||
validateSearch: (search: Record<string, unknown>): { clase?: string } =>
|
||||
typeof search.clase === 'string' ? { clase: search.clase } : {},
|
||||
component: NotifyAbsenceRoute,
|
||||
})
|
||||
6
apps/web/src/routes/_student/alumno.bienvenida.tsx
Normal file
6
apps/web/src/routes/_student/alumno.bienvenida.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { WelcomeView } from '../../features/student-app/WelcomeView'
|
||||
|
||||
export const Route = createFileRoute('/_student/alumno/bienvenida')({
|
||||
component: WelcomeView,
|
||||
})
|
||||
6
apps/web/src/routes/_student/alumno.clases.tsx
Normal file
6
apps/web/src/routes/_student/alumno.clases.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { StudentClassesView } from '../../features/student-app/StudentClassesView'
|
||||
|
||||
export const Route = createFileRoute('/_student/alumno/clases')({
|
||||
component: StudentClassesView,
|
||||
})
|
||||
6
apps/web/src/routes/_student/alumno.index.tsx
Normal file
6
apps/web/src/routes/_student/alumno.index.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { StudentHomeView } from '../../features/student-app/StudentHomeView'
|
||||
|
||||
export const Route = createFileRoute('/_student/alumno/')({
|
||||
component: StudentHomeView,
|
||||
})
|
||||
6
apps/web/src/routes/_student/alumno.informar-pago.tsx
Normal file
6
apps/web/src/routes/_student/alumno.informar-pago.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { ReportPaymentView } from '../../features/student-app/ReportPaymentView'
|
||||
|
||||
export const Route = createFileRoute('/_student/alumno/informar-pago')({
|
||||
component: ReportPaymentView,
|
||||
})
|
||||
6
apps/web/src/routes/_student/alumno.pagos.tsx
Normal file
6
apps/web/src/routes/_student/alumno.pagos.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { StudentPaymentsView } from '../../features/student-app/StudentPaymentsView'
|
||||
|
||||
export const Route = createFileRoute('/_student/alumno/pagos')({
|
||||
component: StudentPaymentsView,
|
||||
})
|
||||
6
apps/web/src/routes/_student/alumno.perfil.tsx
Normal file
6
apps/web/src/routes/_student/alumno.perfil.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { StudentProfileView } from '../../features/student-app/StudentProfileView'
|
||||
|
||||
export const Route = createFileRoute('/_student/alumno/perfil')({
|
||||
component: StudentProfileView,
|
||||
})
|
||||
6
apps/web/src/routes/acceso.index.tsx
Normal file
6
apps/web/src/routes/acceso.index.tsx
Normal file
@@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { LinkUsedView } from '../features/student-access/LinkUsedView'
|
||||
|
||||
export const Route = createFileRoute('/acceso/')({
|
||||
component: () => <LinkUsedView variant="signed-out" />,
|
||||
})
|
||||
11
apps/web/src/routes/acceso.mail.$token.tsx
Normal file
11
apps/web/src/routes/acceso.mail.$token.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { ConfirmRecoveryEmailView } from '../features/student-access/ConfirmRecoveryEmailView'
|
||||
|
||||
function ConfirmRecoveryEmailRoute() {
|
||||
const { token } = Route.useParams()
|
||||
return <ConfirmRecoveryEmailView token={token} />
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/acceso/mail/$token')({
|
||||
component: ConfirmRecoveryEmailRoute,
|
||||
})
|
||||
16
apps/web/src/routes/i.$token.tsx
Normal file
16
apps/web/src/routes/i.$token.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { StudentLinkProvider } from '../features/student-access/StudentLinkProvider'
|
||||
import { StudentLinkView } from '../features/student-access/StudentLinkView'
|
||||
|
||||
function StudentLinkRoute() {
|
||||
const { token } = Route.useParams()
|
||||
return (
|
||||
<StudentLinkProvider token={token}>
|
||||
<StudentLinkView />
|
||||
</StudentLinkProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export const Route = createFileRoute('/i/$token')({
|
||||
component: StudentLinkRoute,
|
||||
})
|
||||
Reference in New Issue
Block a user