feat: soporte multi idioma en la web (infraestructura)
i18next + react-i18next con es-AR (fuente), es-419, pt-BR y en; el idioma sale del dispositivo (fallback a inglés) y se puede cambiar en Ajustes. La elección se guarda en localStorage y, para el profe, en users.locale. Las validaciones de shared pasan a claves y los errores de la API se traducen por code (con params para límites de plan y cupo). Migrados: layout, Ajustes, auth, PWA y lib/format. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import type { AttendeePaymentSummary } from '@gruperly/shared'
|
||||
import { UpdateAttendeeSchema } from '@gruperly/shared'
|
||||
import { validationMessage } from '../../i18n/validation'
|
||||
|
||||
export function contactEmailError(email: string): string | null {
|
||||
const result = UpdateAttendeeSchema.safeParse({ email })
|
||||
if (result.success) return null
|
||||
return result.error.issues[0]?.message ?? 'Ingresá un email válido'
|
||||
return validationMessage(result.error.issues[0]?.message ?? 'email.invalid') ?? null
|
||||
}
|
||||
|
||||
export type PaymentPresentation = {
|
||||
|
||||
@@ -5,11 +5,13 @@ import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Link, useSearch } from '@tanstack/react-router'
|
||||
import { Loader2, MailCheck } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||
import { errorMessage } from '../../i18n'
|
||||
import { AuthShell } from './AuthShell'
|
||||
|
||||
const schema = z.object({
|
||||
email: z.string().email('Ingresá un email válido'),
|
||||
email: z.string().email('email.invalid'),
|
||||
})
|
||||
|
||||
type FormValues = z.infer<typeof schema>
|
||||
@@ -17,6 +19,7 @@ type FormValues = z.infer<typeof schema>
|
||||
export function ForgotPasswordPage() {
|
||||
const { email: initialEmail } = useSearch({ strict: false }) as { email?: string }
|
||||
const [sentTo, setSentTo] = useState<string | null>(null)
|
||||
const { t } = useTranslation('auth')
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
@@ -34,7 +37,7 @@ export function ForgotPasswordPage() {
|
||||
redirectTo: `${window.location.origin}/reset-password`,
|
||||
})
|
||||
if (error) {
|
||||
setError('root', { message: error.message ?? 'No se pudo enviar el email' })
|
||||
setError('root', { message: errorMessage(error, t('forgot.error')) })
|
||||
return
|
||||
}
|
||||
setSentTo(email)
|
||||
@@ -42,15 +45,19 @@ export function ForgotPasswordPage() {
|
||||
|
||||
if (sentTo) {
|
||||
return (
|
||||
<AuthShell title="Revisá tu email">
|
||||
<AuthShell title={t('forgot.sentTitle')}>
|
||||
<div className="flex flex-col items-center gap-4 py-2 text-center">
|
||||
<MailCheck className="size-10 text-success" />
|
||||
<p className="text-sm text-foreground/60">
|
||||
Si hay una cuenta con <span className="font-medium text-primary">{sentTo}</span>, te
|
||||
enviamos un enlace para elegir una nueva contraseña. Vence en 1 hora.
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey="forgot.sent"
|
||||
values={{ email: sentTo }}
|
||||
components={{ strong: <span className="font-medium text-primary" /> }}
|
||||
/>
|
||||
</p>
|
||||
<Link to="/login" className="text-sm font-medium text-accent hover:underline">
|
||||
Volver a iniciar sesión
|
||||
{t('backToLogin')}
|
||||
</Link>
|
||||
</div>
|
||||
</AuthShell>
|
||||
@@ -59,34 +66,34 @@ export function ForgotPasswordPage() {
|
||||
|
||||
return (
|
||||
<AuthShell
|
||||
title="Recuperar contraseña"
|
||||
subtitle="Te enviamos un enlace para elegir una nueva"
|
||||
title={t('forgot.title')}
|
||||
subtitle={t('forgot.subtitle')}
|
||||
>
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Label htmlFor="email">{t('email')}</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
autoFocus
|
||||
placeholder="vos@ejemplo.com"
|
||||
placeholder={t('emailPlaceholder')}
|
||||
invalid={!!errors.email}
|
||||
{...register('email')}
|
||||
/>
|
||||
{errors.email ? <p className="mt-1 text-sm text-danger">{errors.email.message}</p> : null}
|
||||
<FieldError message={errors.email?.message} />
|
||||
</div>
|
||||
|
||||
{errors.root ? <p className="text-sm text-danger">{errors.root.message}</p> : null}
|
||||
|
||||
<Button type="submit" variant="primary" className="w-full" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||
{isSubmitting ? 'Enviando…' : 'Enviar enlace'}
|
||||
{isSubmitting ? t('forgot.submitting') : t('forgot.submit')}
|
||||
</Button>
|
||||
|
||||
<p className="text-center text-sm text-foreground/60">
|
||||
<Link to="/login" className="font-medium text-accent hover:underline">
|
||||
Volver a iniciar sesión
|
||||
{t('backToLogin')}
|
||||
</Link>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
@@ -4,18 +4,21 @@ import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Link, useNavigate, useSearch } from '@tanstack/react-router'
|
||||
import { Fingerprint, Loader2 } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||
import { errorMessage } from '../../i18n'
|
||||
import { AuthShell } from './AuthShell'
|
||||
|
||||
const schema = z.object({
|
||||
email: z.string().email('Ingresá un email válido'),
|
||||
password: z.string().min(8, 'La contraseña debe tener al menos 8 caracteres'),
|
||||
email: z.string().email('email.invalid'),
|
||||
password: z.string().min(8, 'password.min'),
|
||||
})
|
||||
|
||||
type FormValues = z.infer<typeof schema>
|
||||
|
||||
export function LoginPage() {
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation('auth')
|
||||
const { reset } = useSearch({ strict: false }) as { reset?: 'ok' }
|
||||
const {
|
||||
register,
|
||||
@@ -28,7 +31,7 @@ export function LoginPage() {
|
||||
const onSubmit = handleSubmit(async ({ email, password }) => {
|
||||
const { error } = await authClient.signIn.email({ email, password })
|
||||
if (error) {
|
||||
setError('root', { message: error.message ?? 'No se pudo iniciar sesión' })
|
||||
setError('root', { message: errorMessage(error, t('login.error')) })
|
||||
return
|
||||
}
|
||||
navigate({ to: '/' })
|
||||
@@ -41,37 +44,37 @@ export function LoginPage() {
|
||||
const handlePasskey = async () => {
|
||||
const { error, data } = await authClient.signIn.passkey()
|
||||
if (error) {
|
||||
setError('root', { message: error.message ?? 'No se pudo autenticar con passkey' })
|
||||
setError('root', { message: errorMessage(error, t('login.passkeyError')) })
|
||||
return
|
||||
}
|
||||
if (data) navigate({ to: '/' })
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthShell title="Iniciar sesión" subtitle="Accedé a tus cobros grupales">
|
||||
<AuthShell title={t('login.title')} subtitle={t('login.subtitle')}>
|
||||
<div className="space-y-4">
|
||||
{reset === 'ok' ? (
|
||||
<p className="rounded-xl bg-success-soft px-4 py-3 text-sm text-success">
|
||||
Tu contraseña se actualizó. Ingresá con la nueva.
|
||||
{t('login.resetOk')}
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Label htmlFor="email">{t('email')}</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
placeholder="vos@ejemplo.com"
|
||||
placeholder={t('emailPlaceholder')}
|
||||
invalid={!!errors.email}
|
||||
{...register('email')}
|
||||
/>
|
||||
{errors.email ? <p className="mt-1 text-sm text-danger">{errors.email.message}</p> : null}
|
||||
<FieldError message={errors.email?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="password">Contraseña</Label>
|
||||
<Label htmlFor="password">{t('password')}</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
@@ -80,16 +83,14 @@ export function LoginPage() {
|
||||
invalid={!!errors.password}
|
||||
{...register('password')}
|
||||
/>
|
||||
{errors.password ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.password.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.password?.message} />
|
||||
<div className="mt-1 text-right">
|
||||
<Link
|
||||
to="/forgot-password"
|
||||
search={{ email: watch('email') || undefined }}
|
||||
className="text-sm text-accent hover:underline"
|
||||
>
|
||||
¿Olvidaste tu contraseña?
|
||||
{t('login.forgot')}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
@@ -98,30 +99,30 @@ export function LoginPage() {
|
||||
|
||||
<Button type="submit" variant="primary" className="w-full" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||
{isSubmitting ? 'Ingresando…' : 'Ingresar'}
|
||||
{isSubmitting ? t('login.submitting') : t('login.submit')}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="h-px flex-1 bg-border" />
|
||||
<span className="text-xs uppercase tracking-wide text-foreground/40">o</span>
|
||||
<span className="text-xs uppercase tracking-wide text-foreground/40">{t('or')}</span>
|
||||
<div className="h-px flex-1 bg-border" />
|
||||
</div>
|
||||
|
||||
<div className="grid gap-2">
|
||||
<Button variant="outline" className="w-full" onClick={handleGoogle}>
|
||||
Continuar con Google
|
||||
{t('continueWithGoogle')}
|
||||
</Button>
|
||||
<Button variant="outline" className="w-full" onClick={handlePasskey}>
|
||||
<Fingerprint className="size-4" />
|
||||
Entrar con passkey
|
||||
{t('login.passkey')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<p className="text-center text-sm text-foreground/60">
|
||||
¿No tenés cuenta?{' '}
|
||||
{t('login.noAccount')}{' '}
|
||||
<Link to="/signup" className="font-medium text-accent hover:underline">
|
||||
Registrate
|
||||
{t('login.signUp')}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -5,16 +5,18 @@ import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Link, useNavigate, useSearch } from '@tanstack/react-router'
|
||||
import { Loader2, MailWarning } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||
import { errorMessage } from '../../i18n'
|
||||
import { AuthShell } from './AuthShell'
|
||||
|
||||
const schema = z
|
||||
.object({
|
||||
newPassword: z.string().min(8, 'La contraseña debe tener al menos 8 caracteres'),
|
||||
newPassword: z.string().min(8, 'password.min'),
|
||||
confirmPassword: z.string(),
|
||||
})
|
||||
.refine((v) => v.newPassword === v.confirmPassword, {
|
||||
message: 'Las contraseñas no coinciden',
|
||||
message: 'password.mismatch',
|
||||
path: ['confirmPassword'],
|
||||
})
|
||||
|
||||
@@ -23,6 +25,7 @@ type FormValues = z.infer<typeof schema>
|
||||
export function ResetPasswordPage() {
|
||||
const { token, error } = useSearch({ strict: false }) as { token?: string; error?: string }
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation('auth')
|
||||
const [invalidLink, setInvalidLink] = useState(!token || !!error)
|
||||
const {
|
||||
register,
|
||||
@@ -39,7 +42,7 @@ export function ResetPasswordPage() {
|
||||
setInvalidLink(true)
|
||||
return
|
||||
}
|
||||
setError('root', { message: error.message ?? 'No se pudo cambiar la contraseña' })
|
||||
setError('root', { message: errorMessage(error, t('reset.error')) })
|
||||
return
|
||||
}
|
||||
navigate({ to: '/login', search: { reset: 'ok' } })
|
||||
@@ -47,14 +50,14 @@ export function ResetPasswordPage() {
|
||||
|
||||
if (invalidLink) {
|
||||
return (
|
||||
<AuthShell title="Vínculo inválido">
|
||||
<AuthShell title={t('reset.invalidTitle')}>
|
||||
<div className="flex flex-col items-center gap-4 py-2 text-center">
|
||||
<MailWarning className="size-10 text-warning" />
|
||||
<p className="text-sm text-foreground/60">
|
||||
El enlace para restablecer la contraseña no es válido o venció.
|
||||
{t('reset.invalid')}
|
||||
</p>
|
||||
<Link to="/forgot-password" className="text-sm font-medium text-accent hover:underline">
|
||||
Pedir un enlace nuevo
|
||||
{t('reset.requestNew')}
|
||||
</Link>
|
||||
</div>
|
||||
</AuthShell>
|
||||
@@ -62,10 +65,10 @@ export function ResetPasswordPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthShell title="Nueva contraseña" subtitle="Elegí una contraseña para tu cuenta">
|
||||
<AuthShell title={t('reset.title')} subtitle={t('reset.subtitle')}>
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="newPassword">Nueva contraseña</Label>
|
||||
<Label htmlFor="newPassword">{t('reset.newPassword')}</Label>
|
||||
<Input
|
||||
id="newPassword"
|
||||
type="password"
|
||||
@@ -75,13 +78,11 @@ export function ResetPasswordPage() {
|
||||
invalid={!!errors.newPassword}
|
||||
{...register('newPassword')}
|
||||
/>
|
||||
{errors.newPassword ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.newPassword.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.newPassword?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="confirmPassword">Repetir contraseña</Label>
|
||||
<Label htmlFor="confirmPassword">{t('reset.confirmPassword')}</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
@@ -90,16 +91,14 @@ export function ResetPasswordPage() {
|
||||
invalid={!!errors.confirmPassword}
|
||||
{...register('confirmPassword')}
|
||||
/>
|
||||
{errors.confirmPassword ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.confirmPassword.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.confirmPassword?.message} />
|
||||
</div>
|
||||
|
||||
{errors.root ? <p className="text-sm text-danger">{errors.root.message}</p> : null}
|
||||
|
||||
<Button type="submit" variant="primary" className="w-full" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||
{isSubmitting ? 'Guardando…' : 'Guardar contraseña'}
|
||||
{isSubmitting ? t('reset.submitting') : t('reset.submit')}
|
||||
</Button>
|
||||
</form>
|
||||
</AuthShell>
|
||||
|
||||
@@ -4,18 +4,20 @@ import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import { Loader2 } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||
import { errorMessage } from '../../i18n'
|
||||
import { AuthShell } from './AuthShell'
|
||||
|
||||
const schema = z
|
||||
.object({
|
||||
name: z.string().min(2, 'Ingresá tu nombre'),
|
||||
email: z.string().email('Ingresá un email válido'),
|
||||
password: z.string().min(8, 'La contraseña debe tener al menos 8 caracteres'),
|
||||
name: z.string().min(2, 'name.enter'),
|
||||
email: z.string().email('email.invalid'),
|
||||
password: z.string().min(8, 'password.min'),
|
||||
confirmPassword: z.string(),
|
||||
})
|
||||
.refine((v) => v.password === v.confirmPassword, {
|
||||
message: 'Las contraseñas no coinciden',
|
||||
message: 'password.mismatch',
|
||||
path: ['confirmPassword'],
|
||||
})
|
||||
|
||||
@@ -23,6 +25,7 @@ type FormValues = z.infer<typeof schema>
|
||||
|
||||
export function SignupPage() {
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation('auth')
|
||||
const {
|
||||
register,
|
||||
handleSubmit,
|
||||
@@ -40,7 +43,7 @@ export function SignupPage() {
|
||||
},
|
||||
)
|
||||
if (error) {
|
||||
setError('root', { message: error.message ?? 'No se pudo registrar' })
|
||||
setError('root', { message: errorMessage(error, t('signup.error')) })
|
||||
return
|
||||
}
|
||||
if (data?.token) {
|
||||
@@ -55,51 +58,49 @@ export function SignupPage() {
|
||||
}
|
||||
|
||||
return (
|
||||
<AuthShell title="Crear cuenta" subtitle="Empezá a cobrar en grupo en minutos">
|
||||
<AuthShell title={t('signup.title')} subtitle={t('signup.subtitle')}>
|
||||
<div className="space-y-4">
|
||||
<form onSubmit={onSubmit} className="space-y-4">
|
||||
<div>
|
||||
<Label htmlFor="name">Nombre</Label>
|
||||
<Label htmlFor="name">{t('signup.name')}</Label>
|
||||
<Input
|
||||
id="name"
|
||||
autoComplete="name"
|
||||
placeholder="Nombre completo"
|
||||
placeholder={t('signup.namePlaceholder')}
|
||||
invalid={!!errors.name}
|
||||
{...register('name')}
|
||||
/>
|
||||
{errors.name ? <p className="mt-1 text-sm text-danger">{errors.name.message}</p> : null}
|
||||
<FieldError message={errors.name?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="email">Email</Label>
|
||||
<Label htmlFor="email">{t('email')}</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
placeholder="vos@ejemplo.com"
|
||||
placeholder={t('emailPlaceholder')}
|
||||
invalid={!!errors.email}
|
||||
{...register('email')}
|
||||
/>
|
||||
{errors.email ? <p className="mt-1 text-sm text-danger">{errors.email.message}</p> : null}
|
||||
<FieldError message={errors.email?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="password">Contraseña</Label>
|
||||
<Label htmlFor="password">{t('password')}</Label>
|
||||
<Input
|
||||
id="password"
|
||||
type="password"
|
||||
autoComplete="new-password"
|
||||
placeholder="Mínimo 8 caracteres"
|
||||
placeholder={t('signup.passwordPlaceholder')}
|
||||
invalid={!!errors.password}
|
||||
{...register('password')}
|
||||
/>
|
||||
{errors.password ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.password.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.password?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Label htmlFor="confirmPassword">Repetí la contraseña</Label>
|
||||
<Label htmlFor="confirmPassword">{t('signup.confirmPassword')}</Label>
|
||||
<Input
|
||||
id="confirmPassword"
|
||||
type="password"
|
||||
@@ -108,33 +109,31 @@ export function SignupPage() {
|
||||
invalid={!!errors.confirmPassword}
|
||||
{...register('confirmPassword')}
|
||||
/>
|
||||
{errors.confirmPassword ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.confirmPassword.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.confirmPassword?.message} />
|
||||
</div>
|
||||
|
||||
{errors.root ? <p className="text-sm text-danger">{errors.root.message}</p> : null}
|
||||
|
||||
<Button type="submit" variant="primary" className="w-full" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||
{isSubmitting ? 'Creando…' : 'Crear cuenta'}
|
||||
{isSubmitting ? t('signup.submitting') : t('signup.submit')}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="h-px flex-1 bg-border" />
|
||||
<span className="text-xs uppercase tracking-wide text-foreground/40">o</span>
|
||||
<span className="text-xs uppercase tracking-wide text-foreground/40">{t('or')}</span>
|
||||
<div className="h-px flex-1 bg-border" />
|
||||
</div>
|
||||
|
||||
<Button variant="outline" className="w-full" onClick={handleGoogle}>
|
||||
Continuar con Google
|
||||
{t('continueWithGoogle')}
|
||||
</Button>
|
||||
|
||||
<p className="text-center text-sm text-foreground/60">
|
||||
¿Ya tenés cuenta?{' '}
|
||||
{t('signup.hasAccount')}{' '}
|
||||
<Link to="/login" className="font-medium text-accent hover:underline">
|
||||
Iniciá sesión
|
||||
{t('signup.signIn')}
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Link, useNavigate, useSearch } from '@tanstack/react-router'
|
||||
import { MailCheck, MailWarning, Loader2 } from 'lucide-react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { AuthShell } from './AuthShell'
|
||||
|
||||
@@ -14,6 +15,7 @@ type Status = 'idle' | 'verifying' | 'success' | 'error'
|
||||
export function VerifyEmailPage() {
|
||||
const { token, email } = useSearch({ strict: false }) as SearchParams
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation('auth')
|
||||
const [status, setStatus] = useState<Status>(token ? 'verifying' : 'idle')
|
||||
|
||||
useEffect(() => {
|
||||
@@ -40,10 +42,10 @@ export function VerifyEmailPage() {
|
||||
|
||||
const title =
|
||||
status === 'success'
|
||||
? 'Email verificado'
|
||||
? t('verify.successTitle')
|
||||
: status === 'error'
|
||||
? 'Vínculo inválido'
|
||||
: 'Verificá tu email'
|
||||
? t('verify.errorTitle')
|
||||
: t('verify.title')
|
||||
|
||||
return (
|
||||
<AuthShell title={title}>
|
||||
@@ -58,16 +60,20 @@ export function VerifyEmailPage() {
|
||||
|
||||
{status === 'success' ? (
|
||||
<p className="text-sm text-foreground/60">
|
||||
Tu cuenta quedó verificada. Te estamos llevando a Gruperly…
|
||||
{t('verify.success')}
|
||||
</p>
|
||||
) : status === 'error' ? (
|
||||
<p className="text-sm text-foreground/60">
|
||||
El vínculo de verificación no es válido o expiró.
|
||||
{t('verify.error')}
|
||||
</p>
|
||||
) : (
|
||||
<p className="text-sm text-foreground/60">
|
||||
Te enviamos un correo a <span className="font-medium text-primary">{email}</span> para
|
||||
confirmar tu cuenta.
|
||||
<Trans
|
||||
t={t}
|
||||
i18nKey="verify.sent"
|
||||
values={{ email }}
|
||||
components={{ strong: <span className="font-medium text-primary" /> }}
|
||||
/>
|
||||
</p>
|
||||
)}
|
||||
|
||||
@@ -76,13 +82,13 @@ export function VerifyEmailPage() {
|
||||
to="/"
|
||||
className="w-full rounded-xl bg-accent py-2 text-center text-sm font-medium text-on-accent hover:bg-accent-strong"
|
||||
>
|
||||
Ir a Gruperly
|
||||
{t('verify.goToApp')}
|
||||
</Link>
|
||||
) : null}
|
||||
|
||||
{status === 'error' ? (
|
||||
<Link to="/login" className="text-sm font-medium text-accent hover:underline">
|
||||
Intentar iniciar sesión
|
||||
{t('verify.tryLogin')}
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -5,7 +5,7 @@ import { CreateFirstGroupSchema, DEFAULT_COUNTRY } from '@gruperly/shared'
|
||||
import { ArrowLeft, Check, Loader2 } from 'lucide-react'
|
||||
import { sortWeekDays } from '../../lib/format'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||
import { BILLING_TYPES, WEEK_DAY_CHIPS } from '../onboarding/constants'
|
||||
|
||||
type GroupFormProps = {
|
||||
@@ -84,7 +84,7 @@ export function GroupForm({
|
||||
invalid={!!errors.name}
|
||||
{...register('name')}
|
||||
/>
|
||||
{errors.name ? <p className="mt-1 text-sm text-danger">{errors.name.message}</p> : null}
|
||||
<FieldError message={errors.name?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -110,7 +110,7 @@ export function GroupForm({
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
{errors.days ? <p className="mt-1 text-sm text-danger">{errors.days.message}</p> : null}
|
||||
<FieldError message={errors.days?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -121,7 +121,7 @@ export function GroupForm({
|
||||
invalid={!!errors.time}
|
||||
{...register('time')}
|
||||
/>
|
||||
{errors.time ? <p className="mt-1 text-sm text-danger">{errors.time.message}</p> : null}
|
||||
<FieldError message={errors.time?.message} />
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-2 gap-3">
|
||||
@@ -136,9 +136,7 @@ export function GroupForm({
|
||||
invalid={!!errors.capacity}
|
||||
{...register('capacity', { valueAsNumber: true })}
|
||||
/>
|
||||
{errors.capacity ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.capacity.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.capacity?.message} />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
@@ -159,9 +157,7 @@ export function GroupForm({
|
||||
{...register('price', { valueAsNumber: true })}
|
||||
/>
|
||||
</div>
|
||||
{errors.price ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.price.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.price?.message} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -213,9 +209,7 @@ export function GroupForm({
|
||||
<p className="mt-1 text-xs text-foreground/50">
|
||||
Los cobros vencerán el día {isFinite(dueDay) && dueDay ? dueDay : '1'} de cada mes.
|
||||
</p>
|
||||
{errors.dueDay ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.dueDay.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.dueDay?.message} />
|
||||
</div>
|
||||
|
||||
{errorMessage ? (
|
||||
|
||||
@@ -2,7 +2,7 @@ import { CalendarClock, CircleDollarSign, Users } from 'lucide-react'
|
||||
import {
|
||||
formatBillingMeta,
|
||||
formatPrice,
|
||||
WEEK_DAY_FULL_LABELS,
|
||||
weekDayLabel,
|
||||
sortWeekDays,
|
||||
} from '../../../lib/format'
|
||||
import { cn } from '../../../lib/utils'
|
||||
@@ -19,7 +19,7 @@ export function GroupInfoCard() {
|
||||
const { group, attendeesTotal, attendeesPending, waitlistTotal } = useGroupDetail()
|
||||
if (!group) return null
|
||||
|
||||
const daysLabel = sortWeekDays(group.days ?? []).map((day) => WEEK_DAY_FULL_LABELS[day]).join(', ')
|
||||
const daysLabel = sortWeekDays(group.days ?? []).map(weekDayLabel).join(', ')
|
||||
const capacity = group.capacity
|
||||
const isFull = capacity != null && attendeesTotal >= capacity
|
||||
const freeSpots = capacity != null ? Math.max(capacity - attendeesTotal, 0) : null
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { UpcomingPaymentDto } from '@gruperly/shared'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { formatPrice, formatRelativeDateTime, PAYMENT_STATUS_LABELS } from '../../lib/format'
|
||||
import { formatPrice, formatRelativeDateTime, paymentStatusLabel } from '../../lib/format'
|
||||
import { PAYMENT_BADGE_VARIANT } from './constants'
|
||||
|
||||
export function UpcomingPaymentRow({ payment }: { payment: UpcomingPaymentDto }) {
|
||||
@@ -15,7 +15,7 @@ export function UpcomingPaymentRow({ payment }: { payment: UpcomingPaymentDto })
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<span className="text-sm font-semibold text-primary">{formatPrice(payment.amount)}</span>
|
||||
<Badge variant={PAYMENT_BADGE_VARIANT[payment.status]}>
|
||||
{PAYMENT_STATUS_LABELS[payment.status]}
|
||||
{paymentStatusLabel(payment.status)}
|
||||
</Badge>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CalendarClock, GraduationCap, Users } from 'lucide-react'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { BILLING_LABELS, formatPrice, formatSchedule } from '../../lib/format'
|
||||
import { billingTypeLabel, formatPrice, formatSchedule } from '../../lib/format'
|
||||
import { useJoinGroup } from './JoinGroupProvider'
|
||||
|
||||
export function GroupInviteSummary() {
|
||||
@@ -32,7 +32,7 @@ export function GroupInviteSummary() {
|
||||
{group.price != null ? (
|
||||
<div className="inline-flex items-center gap-1.5 rounded-lg bg-primary-soft px-2.5 py-1 text-sm font-medium text-foreground/80">
|
||||
<span>{formatPrice(group.price)}</span>
|
||||
{group.billingType ? <span>· {BILLING_LABELS[group.billingType]}</span> : ''}
|
||||
{group.billingType ? <span>· {billingTypeLabel(group.billingType)}</span> : ''}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useAuth } from '../../context/AuthProvider'
|
||||
import { PLAN_NAMES } from '../billing'
|
||||
import { MP_PROVIDER_NAME, useMpStatus } from '../mp'
|
||||
import { useWhatsappStatus } from '../whatsapp'
|
||||
import { BILLING_LABELS, formatPrice, formatSchedule } from './constants'
|
||||
import { billingTypeLabel, formatPrice, formatSchedule } from './constants'
|
||||
import { useOnboarding } from './OnboardingProvider'
|
||||
|
||||
type ConfirmationStepProps = {
|
||||
@@ -59,7 +59,7 @@ export function ConfirmationStep({ group }: ConfirmationStepProps) {
|
||||
<dt className="text-foreground/60">Precio</dt>
|
||||
<dd className="font-semibold text-primary">
|
||||
{formatPrice(group.price)}
|
||||
{group.billingType ? ` · ${BILLING_LABELS[group.billingType]}` : ''}
|
||||
{group.billingType ? ` · ${billingTypeLabel(group.billingType)}` : ''}
|
||||
</dd>
|
||||
</div>
|
||||
<div className="flex items-center justify-between py-2.5">
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BillingType, WeekDay } from '@gruperly/shared'
|
||||
|
||||
export { BILLING_LABELS, formatPrice, formatSchedule, WEEK_DAY_FULL_LABELS } from '../../lib/format'
|
||||
export { billingTypeLabel, formatPrice, formatSchedule, weekDayLabel } from '../../lib/format'
|
||||
|
||||
export const WEEK_DAYS: readonly WeekDay[] = [
|
||||
'MONDAY',
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Check, Copy, Link2, Loader2, RefreshCw } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { Badge, Button } from '../../components/ui'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { formatPrice, PAYMENT_STATUS_LABELS } from '../../lib/format'
|
||||
import { formatPrice, paymentStatusLabel } from '../../lib/format'
|
||||
import { paymentDateLabel, paymentPeriodLabel, PAYMENT_STATUS_BADGE } from './copy'
|
||||
|
||||
type PaymentRowProps = {
|
||||
@@ -49,7 +49,7 @@ export function PaymentRow({ payment, showGroup, isRenewing, onRenew }: PaymentR
|
||||
<p className="mt-1 text-xs text-foreground/50">{paymentDateLabel(payment)}</p>
|
||||
</div>
|
||||
<Badge variant={PAYMENT_STATUS_BADGE[payment.status]}>
|
||||
{PAYMENT_STATUS_LABELS[payment.status]}
|
||||
{paymentStatusLabel(payment.status)}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Download, X } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button } from '../../components/ui'
|
||||
|
||||
type InstallBannerProps = {
|
||||
@@ -7,6 +8,7 @@ type InstallBannerProps = {
|
||||
}
|
||||
|
||||
export function InstallBanner({ onInstall, onDismiss }: InstallBannerProps) {
|
||||
const { t } = useTranslation('pwa')
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-x-0 z-30 px-4 lg:left-auto lg:right-6 lg:w-96 lg:px-0
|
||||
@@ -15,17 +17,17 @@ export function InstallBanner({ onInstall, onDismiss }: InstallBannerProps) {
|
||||
>
|
||||
<div className="flex items-start gap-3 rounded-xl border border-border bg-surface p-4 shadow-lg">
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-semibold text-primary">Instalá Gruperly</p>
|
||||
<p className="text-sm font-semibold text-primary">{t('banner.title')}</p>
|
||||
<p className="mt-0.5 text-xs leading-relaxed text-foreground/70">
|
||||
Abrila directo desde tu pantalla de inicio, sin barra de navegador.
|
||||
{t('banner.description')}
|
||||
</p>
|
||||
<div className="mt-3 flex items-center gap-2">
|
||||
<Button variant="primary" size="sm" onClick={onInstall}>
|
||||
<Download className="size-4" strokeWidth={2} />
|
||||
Instalar app
|
||||
{t('banner.install')}
|
||||
</Button>
|
||||
<Button variant="ghost" size="sm" onClick={onDismiss}>
|
||||
Ahora no
|
||||
{t('banner.later')}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -33,7 +35,7 @@ export function InstallBanner({ onInstall, onDismiss }: InstallBannerProps) {
|
||||
<button
|
||||
type="button"
|
||||
onClick={onDismiss}
|
||||
aria-label="Cerrar aviso de instalación"
|
||||
aria-label={t('banner.close')}
|
||||
className="shrink-0 rounded-lg p-1 text-foreground/40 transition-colors hover:bg-primary-soft hover:text-foreground"
|
||||
>
|
||||
<X className="size-4" />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Share, X } from 'lucide-react'
|
||||
import { Trans, useTranslation } from 'react-i18next'
|
||||
|
||||
type IosInstallHintProps = {
|
||||
onDismiss: () => void
|
||||
@@ -10,6 +11,7 @@ type IosInstallHintProps = {
|
||||
* no action button.
|
||||
*/
|
||||
export function IosInstallHint({ onDismiss }: IosInstallHintProps) {
|
||||
const { t } = useTranslation('pwa')
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-x-0 z-30 px-4 lg:left-auto lg:right-6 lg:w-96 lg:px-0
|
||||
@@ -19,18 +21,16 @@ export function IosInstallHint({ onDismiss }: IosInstallHintProps) {
|
||||
<Share className="mt-0.5 size-5 shrink-0 text-accent" strokeWidth={2} />
|
||||
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-semibold text-primary">Instalá Gruperly en el iPhone</p>
|
||||
<p className="text-sm font-semibold text-primary">{t('ios.title')}</p>
|
||||
<p className="mt-0.5 text-xs leading-relaxed text-foreground/70">
|
||||
Tocá <span className="font-medium text-foreground">Compartir</span> y elegí{' '}
|
||||
<span className="font-medium text-foreground">Agregar a pantalla de inicio</span> para
|
||||
abrirla como app.
|
||||
<Trans t={t} i18nKey="ios.description" components={{ strong: <span className="font-medium text-foreground" /> }} />
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
onClick={onDismiss}
|
||||
aria-label="Cerrar aviso de instalación"
|
||||
aria-label={t('banner.close')}
|
||||
className="shrink-0 rounded-lg p-1 text-foreground/40 transition-colors hover:bg-primary-soft hover:text-foreground"
|
||||
>
|
||||
<X className="size-4" />
|
||||
|
||||
@@ -11,6 +11,7 @@ import { registerSW } from 'virtual:pwa-register'
|
||||
import { router } from '../../router'
|
||||
import { useAuth } from '../../context/AuthProvider'
|
||||
import { useToast } from '../../components/ui'
|
||||
import { i18n } from '../../i18n/instance'
|
||||
import { InstallPrompt } from './InstallPrompt'
|
||||
|
||||
/** `beforeinstallprompt` is not in lib.dom yet (Chromium >= 108). */
|
||||
@@ -94,7 +95,7 @@ export function PwaProvider({ children }: { children: ReactNode }) {
|
||||
registerSW({
|
||||
immediate: true,
|
||||
onOfflineReady() {
|
||||
success('La app quedó lista para abrirse sin conexión', 'Ya podés usar Gruperly offline.')
|
||||
success(i18n.t('pwa:offlineReady'), i18n.t('pwa:offlineReadyDetail'))
|
||||
},
|
||||
onRegisterError(error) {
|
||||
console.error('No se pudo registrar el service worker', error)
|
||||
@@ -153,14 +154,14 @@ export function PwaProvider({ children }: { children: ReactNode }) {
|
||||
if (outcome === 'accepted') {
|
||||
localStorage.setItem(DISMISSED_KEY, '1')
|
||||
setDismissed(true)
|
||||
success('App instalada', 'Ahora tenés Gruperly en tu pantalla de inicio.')
|
||||
success(i18n.t('pwa:installed'), i18n.t('pwa:installedDetail'))
|
||||
}
|
||||
}, [installEvent, success])
|
||||
|
||||
const dismiss = useCallback(() => {
|
||||
setDismissed(true)
|
||||
localStorage.setItem(DISMISSED_KEY, '1')
|
||||
info('Podés instalarla más adelante desde el menú del navegador.')
|
||||
info(i18n.t('pwa:installLater'))
|
||||
}, [info])
|
||||
|
||||
/**
|
||||
|
||||
@@ -4,7 +4,7 @@ import { z } from 'zod'
|
||||
import { zodResolver } from '@hookform/resolvers/zod'
|
||||
import { Fingerprint, KeyRound, Loader2, Plus } from 'lucide-react'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { Button, Input, Label } from '../../components/ui'
|
||||
import { Button, FieldError, Input, Label } from '../../components/ui'
|
||||
import { PasskeyList } from './PasskeyList'
|
||||
import { changePasswordSchema } from './schema'
|
||||
import type { ChangePasswordValues } from './schema'
|
||||
@@ -81,9 +81,7 @@ export function SecurityPage() {
|
||||
invalid={!!errors.currentPassword}
|
||||
{...register('currentPassword')}
|
||||
/>
|
||||
{errors.currentPassword ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.currentPassword.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.currentPassword?.message} />
|
||||
</div>
|
||||
<div>
|
||||
<Label htmlFor="newPassword">Nueva contraseña</Label>
|
||||
@@ -94,9 +92,7 @@ export function SecurityPage() {
|
||||
invalid={!!errors.newPassword}
|
||||
{...register('newPassword')}
|
||||
/>
|
||||
{errors.newPassword ? (
|
||||
<p className="mt-1 text-sm text-danger">{errors.newPassword.message}</p>
|
||||
) : null}
|
||||
<FieldError message={errors.newPassword?.message} />
|
||||
</div>
|
||||
<Button type="submit" variant="primary" disabled={isSubmitting}>
|
||||
{isSubmitting ? <Loader2 className="size-4 animate-spin" /> : null}
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
import { Check } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useTheme } from '../../context/ThemeProvider'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { THEME_ICONS, THEME_OPTIONS } from './constants'
|
||||
|
||||
export function AppearanceCard() {
|
||||
const { theme, setTheme } = useTheme()
|
||||
const { t } = useTranslation('settings')
|
||||
|
||||
return (
|
||||
<div className="divide-y divide-border rounded-xl border border-border bg-surface">
|
||||
<div className="px-4 py-3">
|
||||
<p className="text-sm font-medium text-primary">Apariencia</p>
|
||||
<p className="text-xs text-foreground/50">Tema claro u oscuro</p>
|
||||
<p className="text-sm font-medium text-primary">{t('appearance.title')}</p>
|
||||
<p className="text-xs text-foreground/50">{t('appearance.description')}</p>
|
||||
</div>
|
||||
{THEME_OPTIONS.map((option) => {
|
||||
const Icon = THEME_ICONS[option.value]
|
||||
@@ -29,9 +31,9 @@ export function AppearanceCard() {
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className={cn('text-sm font-medium', isSelected ? 'text-accent-fg' : 'text-primary')}>
|
||||
{option.label}
|
||||
{t(option.label)}
|
||||
</p>
|
||||
<p className="text-xs text-foreground/50">{option.description}</p>
|
||||
<p className="text-xs text-foreground/50">{t(option.description)}</p>
|
||||
</div>
|
||||
{isSelected ? <Check className="size-4 text-accent-fg" /> : null}
|
||||
</button>
|
||||
|
||||
79
apps/web/src/features/settings/LanguageCard.tsx
Normal file
79
apps/web/src/features/settings/LanguageCard.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import { SUPPORTED_LOCALES } from '@gruperly/shared'
|
||||
import { Check, Languages } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useToast } from '../../components/ui'
|
||||
import { useAuth } from '../../context/AuthProvider'
|
||||
import { useLocale, type LocalePreference } from '../../i18n'
|
||||
import { LOCALE_NAMES } from '../../i18n/locales'
|
||||
import { authClient } from '../../lib/auth-client'
|
||||
import { cn } from '../../lib/utils'
|
||||
|
||||
const OPTIONS: LocalePreference[] = ['system', ...SUPPORTED_LOCALES]
|
||||
|
||||
type LanguageCardProps = {
|
||||
/** Guarda la elección en la cuenta del profe (Better Auth). La app de
|
||||
* alumnos no tiene esa sesión: ahí queda solo en el dispositivo. */
|
||||
syncProfile?: boolean
|
||||
}
|
||||
|
||||
export function LanguageCard({ syncProfile = false }: LanguageCardProps) {
|
||||
const { t } = useTranslation('settings')
|
||||
const { preference, device, setPreference } = useLocale()
|
||||
const { user } = useAuth()
|
||||
const toast = useToast()
|
||||
|
||||
const select = (next: LocalePreference) => {
|
||||
if (next === preference) return
|
||||
// Optimista: el idioma cambia ya; la cuenta se actualiza por detrás.
|
||||
setPreference(next)
|
||||
if (!syncProfile || !user) return
|
||||
void authClient.updateUser({ locale: next === 'system' ? null : next }).then(({ error }) => {
|
||||
if (error) toast.error(t('language.saveError'))
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="divide-y divide-border 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">
|
||||
<Languages className="size-4 text-primary" />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium text-primary">{t('language.title')}</p>
|
||||
<p className="text-xs text-foreground/50">{t('language.description')}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div role="radiogroup" aria-label={t('language.title')}>
|
||||
{OPTIONS.map((option) => {
|
||||
const isSelected = preference === option
|
||||
const isSystem = option === 'system'
|
||||
return (
|
||||
<button
|
||||
key={option}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={isSelected}
|
||||
onClick={() => select(option)}
|
||||
className="flex w-full items-center gap-3 px-4 py-3 text-left transition-colors hover:bg-primary-soft"
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p
|
||||
lang={isSystem ? undefined : option}
|
||||
className={cn('text-sm font-medium', isSelected ? 'text-accent-fg' : 'text-primary')}
|
||||
>
|
||||
{isSystem ? t('language.system') : LOCALE_NAMES[option]}
|
||||
</p>
|
||||
{isSystem ? (
|
||||
<p className="text-xs text-foreground/50">
|
||||
{t('language.systemDescription', { language: LOCALE_NAMES[device] })}
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
{isSelected ? <Check className="size-4 text-accent-fg" /> : null}
|
||||
</button>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import { ChevronRight, Fingerprint } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button } from '../../components/ui'
|
||||
import { signOut } from '../../lib/auth-client'
|
||||
import { PlanSettingsCard } from '../billing'
|
||||
import { MpStatusCard } from '../mp'
|
||||
import { WhatsappStatusCard } from '../whatsapp'
|
||||
import { AppearanceCard } from './AppearanceCard'
|
||||
import { LanguageCard } from './LanguageCard'
|
||||
import { TransferDetailsSettingsCard } from './TransferDetailsSettingsCard'
|
||||
import { useCallbackFeedbackToast } from './useCallbackFeedbackToast'
|
||||
|
||||
export function SettingsView() {
|
||||
useCallbackFeedbackToast()
|
||||
const { t } = useTranslation('settings')
|
||||
|
||||
const handleSignOut = async () => {
|
||||
await signOut({
|
||||
@@ -22,8 +25,8 @@ export function SettingsView() {
|
||||
return (
|
||||
<section className="space-y-6">
|
||||
<div>
|
||||
<h1 className="text-2xl font-bold text-primary">Ajustes</h1>
|
||||
<p className="mt-1 text-sm text-foreground/60">Configurá tu cuenta y tus grupos.</p>
|
||||
<h1 className="text-2xl font-bold text-primary">{t('title')}</h1>
|
||||
<p className="mt-1 text-sm text-foreground/60">{t('subtitle')}</p>
|
||||
</div>
|
||||
|
||||
<div className="divide-y divide-border rounded-xl border border-border bg-surface">
|
||||
@@ -32,8 +35,8 @@ export function SettingsView() {
|
||||
<Fingerprint className="size-4 text-accent-fg" />
|
||||
</span>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-medium text-primary">Seguridad</p>
|
||||
<p className="text-xs text-foreground/50">Contraseña y passkeys</p>
|
||||
<p className="text-sm font-medium text-primary">{t('security.title')}</p>
|
||||
<p className="text-xs text-foreground/50">{t('security.description')}</p>
|
||||
</div>
|
||||
<ChevronRight className="size-4 text-foreground/40" />
|
||||
</Link>
|
||||
@@ -49,8 +52,10 @@ export function SettingsView() {
|
||||
|
||||
<AppearanceCard />
|
||||
|
||||
<LanguageCard syncProfile />
|
||||
|
||||
<Button variant="outline" onClick={handleSignOut}>
|
||||
Cerrar sesión
|
||||
{t('signOut')}
|
||||
</Button>
|
||||
</section>
|
||||
)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useState, type FormEvent } from 'react'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { Landmark, Loader2 } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button, Input, Label, useToast } from '../../components/ui'
|
||||
import { getTransferDetails, updateTransferDetails } from '../../lib/api'
|
||||
|
||||
@@ -11,6 +12,7 @@ const KEY = ['transfer-details'] as const
|
||||
export function TransferDetailsSettingsCard() {
|
||||
const queryClient = useQueryClient()
|
||||
const toast = useToast()
|
||||
const { t } = useTranslation(['settings', 'common'])
|
||||
const query = useQuery({ queryKey: KEY, queryFn: getTransferDetails })
|
||||
const [editing, setEditing] = useState(false)
|
||||
const [alias, setAlias] = useState('')
|
||||
@@ -21,9 +23,9 @@ export function TransferDetailsSettingsCard() {
|
||||
onSuccess: (data) => {
|
||||
queryClient.setQueryData(KEY, data)
|
||||
setEditing(false)
|
||||
toast.success('Datos para transferir guardados')
|
||||
toast.success(t('transfer.saved'))
|
||||
},
|
||||
onError: () => toast.error('No pudimos guardar los datos'),
|
||||
onError: () => toast.error(t('transfer.saveError')),
|
||||
})
|
||||
|
||||
const startEditing = () => {
|
||||
@@ -44,12 +46,12 @@ export function TransferDetailsSettingsCard() {
|
||||
<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>
|
||||
<p className="text-sm font-medium text-primary">{t('transfer.title')}</p>
|
||||
<p className="text-xs text-secondary">{t('transfer.description')}</p>
|
||||
</div>
|
||||
{!editing ? (
|
||||
<Button variant="outline" size="sm" className="h-11 shrink-0" onClick={startEditing} disabled={query.isPending}>
|
||||
{query.data?.alias ? 'Editar' : 'Agregar'}
|
||||
{query.data?.alias ? t('common:actions.edit') : t('common:actions.add')}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
@@ -57,32 +59,32 @@ export function TransferDetailsSettingsCard() {
|
||||
{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>
|
||||
<Label htmlFor="transfer-alias">{t('transfer.alias')}</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>
|
||||
<Label htmlFor="transfer-holder">{t('transfer.holder')}</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
|
||||
{t('common:actions.cancel')}
|
||||
</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
|
||||
{t('common:actions.save')}
|
||||
</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>
|
||||
<dt className="text-secondary">{t('transfer.aliasShort')}</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>
|
||||
<dt className="text-secondary">{t('transfer.holder')}</dt>
|
||||
<dd className="truncate font-medium text-primary">{query.data.holder}</dd>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import { Monitor, Moon, Sun } from 'lucide-react'
|
||||
import type { Theme } from '../../context/ThemeProvider'
|
||||
|
||||
export const THEME_OPTIONS: { value: Theme; label: string; description: string }[] = [
|
||||
{ value: 'light', label: 'Claro', description: 'Interfaz en tonos claros' },
|
||||
{ value: 'dark', label: 'Oscuro', description: 'Interfaz en tonos oscuros' },
|
||||
{ value: 'system', label: 'Sistema', description: 'Sigue la preferencia de tu dispositivo' },
|
||||
]
|
||||
/** Claves en el namespace `settings` (`appearance.*`). */
|
||||
export const THEME_OPTIONS = [
|
||||
{ value: 'light', label: 'appearance.light', description: 'appearance.lightDescription' },
|
||||
{ value: 'dark', label: 'appearance.dark', description: 'appearance.darkDescription' },
|
||||
{ value: 'system', label: 'appearance.system', description: 'appearance.systemDescription' },
|
||||
] as const satisfies readonly { value: Theme; label: string; description: string }[]
|
||||
|
||||
export const THEME_ICONS: Record<Theme, typeof Sun> = {
|
||||
light: Sun,
|
||||
dark: Moon,
|
||||
system: Monitor,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useNavigate, useSearch } from '@tanstack/react-router'
|
||||
import { useEffect } from 'react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { useToast } from '../../components/ui'
|
||||
import { mpCallbackErrorMessage, mpStatusQueryKey, readMpCallbackFeedback } from '../mp'
|
||||
import {
|
||||
@@ -19,6 +20,7 @@ export function useCallbackFeedbackToast() {
|
||||
const navigate = useNavigate()
|
||||
const queryClient = useQueryClient()
|
||||
const toast = useToast()
|
||||
const { t } = useTranslation('settings')
|
||||
|
||||
useEffect(() => {
|
||||
const mp = readMpCallbackFeedback(search.mp, search.reason)
|
||||
@@ -26,12 +28,12 @@ export function useCallbackFeedbackToast() {
|
||||
if (!mp && !wa) return
|
||||
|
||||
if (mp) {
|
||||
if (mp.kind === 'success') toast.success('Tu cuenta de Mercado Pago quedó vinculada.')
|
||||
if (mp.kind === 'success') toast.success(t('callback.mpLinked'))
|
||||
else toast.error(mpCallbackErrorMessage(mp.reason))
|
||||
void queryClient.invalidateQueries({ queryKey: mpStatusQueryKey })
|
||||
}
|
||||
if (wa) {
|
||||
if (wa.kind === 'success') toast.success('Tu WhatsApp quedó vinculado.')
|
||||
if (wa.kind === 'success') toast.success(t('callback.whatsappLinked'))
|
||||
else toast.error(whatsappCallbackErrorMessage(wa.reason))
|
||||
void queryClient.invalidateQueries({ queryKey: whatsappStatusQueryKey })
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { CalendarDays, Home, User, Wallet } from 'lucide-react'
|
||||
import type { NavItem } from '../../components/layout/nav-items'
|
||||
import { CalendarDays, Home, User, Wallet, type LucideIcon } from 'lucide-react'
|
||||
|
||||
type StudentNavItem = { label: string; to: string; icon: LucideIcon }
|
||||
|
||||
// Bottom nav of the student app: the single source for StudentBottomNav.
|
||||
export const STUDENT_NAV_ITEMS: NavItem[] = [
|
||||
export const STUDENT_NAV_ITEMS: StudentNavItem[] = [
|
||||
{ label: 'Inicio', to: '/student', icon: Home },
|
||||
{ label: 'Clases', to: '/student/classes', icon: CalendarDays },
|
||||
{ label: 'Pagos', to: '/student/payments', icon: Wallet },
|
||||
|
||||
Reference in New Issue
Block a user