feat(i18n): traducir Inicio
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import { useQuery } from '@tanstack/react-query'
|
||||
import { Link } from '@tanstack/react-router'
|
||||
import type { PendingPreRegistrations } from '@gruperly/shared'
|
||||
import { CheckCircle2, ChevronRight, Inbox, Wallet } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Avatar } from '../../components/ui'
|
||||
import { getGroupsRiskOverview, getPayments } from '../../lib/api'
|
||||
import { absenceReason } from '../groups/card'
|
||||
@@ -19,6 +20,7 @@ export function AttentionList({
|
||||
}: {
|
||||
pendingPreRegistrations: PendingPreRegistrations[]
|
||||
}) {
|
||||
const { t } = useTranslation('home')
|
||||
const riskQuery = useQuery({
|
||||
queryKey: ['groups-risk-overview'],
|
||||
queryFn: getGroupsRiskOverview,
|
||||
@@ -45,12 +47,12 @@ export function AttentionList({
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h2 className="text-lg font-bold text-primary">Para atender</h2>
|
||||
<h2 className="text-lg font-bold text-primary">{t('attention.title')}</h2>
|
||||
|
||||
{atRisk.length === 0 && overdue === 0 && pendingPreRegistrations.length === 0 ? (
|
||||
<p className="mt-3 flex items-center gap-2 rounded-xl border border-border bg-surface px-4 py-3 text-sm text-foreground/70">
|
||||
<CheckCircle2 className="size-4 shrink-0 text-success" aria-hidden="true" />
|
||||
Todo en orden: nadie en riesgo, sin cobros vencidos ni preinscripciones.
|
||||
{t('attention.allGood')}
|
||||
</p>
|
||||
) : (
|
||||
<ul className="mt-3 divide-y divide-border overflow-hidden rounded-xl border border-border bg-surface">
|
||||
@@ -62,9 +64,9 @@ export function AttentionList({
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block text-sm font-semibold text-primary">
|
||||
{overdue} {overdue === 1 ? 'cobro vencido' : 'cobros vencidos'}
|
||||
{t('attention.overdue', { count: overdue })}
|
||||
</span>
|
||||
<span className="block text-xs text-foreground/60">Revisalos en Cobros</span>
|
||||
<span className="block text-xs text-foreground/60">{t('attention.overdueHint')}</span>
|
||||
</span>
|
||||
<ChevronRight className="size-4 shrink-0 text-foreground/40" aria-hidden="true" />
|
||||
</Link>
|
||||
@@ -86,9 +88,7 @@ export function AttentionList({
|
||||
</span>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block text-sm font-semibold text-primary">
|
||||
{group.count === 1
|
||||
? '1 preinscripción por aprobar'
|
||||
: `${group.count} preinscripciones por aprobar`}
|
||||
{t('attention.preRegistrations', { count: group.count })}
|
||||
</span>
|
||||
<span className="block truncate text-xs text-foreground/60">{group.groupName}</span>
|
||||
</span>
|
||||
@@ -126,7 +126,7 @@ export function AttentionList({
|
||||
|
||||
{totalAtRisk > MAX_AT_RISK ? (
|
||||
<li className="px-4 py-3 text-xs text-foreground/60">
|
||||
Y {totalAtRisk - MAX_AT_RISK} más en riesgo. Mirá las estadísticas de cada grupo.
|
||||
{t('attention.moreAtRisk', { count: totalAtRisk - MAX_AT_RISK })}
|
||||
</li>
|
||||
) : null}
|
||||
</ul>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import { Loader2, Plus } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Button } from '../../components/ui'
|
||||
import { useAuth } from '../../context/AuthProvider'
|
||||
import { useIntlLocale } from '../../i18n'
|
||||
import { getClassesToday, getHomeSummary } from '../../lib/api'
|
||||
import { useMpStatus } from '../mp/useMpStatus'
|
||||
import { AttentionList } from './AttentionList'
|
||||
@@ -13,11 +15,13 @@ import { UpcomingPaymentRow } from './UpcomingPaymentRow'
|
||||
|
||||
export function HomeView() {
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation(['home', 'common'])
|
||||
const locale = useIntlLocale()
|
||||
const { user } = useAuth()
|
||||
const mpStatusQuery = useMpStatus()
|
||||
const firstName = user?.name?.trim().split(/\s+/)[0]
|
||||
// "martes 27 de octubre": the date anchors "Clase de hoy" and the due dates below.
|
||||
const today = new Date().toLocaleDateString('es-AR', {
|
||||
const today = new Date().toLocaleDateString(locale, {
|
||||
weekday: 'long',
|
||||
day: 'numeric',
|
||||
month: 'long',
|
||||
@@ -38,7 +42,7 @@ export function HomeView() {
|
||||
<div>
|
||||
<p className="text-sm font-medium first-letter:uppercase text-foreground/60">{today}</p>
|
||||
<h1 className="mt-1 text-2xl font-bold text-primary">
|
||||
{firstName ? `Hola, ${firstName}` : 'Hola'}
|
||||
{firstName ? t('greetingName', { name: firstName }) : t('greeting')}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@@ -50,18 +54,18 @@ export function HomeView() {
|
||||
|
||||
{summaryQuery.isError ? (
|
||||
<div className="mt-8 space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||
<p>No pudimos cargar tu resumen.</p>
|
||||
<p>{t('loadError')}</p>
|
||||
<Button variant="outline" size="sm" onClick={() => void summaryQuery.refetch()}>
|
||||
Reintentar
|
||||
{t('common:actions.retry')}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{summaryQuery.isSuccess && summaryQuery.data.stats.groups === 0 ? (
|
||||
<div className="mt-8 rounded-xl border border-dashed border-border bg-surface px-4 py-12 text-center">
|
||||
<p className="font-medium text-primary">Todavía no tenés grupos</p>
|
||||
<p className="font-medium text-primary">{t('empty.title')}</p>
|
||||
<p className="mt-1 text-sm text-foreground/60">
|
||||
Crea tu primer grupo para empezar a cobrar.
|
||||
{t('empty.description')}
|
||||
</p>
|
||||
<Button
|
||||
variant="primary"
|
||||
@@ -69,7 +73,7 @@ export function HomeView() {
|
||||
onClick={() => void navigate({ to: '/groups/new' })}
|
||||
>
|
||||
<Plus className="size-4" />
|
||||
Crear tu primer grupo
|
||||
{t('empty.cta')}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
@@ -86,9 +90,9 @@ export function HomeView() {
|
||||
<NextClassHero nextClass={summaryQuery.data.nextClass} />
|
||||
) : (
|
||||
<div className="rounded-xl border border-dashed border-border bg-surface px-4 py-8 text-center">
|
||||
<p className="text-sm font-medium text-primary">Sin clases programadas</p>
|
||||
<p className="text-sm font-medium text-primary">{t('noClasses.title')}</p>
|
||||
<p className="mt-1 text-sm text-foreground/60">
|
||||
Agregá días y horario a tus grupos para ver tu próxima clase acá.
|
||||
{t('noClasses.description')}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
@@ -99,9 +103,9 @@ export function HomeView() {
|
||||
|
||||
<div>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<h2 className="text-lg font-bold text-primary">Próximos cobros</h2>
|
||||
<h2 className="text-lg font-bold text-primary">{t('upcoming.title')}</h2>
|
||||
<Button variant="ghost" size="sm" onClick={() => void navigate({ to: '/payments' })}>
|
||||
Ver todos
|
||||
{t('upcoming.seeAll')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -113,7 +117,7 @@ export function HomeView() {
|
||||
</ul>
|
||||
) : (
|
||||
<div className="mt-3 rounded-xl border border-dashed border-border bg-surface px-4 py-6 text-center text-sm text-foreground/60">
|
||||
<p>Sin cobros pendientes por ahora.</p>
|
||||
<p>{t('upcoming.empty')}</p>
|
||||
{/* The empty state says how to get out of it: without Mercado
|
||||
Pago there is no way to create payment links. */}
|
||||
{mpStatusQuery.data && mpStatusQuery.data.status !== 'active' ? (
|
||||
@@ -121,10 +125,10 @@ export function HomeView() {
|
||||
to="/settings"
|
||||
className="mt-2 inline-block font-medium text-accent hover:underline"
|
||||
>
|
||||
Vinculá Mercado Pago para cobrar
|
||||
{t('upcoming.linkMp')}
|
||||
</Link>
|
||||
) : (
|
||||
<p className="mt-1 text-xs">Los creás desde la ficha de cada grupo.</p>
|
||||
<p className="mt-1 text-xs">{t('upcoming.hint')}</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import type { NextClassDto } from '@gruperly/shared'
|
||||
import { CalendarClock } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Badge, Button } from '../../components/ui'
|
||||
import { formatRelativeDateTime, formatSchedule } from '../../lib/format'
|
||||
|
||||
export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation('home')
|
||||
const hasSchedule = (nextClass.days?.length ?? 0) > 0
|
||||
|
||||
return (
|
||||
@@ -13,7 +15,7 @@ export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
|
||||
<div className="min-w-0">
|
||||
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
||||
{nextClass.isNow ? 'Clase en curso' : 'Próxima clase'}
|
||||
{nextClass.isNow ? t('nextClass.now') : t('nextClass.next')}
|
||||
</p>
|
||||
<h2 className="mt-1 truncate text-xl font-bold text-primary">{nextClass.name}</h2>
|
||||
{hasSchedule ? (
|
||||
@@ -25,7 +27,7 @@ export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<Badge variant={nextClass.isNow ? 'success' : 'neutral'}>
|
||||
{nextClass.isNow ? 'En curso ahora' : formatRelativeDateTime(nextClass.occurrenceAt)}
|
||||
{nextClass.isNow ? t('nextClass.nowBadge') : formatRelativeDateTime(nextClass.occurrenceAt)}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,7 +37,7 @@ export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
||||
size="sm"
|
||||
onClick={() => void navigate({ to: `/groups/${nextClass.groupId}` })}
|
||||
>
|
||||
Ver grupo
|
||||
{t('nextClass.seeGroup')}
|
||||
</Button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import type { HomeSummaryDto } from '@gruperly/shared'
|
||||
import { UserCheck, Users, Wallet, type LucideIcon } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { formatPrice } from '../../lib/format'
|
||||
|
||||
@@ -12,6 +13,7 @@ type StatTarget = '/groups' | '/payments'
|
||||
the label for a sub-line and read "0 / 0 por cobrar". */
|
||||
export function SummaryStats({ summary }: { summary: HomeSummaryDto }) {
|
||||
const navigate = useNavigate()
|
||||
const { t } = useTranslation('home')
|
||||
const { pendingAmount, pendingPayments } = summary.stats
|
||||
const stats: {
|
||||
label: string
|
||||
@@ -20,19 +22,19 @@ export function SummaryStats({ summary }: { summary: HomeSummaryDto }) {
|
||||
to: StatTarget
|
||||
}[] = [
|
||||
{
|
||||
label: summary.stats.groups === 1 ? 'Grupo' : 'Grupos',
|
||||
label: t('stats.groups', { count: summary.stats.groups }),
|
||||
value: String(summary.stats.groups),
|
||||
icon: Users,
|
||||
to: '/groups',
|
||||
},
|
||||
{
|
||||
label: pendingPayments > 0 ? `Por cobrar · ${pendingPayments}` : 'Por cobrar',
|
||||
label: pendingPayments > 0 ? t('stats.toCollectCount', { count: pendingPayments }) : t('stats.toCollect'),
|
||||
value: formatPrice(pendingAmount),
|
||||
icon: Wallet,
|
||||
to: '/payments',
|
||||
},
|
||||
{
|
||||
label: summary.stats.attendees === 1 ? 'Alumno' : 'Alumnos',
|
||||
label: t('stats.students', { count: summary.stats.attendees }),
|
||||
value: String(summary.stats.attendees),
|
||||
icon: UserCheck,
|
||||
to: '/groups',
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import { Link, useNavigate } from '@tanstack/react-router'
|
||||
import type { ClassTodayDto } from '@gruperly/shared'
|
||||
import { CalendarClock, ChevronRight, ClipboardCheck } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Badge, Button } from '../../components/ui'
|
||||
import { useIntlLocale } from '../../i18n'
|
||||
|
||||
export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
||||
const navigate = useNavigate()
|
||||
const time = new Date(item.startsAt).toLocaleTimeString('es-MX', {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false,
|
||||
})
|
||||
const { t } = useTranslation('home')
|
||||
const locale = useIntlLocale()
|
||||
const time = new Date(item.startsAt).toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' })
|
||||
|
||||
return (
|
||||
<article className="relative overflow-hidden rounded-xl border border-accent/30 bg-surface p-5">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
||||
Clase de hoy
|
||||
{t('today.label')}
|
||||
</p>
|
||||
{/* Only the done state earns a badge: "Por tomar" repeated what the
|
||||
button below already says. */}
|
||||
{item.hasAttendance ? <Badge variant="success">Asistencia tomada</Badge> : null}
|
||||
{item.hasAttendance ? <Badge variant="success">{t('today.attendanceTaken')}</Badge> : null}
|
||||
</div>
|
||||
<Link
|
||||
to="/groups/$groupId"
|
||||
@@ -34,13 +34,11 @@ export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
||||
</Link>
|
||||
<div className="mt-2 flex items-center gap-2 text-sm text-foreground/70">
|
||||
<CalendarClock className="size-4 shrink-0 text-accent" />
|
||||
<span>Hoy · {time} hs</span>
|
||||
<span>{t('today.time', { time })}</span>
|
||||
</div>
|
||||
<p className="mt-1 text-xs text-foreground/60">
|
||||
{item.enrolledCount} inscrito{item.enrolledCount === 1 ? '' : 's'}
|
||||
{item.availableSlots != null
|
||||
? ` · ${item.availableSlots} cupo${item.availableSlots === 1 ? '' : 's'} disponible${item.availableSlots === 1 ? '' : 's'}`
|
||||
: ''}
|
||||
{t('today.enrolled', { count: item.enrolledCount })}
|
||||
{item.availableSlots != null ? ` · ${t('today.slots', { count: item.availableSlots })}` : ''}
|
||||
</p>
|
||||
<Button
|
||||
variant={item.hasAttendance ? 'outline' : 'primary'}
|
||||
@@ -48,7 +46,7 @@ export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
||||
onClick={() => void navigate({ to: `/class/${item.sessionId}/attendance` })}
|
||||
>
|
||||
<ClipboardCheck className="size-4" />
|
||||
{item.hasAttendance ? 'Ver asistencia' : 'Tomar asistencia'}
|
||||
{item.hasAttendance ? t('today.seeAttendance') : t('today.takeAttendance')}
|
||||
</Button>
|
||||
</article>
|
||||
)
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import type { UpcomingPaymentDto } from '@gruperly/shared'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import { Badge } from '../../components/ui'
|
||||
import { formatPrice, formatRelativeDateTime, paymentStatusLabel } from '../../lib/format'
|
||||
import { PAYMENT_BADGE_VARIANT } from './constants'
|
||||
|
||||
export function UpcomingPaymentRow({ payment }: { payment: UpcomingPaymentDto }) {
|
||||
// Re-render on language change: the labels come from lib/format.
|
||||
useTranslation()
|
||||
return (
|
||||
<li className="flex items-center justify-between gap-3 rounded-xl border border-border bg-surface px-4 py-3">
|
||||
<div className="min-w-0">
|
||||
|
||||
Reference in New Issue
Block a user