development #14
@@ -4,6 +4,8 @@ import { useMutation, useQuery } from '@tanstack/react-query'
|
|||||||
import type { AbsenceDetails } from '@gruperly/shared'
|
import type { AbsenceDetails } from '@gruperly/shared'
|
||||||
import { useToast } from '../../components/ui'
|
import { useToast } from '../../components/ui'
|
||||||
import { ApiError, getAbsenceDetails, publicNotifyAbsence } from '../../lib/api'
|
import { ApiError, getAbsenceDetails, publicNotifyAbsence } from '../../lib/api'
|
||||||
|
import { errorMessage } from '../../i18n'
|
||||||
|
import { i18n } from '../../i18n/instance'
|
||||||
|
|
||||||
type AbsenceNotifyContextValue = {
|
type AbsenceNotifyContextValue = {
|
||||||
token: string
|
token: string
|
||||||
@@ -32,14 +34,14 @@ export function AbsenceNotifyProvider({ token, children }: { token: string; chil
|
|||||||
mutationFn: (sessionId: string) => publicNotifyAbsence({ token, classSessionId: sessionId }),
|
mutationFn: (sessionId: string) => publicNotifyAbsence({ token, classSessionId: sessionId }),
|
||||||
onSuccess: (_data, sessionId) => {
|
onSuccess: (_data, sessionId) => {
|
||||||
setLocallyNotified((prev) => [...prev, sessionId])
|
setLocallyNotified((prev) => [...prev, sessionId])
|
||||||
toast.success('Tu profesor ya tiene registrado el aviso. Gracias por avisar.', 'Ausencia avisada')
|
toast.success(i18n.t('public:absence.done'), i18n.t('public:absence.doneTitle'))
|
||||||
},
|
},
|
||||||
onError: (error: unknown) => {
|
onError: (error: unknown) => {
|
||||||
if (error instanceof ApiError && error.problem?.status === 404) {
|
if (error instanceof ApiError && error.problem?.status === 404) {
|
||||||
toast.error('Este enlace ya no es válido. Consultá a tu profesor.')
|
toast.error(i18n.t('public:absence.invalidLink'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
toast.error(error instanceof Error ? error.message : 'No pudimos registrar el aviso.')
|
toast.error(errorMessage(error, i18n.t('public:absence.error')))
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ import { PublicFooter, PublicHeader } from '../../components/layout'
|
|||||||
import { Badge } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { AbsenceSessionRow } from './AbsenceSessionRow'
|
import { AbsenceSessionRow } from './AbsenceSessionRow'
|
||||||
import { useAbsenceNotify } from './AbsenceNotifyProvider'
|
import { useAbsenceNotify } from './AbsenceNotifyProvider'
|
||||||
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export function AbsenceNotifyView() {
|
export function AbsenceNotifyView() {
|
||||||
const { details, detailsPending, detailsFailed } = useAbsenceNotify()
|
const { details, detailsPending, detailsFailed } = useAbsenceNotify()
|
||||||
|
const { t } = useTranslation('public')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen flex-col justify-between bg-background text-primary selection:bg-accent selection:text-white">
|
<div className="flex min-h-screen flex-col justify-between bg-background text-primary selection:bg-accent selection:text-white">
|
||||||
@@ -16,15 +18,15 @@ export function AbsenceNotifyView() {
|
|||||||
{detailsPending ? (
|
{detailsPending ? (
|
||||||
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
||||||
<Loader2 className="size-8 animate-spin text-accent" />
|
<Loader2 className="size-8 animate-spin text-accent" />
|
||||||
<p className="text-sm text-foreground/60">Cargando tus clases...</p>
|
<p className="text-sm text-foreground/60">{t('absence.loading')}</p>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{detailsFailed || (!details && !detailsPending) ? (
|
{detailsFailed || (!details && !detailsPending) ? (
|
||||||
<div className="space-y-3 rounded-2xl border border-danger/20 bg-danger-soft p-6 text-center sm:p-8">
|
<div className="space-y-3 rounded-2xl border border-danger/20 bg-danger-soft p-6 text-center sm:p-8">
|
||||||
<h2 className="text-xl font-bold text-danger">Enlace no válido</h2>
|
<h2 className="text-xl font-bold text-danger">{t('absence.invalidTitle')}</h2>
|
||||||
<p className="mx-auto max-w-sm text-sm leading-relaxed text-foreground/70">
|
<p className="mx-auto max-w-sm text-sm leading-relaxed text-foreground/70">
|
||||||
No pudimos identificarte con este enlace. Consultá con tu profesor para solicitar uno nuevo.
|
{t('absence.invalidDescription')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -36,18 +38,22 @@ export function AbsenceNotifyView() {
|
|||||||
<CalendarX2 className="size-7" />
|
<CalendarX2 className="size-7" />
|
||||||
</div>
|
</div>
|
||||||
<Badge variant="neutral" className="mb-2">
|
<Badge variant="neutral" className="mb-2">
|
||||||
Aviso de ausencia
|
{t('absence.badge')}
|
||||||
</Badge>
|
</Badge>
|
||||||
<h1 className="text-2xl font-bold text-primary">Hola, {details.fullName}</h1>
|
<h1 className="text-2xl font-bold text-primary">{t('absence.greeting', { name: details.fullName })}</h1>
|
||||||
<p className="mt-1 text-sm font-medium text-foreground/80">
|
<p className="mt-1 text-sm font-medium text-foreground/80">
|
||||||
Grupo: <span className="text-primary">{details.groupName}</span>
|
<Trans
|
||||||
|
t={t}
|
||||||
|
i18nKey="absence.group"
|
||||||
|
values={{ group: details.groupName }}
|
||||||
|
components={{ strong: <span className="text-primary" /> }}
|
||||||
|
/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{details.sessions.length === 0 ? (
|
{details.sessions.length === 0 ? (
|
||||||
<p className="rounded-xl border border-dashed border-border bg-primary-soft/40 px-4 py-8 text-center text-sm text-foreground/60">
|
<p className="rounded-xl border border-dashed border-border bg-primary-soft/40 px-4 py-8 text-center text-sm text-foreground/60">
|
||||||
No tenés clases programadas para hoy. Si necesitás avisar de todas formas, contactá a tu
|
{t('absence.noClasses')}
|
||||||
profesor.
|
|
||||||
</p>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<ul className="space-y-3">
|
<ul className="space-y-3">
|
||||||
@@ -58,7 +64,7 @@ export function AbsenceNotifyView() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<p className="text-center text-xs leading-relaxed text-foreground/50">
|
<p className="text-center text-xs leading-relaxed text-foreground/50">
|
||||||
Si avisás con anticipación, tu cupo se libera para una clase de recuperación.
|
{t('absence.hint')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { CheckCircle2, Loader2 } from 'lucide-react'
|
import { CheckCircle2, Loader2 } from 'lucide-react'
|
||||||
import { Button } from '../../components/ui'
|
import { Button } from '../../components/ui'
|
||||||
import { useAbsenceNotify } from './AbsenceNotifyProvider'
|
import { useAbsenceNotify } from './AbsenceNotifyProvider'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { useIntlLocale } from '../../i18n'
|
||||||
|
|
||||||
type AbsenceSession = {
|
type AbsenceSession = {
|
||||||
sessionId: string
|
sessionId: string
|
||||||
@@ -11,22 +13,20 @@ type AbsenceSession = {
|
|||||||
|
|
||||||
export function AbsenceSessionRow({ session }: { session: AbsenceSession }) {
|
export function AbsenceSessionRow({ session }: { session: AbsenceSession }) {
|
||||||
const { isNotified, isNotifying, notify } = useAbsenceNotify()
|
const { isNotified, isNotifying, notify } = useAbsenceNotify()
|
||||||
const time = new Date(session.startsAt).toLocaleTimeString('es-MX', {
|
const { t } = useTranslation('public')
|
||||||
hour: '2-digit',
|
const locale = useIntlLocale()
|
||||||
minute: '2-digit',
|
const time = new Date(session.startsAt).toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' })
|
||||||
hour12: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className="flex items-center justify-between gap-3 rounded-xl border border-border bg-primary-soft/30 px-4 py-3">
|
<li className="flex items-center justify-between gap-3 rounded-xl border border-border bg-primary-soft/30 px-4 py-3">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="text-sm font-semibold text-primary">Hoy · {time} hs</p>
|
<p className="text-sm font-semibold text-primary">{t('absence.today', { time })}</p>
|
||||||
<p className="truncate text-xs text-foreground/60">{session.groupName}</p>
|
<p className="truncate text-xs text-foreground/60">{session.groupName}</p>
|
||||||
</div>
|
</div>
|
||||||
{isNotified(session) ? (
|
{isNotified(session) ? (
|
||||||
<span className="inline-flex shrink-0 items-center gap-1.5 rounded-full bg-success-soft px-2.5 py-1 text-xs font-medium text-success">
|
<span className="inline-flex shrink-0 items-center gap-1.5 rounded-full bg-success-soft px-2.5 py-1 text-xs font-medium text-success">
|
||||||
<CheckCircle2 className="size-3.5" />
|
<CheckCircle2 className="size-3.5" />
|
||||||
Ya avisaste
|
{t('absence.notified')}
|
||||||
</span>
|
</span>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<Button
|
||||||
@@ -36,7 +36,7 @@ export function AbsenceSessionRow({ session }: { session: AbsenceSession }) {
|
|||||||
onClick={() => notify(session.sessionId)}
|
onClick={() => notify(session.sessionId)}
|
||||||
>
|
>
|
||||||
{isNotifying(session.sessionId) ? <Loader2 className="size-4 animate-spin" /> : null}
|
{isNotifying(session.sessionId) ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||||
Avisar ausencia
|
{t('absence.notify')}
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -2,9 +2,11 @@ import { CalendarClock, GraduationCap, Users } from 'lucide-react'
|
|||||||
import { Badge } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { billingTypeLabel, formatPrice, formatSchedule } from '../../lib/format'
|
import { billingTypeLabel, formatPrice, formatSchedule } from '../../lib/format'
|
||||||
import { useJoinGroup } from './JoinGroupProvider'
|
import { useJoinGroup } from './JoinGroupProvider'
|
||||||
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export function GroupInviteSummary() {
|
export function GroupInviteSummary() {
|
||||||
const { group } = useJoinGroup()
|
const { group } = useJoinGroup()
|
||||||
|
const { t } = useTranslation('public')
|
||||||
if (!group) return null
|
if (!group) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -12,12 +14,17 @@ export function GroupInviteSummary() {
|
|||||||
<div className="mb-2 flex items-center gap-2">
|
<div className="mb-2 flex items-center gap-2">
|
||||||
<Badge variant="neutral" className="gap-1 text-[11px]">
|
<Badge variant="neutral" className="gap-1 text-[11px]">
|
||||||
<GraduationCap className="size-3.5 text-accent" />
|
<GraduationCap className="size-3.5 text-accent" />
|
||||||
<span>Invitación Oficial</span>
|
<span>{t('join.badge')}</span>
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
<h1 className="text-2xl font-bold text-primary">{group.name}</h1>
|
<h1 className="text-2xl font-bold text-primary">{group.name}</h1>
|
||||||
<p className="mt-1 text-sm font-medium text-foreground/80">
|
<p className="mt-1 text-sm font-medium text-foreground/80">
|
||||||
Profesor: <span className="font-semibold text-primary">{group.teacherName}</span>
|
<Trans
|
||||||
|
t={t}
|
||||||
|
i18nKey="join.teacher"
|
||||||
|
values={{ name: group.teacherName }}
|
||||||
|
components={{ strong: <span className="font-semibold text-primary" /> }}
|
||||||
|
/>
|
||||||
</p>
|
</p>
|
||||||
{group.description ? <p className="mt-2 text-sm text-foreground/60">{group.description}</p> : null}
|
{group.description ? <p className="mt-2 text-sm text-foreground/60">{group.description}</p> : null}
|
||||||
|
|
||||||
@@ -39,14 +46,13 @@ export function GroupInviteSummary() {
|
|||||||
{group.capacity ? (
|
{group.capacity ? (
|
||||||
<div className="inline-flex items-center gap-1.5 rounded-lg bg-primary-soft px-2.5 py-1 text-foreground/80">
|
<div className="inline-flex items-center gap-1.5 rounded-lg bg-primary-soft px-2.5 py-1 text-foreground/80">
|
||||||
<Users className="size-3.5 text-accent" />
|
<Users className="size-3.5 text-accent" />
|
||||||
<span>Cupo {group.capacity}</span>
|
<span>{t('join.capacity', { count: group.capacity })}</span>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="mt-3 text-xs leading-relaxed text-foreground/60">
|
<p className="mt-3 text-xs leading-relaxed text-foreground/60">
|
||||||
Al completar el formulario envías una solicitud de pre-inscripción. El profesor revisará tus
|
{t('join.notice')}
|
||||||
datos y te confirmará el lugar.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export function InvalidInviteCard() {
|
export function InvalidInviteCard() {
|
||||||
|
const { t } = useTranslation('public')
|
||||||
return (
|
return (
|
||||||
<div className="space-y-3 rounded-2xl border border-danger/20 bg-danger-soft p-6 text-center sm:p-8">
|
<div className="space-y-3 rounded-2xl border border-danger/20 bg-danger-soft p-6 text-center sm:p-8">
|
||||||
<h2 className="text-xl font-bold text-danger">Enlace no válido o expirado</h2>
|
<h2 className="text-xl font-bold text-danger">{t('join.invalidTitle')}</h2>
|
||||||
<p className="mx-auto max-w-sm text-sm text-foreground/70">
|
<p className="mx-auto max-w-sm text-sm text-foreground/70">
|
||||||
No pudimos encontrar este grupo. Por favor consulta con tu profesor para solicitar un nuevo enlace de
|
{t('join.invalidDescription')}
|
||||||
invitación.
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Loader2 } from 'lucide-react'
|
import { Loader2 } from 'lucide-react'
|
||||||
import { Button, Input, Label } from '../../components/ui'
|
import { Button, Input, Label } from '../../components/ui'
|
||||||
import { useJoinGroup } from './JoinGroupProvider'
|
import { useJoinGroup } from './JoinGroupProvider'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export function JoinForm() {
|
export function JoinForm() {
|
||||||
const {
|
const {
|
||||||
@@ -16,13 +17,14 @@ export function JoinForm() {
|
|||||||
submit,
|
submit,
|
||||||
isSubmitting,
|
isSubmitting,
|
||||||
} = useJoinGroup()
|
} = useJoinGroup()
|
||||||
|
const { t } = useTranslation('public')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6">
|
<div className="space-y-6">
|
||||||
<div>
|
<div>
|
||||||
<h2 className="text-lg font-bold text-primary">Completa tus datos</h2>
|
<h2 className="text-lg font-bold text-primary">{t('join.formTitle')}</h2>
|
||||||
<p className="mt-0.5 text-xs text-foreground/60">
|
<p className="mt-0.5 text-xs text-foreground/60">
|
||||||
Ingresa tus datos para registrarte en la lista de alumnos de este grupo.
|
{t('join.formDescription')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -42,11 +44,11 @@ export function JoinForm() {
|
|||||||
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
<div className="grid grid-cols-1 gap-3 sm:grid-cols-2">
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="student-first-name" className="mb-1 block text-xs">
|
<Label htmlFor="student-first-name" className="mb-1 block text-xs">
|
||||||
Nombre <span className="text-danger">*</span>
|
{t('join.firstName')} <span className="text-danger">*</span>
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="student-first-name"
|
id="student-first-name"
|
||||||
placeholder="Ej. Sofía"
|
placeholder={t('join.firstNamePlaceholder')}
|
||||||
value={firstName}
|
value={firstName}
|
||||||
onChange={(e) => setFirstName(e.target.value)}
|
onChange={(e) => setFirstName(e.target.value)}
|
||||||
required
|
required
|
||||||
@@ -55,11 +57,11 @@ export function JoinForm() {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="student-last-name" className="mb-1 block text-xs">
|
<Label htmlFor="student-last-name" className="mb-1 block text-xs">
|
||||||
Apellido <span className="text-danger">*</span>
|
{t('join.lastName')} <span className="text-danger">*</span>
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="student-last-name"
|
id="student-last-name"
|
||||||
placeholder="Ej. Fernández"
|
placeholder={t('join.lastNamePlaceholder')}
|
||||||
value={lastName}
|
value={lastName}
|
||||||
onChange={(e) => setLastName(e.target.value)}
|
onChange={(e) => setLastName(e.target.value)}
|
||||||
required
|
required
|
||||||
@@ -69,28 +71,28 @@ export function JoinForm() {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="student-phone" className="mb-1 block text-xs">
|
<Label htmlFor="student-phone" className="mb-1 block text-xs">
|
||||||
Teléfono / WhatsApp <span className="text-danger">*</span>
|
{t('join.phone')} <span className="text-danger">*</span>
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="student-phone"
|
id="student-phone"
|
||||||
placeholder="Ej. +54 9 11 2345-6789"
|
placeholder={t('join.phonePlaceholder')}
|
||||||
value={phone}
|
value={phone}
|
||||||
onChange={(e) => setPhone(e.target.value)}
|
onChange={(e) => setPhone(e.target.value)}
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
<p className="mt-1 text-[11px] text-foreground/50">
|
<p className="mt-1 text-[11px] text-foreground/50">
|
||||||
El profesor se comunicará contigo por WhatsApp a este número.
|
{t('join.phoneHint')}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Label htmlFor="student-email" className="mb-1 block text-xs">
|
<Label htmlFor="student-email" className="mb-1 block text-xs">
|
||||||
Email (opcional)
|
{t('join.email')}
|
||||||
</Label>
|
</Label>
|
||||||
<Input
|
<Input
|
||||||
id="student-email"
|
id="student-email"
|
||||||
type="email"
|
type="email"
|
||||||
placeholder="alumno@ejemplo.com"
|
placeholder={t('join.emailPlaceholder')}
|
||||||
value={email}
|
value={email}
|
||||||
onChange={(e) => setEmail(e.target.value)}
|
onChange={(e) => setEmail(e.target.value)}
|
||||||
/>
|
/>
|
||||||
@@ -104,7 +106,7 @@ export function JoinForm() {
|
|||||||
className="w-full gap-2 py-2.5 text-sm font-semibold"
|
className="w-full gap-2 py-2.5 text-sm font-semibold"
|
||||||
>
|
>
|
||||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||||
<span>Enviar Solicitud</span>
|
<span>{t('join.submit')}</span>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@@ -3,6 +3,9 @@ import type { ReactNode } from 'react'
|
|||||||
import { useMutation, useQuery } from '@tanstack/react-query'
|
import { useMutation, useQuery } from '@tanstack/react-query'
|
||||||
import type { GroupInviteInfoDto } from '@gruperly/shared'
|
import type { GroupInviteInfoDto } from '@gruperly/shared'
|
||||||
import { ApiError, getInviteInfo, joinViaInvite } from '../../lib/api'
|
import { ApiError, getInviteInfo, joinViaInvite } from '../../lib/api'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
import { errorMessage as apiErrorMessage } from '../../i18n'
|
||||||
|
import { i18n } from '../../i18n/instance'
|
||||||
|
|
||||||
type JoinGroupContextValue = {
|
type JoinGroupContextValue = {
|
||||||
token: string
|
token: string
|
||||||
@@ -26,6 +29,7 @@ type JoinGroupContextValue = {
|
|||||||
const JoinGroupContext = createContext<JoinGroupContextValue | null>(null)
|
const JoinGroupContext = createContext<JoinGroupContextValue | null>(null)
|
||||||
|
|
||||||
export function JoinGroupProvider({ token, children }: { token: string; children: ReactNode }) {
|
export function JoinGroupProvider({ token, children }: { token: string; children: ReactNode }) {
|
||||||
|
useTranslation()
|
||||||
const [firstName, setFirstName] = useState('')
|
const [firstName, setFirstName] = useState('')
|
||||||
const [lastName, setLastName] = useState('')
|
const [lastName, setLastName] = useState('')
|
||||||
const [phone, setPhone] = useState('')
|
const [phone, setPhone] = useState('')
|
||||||
@@ -50,41 +54,33 @@ export function JoinGroupProvider({ token, children }: { token: string; children
|
|||||||
}),
|
}),
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
setErrorMessage(null)
|
setErrorMessage(null)
|
||||||
setPreRegistrationMessage(data.message)
|
// The API's `message` is Spanish only: the card words it in the UI language.
|
||||||
|
void data
|
||||||
|
setPreRegistrationMessage(i18n.t('public:join.sentMessage'))
|
||||||
},
|
},
|
||||||
onError: (error: unknown) => {
|
onError: (error: unknown) => {
|
||||||
if (error instanceof ApiError) {
|
if (error instanceof ApiError) {
|
||||||
if (error.problem?.code === 'attendee_already_registered') {
|
if (error.problem?.code === 'attendee_already_registered') {
|
||||||
setErrorMessage(
|
setErrorMessage(i18n.t('public:join.alreadyRegistered'))
|
||||||
'Ya te encuentras registrado en este grupo con ese número de teléfono. El profesor ya tiene tus datos.',
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (error.problem?.code === 'pre_registration_already_pending') {
|
if (error.problem?.code === 'pre_registration_already_pending') {
|
||||||
setErrorMessage(
|
setErrorMessage(i18n.t('public:join.alreadyPending'))
|
||||||
'Ya enviaste una solicitud de inscripción para este grupo y está pendiente de revisión. Pronto recibirás novedades.',
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (error.problem?.code === 'pre_registration_already_approved') {
|
if (error.problem?.code === 'pre_registration_already_approved') {
|
||||||
setErrorMessage('Tu inscripción para este grupo ya fue aprobada.')
|
setErrorMessage(i18n.t('public:join.alreadyApproved'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setErrorMessage(error.message || 'Error al procesar la inscripción.')
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
if (error instanceof Error) {
|
setErrorMessage(apiErrorMessage(error, i18n.t('public:join.error')))
|
||||||
setErrorMessage(error.message)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
setErrorMessage('Ocurrió un error inesperado. Por favor, intenta de nuevo.')
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
setErrorMessage(null)
|
setErrorMessage(null)
|
||||||
if (!firstName.trim() || !lastName.trim() || !phone.trim()) {
|
if (!firstName.trim() || !lastName.trim() || !phone.trim()) {
|
||||||
setErrorMessage('Por favor completa los campos requeridos (Nombre, Apellido y Teléfono).')
|
setErrorMessage(i18n.t('public:join.required'))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
joinMutation.mutate()
|
joinMutation.mutate()
|
||||||
|
|||||||
@@ -5,9 +5,11 @@ import { InvalidInviteCard } from './InvalidInviteCard'
|
|||||||
import { JoinForm } from './JoinForm'
|
import { JoinForm } from './JoinForm'
|
||||||
import { useJoinGroup } from './JoinGroupProvider'
|
import { useJoinGroup } from './JoinGroupProvider'
|
||||||
import { PreRegistrationNoticeCard } from './PreRegistrationNoticeCard'
|
import { PreRegistrationNoticeCard } from './PreRegistrationNoticeCard'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export function JoinGroupView() {
|
export function JoinGroupView() {
|
||||||
const { group, invitePending, inviteFailed, preRegistrationMessage } = useJoinGroup()
|
const { group, invitePending, inviteFailed, preRegistrationMessage } = useJoinGroup()
|
||||||
|
const { t } = useTranslation('public')
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex min-h-screen flex-col justify-between bg-background text-primary selection:bg-accent selection:text-white">
|
<div className="flex min-h-screen flex-col justify-between bg-background text-primary selection:bg-accent selection:text-white">
|
||||||
@@ -18,7 +20,7 @@ export function JoinGroupView() {
|
|||||||
{invitePending ? (
|
{invitePending ? (
|
||||||
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
<div className="flex flex-col items-center justify-center gap-3 py-20">
|
||||||
<Loader2 className="size-8 animate-spin text-accent" />
|
<Loader2 className="size-8 animate-spin text-accent" />
|
||||||
<p className="text-sm text-foreground/60">Cargando información del grupo...</p>
|
<p className="text-sm text-foreground/60">{t('join.loading')}</p>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
import { Clock } from 'lucide-react'
|
import { Clock } from 'lucide-react'
|
||||||
import { Badge } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { useJoinGroup } from './JoinGroupProvider'
|
import { useJoinGroup } from './JoinGroupProvider'
|
||||||
|
import { Trans, useTranslation } from 'react-i18next'
|
||||||
|
|
||||||
export function PreRegistrationNoticeCard() {
|
export function PreRegistrationNoticeCard() {
|
||||||
const { group, preRegistrationMessage } = useJoinGroup()
|
const { group, preRegistrationMessage } = useJoinGroup()
|
||||||
|
const { t } = useTranslation('public')
|
||||||
if (!group || !preRegistrationMessage) return null
|
if (!group || !preRegistrationMessage) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -14,16 +16,19 @@ export function PreRegistrationNoticeCard() {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<Badge variant="neutral" className="mb-2">
|
<Badge variant="neutral" className="mb-2">
|
||||||
Pre-inscripción
|
{t('join.sentBadge')}
|
||||||
</Badge>
|
</Badge>
|
||||||
<h1 className="text-2xl font-bold text-primary">Solicitud enviada</h1>
|
<h1 className="text-2xl font-bold text-primary">{t('join.sentTitle')}</h1>
|
||||||
<p className="mt-2 text-sm leading-relaxed text-foreground/70">{preRegistrationMessage}</p>
|
<p className="mt-2 text-sm leading-relaxed text-foreground/70">{preRegistrationMessage}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p className="text-xs text-foreground/60">
|
<p className="text-xs text-foreground/60">
|
||||||
El profesor revisará tu solicitud para el grupo{' '}
|
<Trans
|
||||||
<strong className="font-semibold text-primary">{group.name}</strong> y se pondrá en contacto
|
t={t}
|
||||||
contigo por WhatsApp para confirmarte el lugar.
|
i18nKey="join.sentFooter"
|
||||||
|
values={{ group: group.name }}
|
||||||
|
components={{ strong: <strong className="font-semibold text-primary" /> }}
|
||||||
|
/>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
|||||||
2
apps/web/src/i18n/i18next.d.ts
vendored
2
apps/web/src/i18n/i18next.d.ts
vendored
@@ -19,6 +19,7 @@ import type mp from './locales/es-AR/mp.json'
|
|||||||
import type whatsapp from './locales/es-AR/whatsapp.json'
|
import type whatsapp from './locales/es-AR/whatsapp.json'
|
||||||
import type onboarding from './locales/es-AR/onboarding.json'
|
import type onboarding from './locales/es-AR/onboarding.json'
|
||||||
import type account from './locales/es-AR/account.json'
|
import type account from './locales/es-AR/account.json'
|
||||||
|
import type public from './locales/es-AR/public.json'
|
||||||
import type validation from './locales/es-AR/validation.json'
|
import type validation from './locales/es-AR/validation.json'
|
||||||
|
|
||||||
// es-AR es la fuente: una clave que no exista ahí rompe el typecheck.
|
// es-AR es la fuente: una clave que no exista ahí rompe el typecheck.
|
||||||
@@ -33,6 +34,7 @@ declare module 'i18next' {
|
|||||||
pwa: typeof pwa
|
pwa: typeof pwa
|
||||||
settings: typeof settings
|
settings: typeof settings
|
||||||
validation: typeof validation
|
validation: typeof validation
|
||||||
|
'public': typeof public
|
||||||
'account': typeof account
|
'account': typeof account
|
||||||
'onboarding': typeof onboarding
|
'onboarding': typeof onboarding
|
||||||
'whatsapp': typeof whatsapp
|
'whatsapp': typeof whatsapp
|
||||||
|
|||||||
49
apps/web/src/i18n/locales/en/public.json
Normal file
49
apps/web/src/i18n/locales/en/public.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"join": {
|
||||||
|
"badge": "Official invite",
|
||||||
|
"teacher": "Teacher: <strong>{{name}}</strong>",
|
||||||
|
"capacity": "{{count}} spots",
|
||||||
|
"notice": "Submitting the form sends a pre-registration request. Your teacher will review your details and confirm your spot.",
|
||||||
|
"invalidTitle": "Invalid or expired link",
|
||||||
|
"invalidDescription": "We couldn't find this group. Ask your teacher for a new link.",
|
||||||
|
"formTitle": "Fill in your details",
|
||||||
|
"formDescription": "Enter your details to sign up for this group.",
|
||||||
|
"firstName": "First name",
|
||||||
|
"firstNamePlaceholder": "E.g. Sophia",
|
||||||
|
"lastName": "Last name",
|
||||||
|
"lastNamePlaceholder": "E.g. Smith",
|
||||||
|
"phone": "Phone / WhatsApp",
|
||||||
|
"phonePlaceholder": "E.g. +1 555 123 4567",
|
||||||
|
"phoneHint": "Your teacher will contact you on WhatsApp at this number.",
|
||||||
|
"email": "Email (optional)",
|
||||||
|
"emailPlaceholder": "student@example.com",
|
||||||
|
"submit": "Send request",
|
||||||
|
"loading": "Loading group information...",
|
||||||
|
"sentBadge": "Pre-registration",
|
||||||
|
"sentTitle": "Request sent",
|
||||||
|
"sentMessage": "We received your pre-registration request.",
|
||||||
|
"sentFooter": "Your teacher will review your request for <strong>{{group}}</strong> and contact you on WhatsApp to confirm your spot.",
|
||||||
|
"alreadyRegistered": "You're already registered in this group with that phone number. Your teacher already has your details.",
|
||||||
|
"alreadyPending": "You already sent a request for this group and it's pending review. You'll hear back soon.",
|
||||||
|
"alreadyApproved": "Your registration for this group was already approved.",
|
||||||
|
"error": "We couldn't process your registration.",
|
||||||
|
"required": "Fill in the required fields (first name, last name and phone)."
|
||||||
|
},
|
||||||
|
"absence": {
|
||||||
|
"loading": "Loading your classes...",
|
||||||
|
"invalidTitle": "Invalid link",
|
||||||
|
"invalidDescription": "We couldn't identify you with this link. Ask your teacher for a new one.",
|
||||||
|
"badge": "Absence notice",
|
||||||
|
"greeting": "Hi, {{name}}",
|
||||||
|
"group": "Group: <strong>{{group}}</strong>",
|
||||||
|
"noClasses": "You have no classes scheduled for today. If you need to let them know anyway, contact your teacher.",
|
||||||
|
"hint": "If you let them know in advance, your spot opens up for a make-up class.",
|
||||||
|
"today": "Today · {{time}}",
|
||||||
|
"notified": "Already notified",
|
||||||
|
"notify": "Report absence",
|
||||||
|
"doneTitle": "Absence reported",
|
||||||
|
"done": "Your teacher has your notice. Thanks for letting them know.",
|
||||||
|
"invalidLink": "This link is no longer valid. Ask your teacher.",
|
||||||
|
"error": "We couldn't register the notice."
|
||||||
|
}
|
||||||
|
}
|
||||||
49
apps/web/src/i18n/locales/es-419/public.json
Normal file
49
apps/web/src/i18n/locales/es-419/public.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"join": {
|
||||||
|
"badge": "Invitación oficial",
|
||||||
|
"teacher": "Profesor: <strong>{{name}}</strong>",
|
||||||
|
"capacity": "Cupo {{count}}",
|
||||||
|
"notice": "Al completar el formulario envías una solicitud de preinscripción. El profesor revisará tus datos y te confirmará el lugar.",
|
||||||
|
"invalidTitle": "Enlace no válido o vencido",
|
||||||
|
"invalidDescription": "No pudimos encontrar este grupo. Consulta con tu profesor para pedirle un enlace nuevo.",
|
||||||
|
"formTitle": "Completa tus datos",
|
||||||
|
"formDescription": "Ingresa tus datos para inscribirte en este grupo.",
|
||||||
|
"firstName": "Nombre",
|
||||||
|
"firstNamePlaceholder": "Ej.: Sofía",
|
||||||
|
"lastName": "Apellido",
|
||||||
|
"lastNamePlaceholder": "Ej.: Fernández",
|
||||||
|
"phone": "Teléfono / WhatsApp",
|
||||||
|
"phonePlaceholder": "Ej.: +52 55 1234 5678",
|
||||||
|
"phoneHint": "El profesor se comunicará contigo por WhatsApp a este número.",
|
||||||
|
"email": "Email (opcional)",
|
||||||
|
"emailPlaceholder": "alumno@ejemplo.com",
|
||||||
|
"submit": "Enviar solicitud",
|
||||||
|
"loading": "Cargando información del grupo...",
|
||||||
|
"sentBadge": "Preinscripción",
|
||||||
|
"sentTitle": "Solicitud enviada",
|
||||||
|
"sentMessage": "Recibimos tu solicitud de preinscripción.",
|
||||||
|
"sentFooter": "El profesor revisará tu solicitud para el grupo <strong>{{group}}</strong> y se comunicará contigo por WhatsApp para confirmarte el lugar.",
|
||||||
|
"alreadyRegistered": "Ya estás inscrito en este grupo con ese número de teléfono. El profesor ya tiene tus datos.",
|
||||||
|
"alreadyPending": "Ya enviaste una solicitud para este grupo y está pendiente de revisión. Pronto tendrás novedades.",
|
||||||
|
"alreadyApproved": "Tu inscripción para este grupo ya fue aprobada.",
|
||||||
|
"error": "No pudimos procesar la inscripción.",
|
||||||
|
"required": "Completa los campos obligatorios (nombre, apellido y teléfono)."
|
||||||
|
},
|
||||||
|
"absence": {
|
||||||
|
"loading": "Cargando tus clases...",
|
||||||
|
"invalidTitle": "Enlace no válido",
|
||||||
|
"invalidDescription": "No pudimos identificarte con este enlace. Consulta con tu profesor para pedirle uno nuevo.",
|
||||||
|
"badge": "Aviso de ausencia",
|
||||||
|
"greeting": "Hola, {{name}}",
|
||||||
|
"group": "Grupo: <strong>{{group}}</strong>",
|
||||||
|
"noClasses": "No tienes clases programadas para hoy. Si necesitas avisar de todas formas, contacta a tu profesor.",
|
||||||
|
"hint": "Si avisas con anticipación, tu lugar se libera para una clase de recuperación.",
|
||||||
|
"today": "Hoy · {{time}} h",
|
||||||
|
"notified": "Ya avisaste",
|
||||||
|
"notify": "Avisar ausencia",
|
||||||
|
"doneTitle": "Ausencia avisada",
|
||||||
|
"done": "Tu profesor ya tiene registrado el aviso. Gracias por avisar.",
|
||||||
|
"invalidLink": "Este enlace ya no es válido. Consulta a tu profesor.",
|
||||||
|
"error": "No pudimos registrar el aviso."
|
||||||
|
}
|
||||||
|
}
|
||||||
49
apps/web/src/i18n/locales/es-AR/public.json
Normal file
49
apps/web/src/i18n/locales/es-AR/public.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"join": {
|
||||||
|
"badge": "Invitación oficial",
|
||||||
|
"teacher": "Profesor: <strong>{{name}}</strong>",
|
||||||
|
"capacity": "Cupo {{count}}",
|
||||||
|
"notice": "Al completar el formulario enviás una solicitud de preinscripción. El profesor va a revisar tus datos y te va a confirmar el lugar.",
|
||||||
|
"invalidTitle": "Enlace no válido o vencido",
|
||||||
|
"invalidDescription": "No pudimos encontrar este grupo. Consultá con tu profesor para pedirle un enlace nuevo.",
|
||||||
|
"formTitle": "Completá tus datos",
|
||||||
|
"formDescription": "Ingresá tus datos para anotarte en este grupo.",
|
||||||
|
"firstName": "Nombre",
|
||||||
|
"firstNamePlaceholder": "Ej.: Sofía",
|
||||||
|
"lastName": "Apellido",
|
||||||
|
"lastNamePlaceholder": "Ej.: Fernández",
|
||||||
|
"phone": "Teléfono / WhatsApp",
|
||||||
|
"phonePlaceholder": "Ej.: +54 9 11 2345-6789",
|
||||||
|
"phoneHint": "El profesor se va a comunicar con vos por WhatsApp a este número.",
|
||||||
|
"email": "Email (opcional)",
|
||||||
|
"emailPlaceholder": "alumno@ejemplo.com",
|
||||||
|
"submit": "Enviar solicitud",
|
||||||
|
"loading": "Cargando información del grupo...",
|
||||||
|
"sentBadge": "Preinscripción",
|
||||||
|
"sentTitle": "Solicitud enviada",
|
||||||
|
"sentMessage": "Recibimos tu solicitud de preinscripción.",
|
||||||
|
"sentFooter": "El profesor va a revisar tu solicitud para el grupo <strong>{{group}}</strong> y se va a comunicar con vos por WhatsApp para confirmarte el lugar.",
|
||||||
|
"alreadyRegistered": "Ya estás anotado en este grupo con ese número de teléfono. El profesor ya tiene tus datos.",
|
||||||
|
"alreadyPending": "Ya enviaste una solicitud para este grupo y está pendiente de revisión. Pronto vas a tener novedades.",
|
||||||
|
"alreadyApproved": "Tu inscripción para este grupo ya fue aprobada.",
|
||||||
|
"error": "No pudimos procesar la inscripción.",
|
||||||
|
"required": "Completá los campos obligatorios (nombre, apellido y teléfono)."
|
||||||
|
},
|
||||||
|
"absence": {
|
||||||
|
"loading": "Cargando tus clases...",
|
||||||
|
"invalidTitle": "Enlace no válido",
|
||||||
|
"invalidDescription": "No pudimos identificarte con este enlace. Consultá con tu profesor para pedirle uno nuevo.",
|
||||||
|
"badge": "Aviso de ausencia",
|
||||||
|
"greeting": "Hola, {{name}}",
|
||||||
|
"group": "Grupo: <strong>{{group}}</strong>",
|
||||||
|
"noClasses": "No tenés clases programadas para hoy. Si necesitás avisar de todas formas, contactá a tu profesor.",
|
||||||
|
"hint": "Si avisás con anticipación, tu cupo se libera para una clase de recuperación.",
|
||||||
|
"today": "Hoy · {{time}} hs",
|
||||||
|
"notified": "Ya avisaste",
|
||||||
|
"notify": "Avisar ausencia",
|
||||||
|
"doneTitle": "Ausencia avisada",
|
||||||
|
"done": "Tu profesor ya tiene registrado el aviso. Gracias por avisar.",
|
||||||
|
"invalidLink": "Este enlace ya no es válido. Consultá a tu profesor.",
|
||||||
|
"error": "No pudimos registrar el aviso."
|
||||||
|
}
|
||||||
|
}
|
||||||
49
apps/web/src/i18n/locales/pt-BR/public.json
Normal file
49
apps/web/src/i18n/locales/pt-BR/public.json
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"join": {
|
||||||
|
"badge": "Convite oficial",
|
||||||
|
"teacher": "Professor: <strong>{{name}}</strong>",
|
||||||
|
"capacity": "{{count}} vagas",
|
||||||
|
"notice": "Ao preencher o formulário você envia um pedido de pré-inscrição. O professor vai revisar seus dados e confirmar sua vaga.",
|
||||||
|
"invalidTitle": "Link inválido ou expirado",
|
||||||
|
"invalidDescription": "Não encontramos este grupo. Fale com seu professor para pedir um novo link.",
|
||||||
|
"formTitle": "Preencha seus dados",
|
||||||
|
"formDescription": "Informe seus dados para se inscrever neste grupo.",
|
||||||
|
"firstName": "Nome",
|
||||||
|
"firstNamePlaceholder": "Ex.: Sofia",
|
||||||
|
"lastName": "Sobrenome",
|
||||||
|
"lastNamePlaceholder": "Ex.: Ferreira",
|
||||||
|
"phone": "Telefone / WhatsApp",
|
||||||
|
"phonePlaceholder": "Ex.: +55 11 91234-5678",
|
||||||
|
"phoneHint": "O professor vai falar com você pelo WhatsApp neste número.",
|
||||||
|
"email": "E-mail (opcional)",
|
||||||
|
"emailPlaceholder": "aluno@exemplo.com",
|
||||||
|
"submit": "Enviar pedido",
|
||||||
|
"loading": "Carregando informações do grupo...",
|
||||||
|
"sentBadge": "Pré-inscrição",
|
||||||
|
"sentTitle": "Pedido enviado",
|
||||||
|
"sentMessage": "Recebemos seu pedido de pré-inscrição.",
|
||||||
|
"sentFooter": "O professor vai revisar seu pedido para o grupo <strong>{{group}}</strong> e vai falar com você pelo WhatsApp para confirmar a vaga.",
|
||||||
|
"alreadyRegistered": "Você já está inscrito neste grupo com esse telefone. O professor já tem seus dados.",
|
||||||
|
"alreadyPending": "Você já enviou um pedido para este grupo e ele está em análise. Em breve você terá novidades.",
|
||||||
|
"alreadyApproved": "Sua inscrição neste grupo já foi aprovada.",
|
||||||
|
"error": "Não conseguimos processar a inscrição.",
|
||||||
|
"required": "Preencha os campos obrigatórios (nome, sobrenome e telefone)."
|
||||||
|
},
|
||||||
|
"absence": {
|
||||||
|
"loading": "Carregando suas aulas...",
|
||||||
|
"invalidTitle": "Link inválido",
|
||||||
|
"invalidDescription": "Não conseguimos identificar você com este link. Fale com seu professor para pedir um novo.",
|
||||||
|
"badge": "Aviso de falta",
|
||||||
|
"greeting": "Olá, {{name}}",
|
||||||
|
"group": "Grupo: <strong>{{group}}</strong>",
|
||||||
|
"noClasses": "Você não tem aulas marcadas para hoje. Se precisar avisar mesmo assim, fale com seu professor.",
|
||||||
|
"hint": "Se você avisar com antecedência, sua vaga fica livre para uma aula de reposição.",
|
||||||
|
"today": "Hoje · {{time}}",
|
||||||
|
"notified": "Você já avisou",
|
||||||
|
"notify": "Avisar falta",
|
||||||
|
"doneTitle": "Falta avisada",
|
||||||
|
"done": "Seu professor já registrou o aviso. Obrigado por avisar.",
|
||||||
|
"invalidLink": "Este link não é mais válido. Fale com seu professor.",
|
||||||
|
"error": "Não conseguimos registrar o aviso."
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user