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 { Link } from '@tanstack/react-router'
|
||||||
import type { PendingPreRegistrations } from '@gruperly/shared'
|
import type { PendingPreRegistrations } from '@gruperly/shared'
|
||||||
import { CheckCircle2, ChevronRight, Inbox, Wallet } from 'lucide-react'
|
import { CheckCircle2, ChevronRight, Inbox, Wallet } from 'lucide-react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Avatar } from '../../components/ui'
|
import { Avatar } from '../../components/ui'
|
||||||
import { getGroupsRiskOverview, getPayments } from '../../lib/api'
|
import { getGroupsRiskOverview, getPayments } from '../../lib/api'
|
||||||
import { absenceReason } from '../groups/card'
|
import { absenceReason } from '../groups/card'
|
||||||
@@ -19,6 +20,7 @@ export function AttentionList({
|
|||||||
}: {
|
}: {
|
||||||
pendingPreRegistrations: PendingPreRegistrations[]
|
pendingPreRegistrations: PendingPreRegistrations[]
|
||||||
}) {
|
}) {
|
||||||
|
const { t } = useTranslation('home')
|
||||||
const riskQuery = useQuery({
|
const riskQuery = useQuery({
|
||||||
queryKey: ['groups-risk-overview'],
|
queryKey: ['groups-risk-overview'],
|
||||||
queryFn: getGroupsRiskOverview,
|
queryFn: getGroupsRiskOverview,
|
||||||
@@ -45,12 +47,12 @@ export function AttentionList({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<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 ? (
|
{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">
|
<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" />
|
<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>
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<ul className="mt-3 divide-y divide-border overflow-hidden rounded-xl border border-border bg-surface">
|
<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>
|
||||||
<span className="min-w-0 flex-1">
|
<span className="min-w-0 flex-1">
|
||||||
<span className="block text-sm font-semibold text-primary">
|
<span className="block text-sm font-semibold text-primary">
|
||||||
{overdue} {overdue === 1 ? 'cobro vencido' : 'cobros vencidos'}
|
{t('attention.overdue', { count: overdue })}
|
||||||
</span>
|
</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>
|
</span>
|
||||||
<ChevronRight className="size-4 shrink-0 text-foreground/40" aria-hidden="true" />
|
<ChevronRight className="size-4 shrink-0 text-foreground/40" aria-hidden="true" />
|
||||||
</Link>
|
</Link>
|
||||||
@@ -86,9 +88,7 @@ export function AttentionList({
|
|||||||
</span>
|
</span>
|
||||||
<span className="min-w-0 flex-1">
|
<span className="min-w-0 flex-1">
|
||||||
<span className="block text-sm font-semibold text-primary">
|
<span className="block text-sm font-semibold text-primary">
|
||||||
{group.count === 1
|
{t('attention.preRegistrations', { count: group.count })}
|
||||||
? '1 preinscripción por aprobar'
|
|
||||||
: `${group.count} preinscripciones por aprobar`}
|
|
||||||
</span>
|
</span>
|
||||||
<span className="block truncate text-xs text-foreground/60">{group.groupName}</span>
|
<span className="block truncate text-xs text-foreground/60">{group.groupName}</span>
|
||||||
</span>
|
</span>
|
||||||
@@ -126,7 +126,7 @@ export function AttentionList({
|
|||||||
|
|
||||||
{totalAtRisk > MAX_AT_RISK ? (
|
{totalAtRisk > MAX_AT_RISK ? (
|
||||||
<li className="px-4 py-3 text-xs text-foreground/60">
|
<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>
|
</li>
|
||||||
) : null}
|
) : null}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import { useQuery } from '@tanstack/react-query'
|
import { useQuery } from '@tanstack/react-query'
|
||||||
import { Link, useNavigate } from '@tanstack/react-router'
|
import { Link, useNavigate } from '@tanstack/react-router'
|
||||||
import { Loader2, Plus } from 'lucide-react'
|
import { Loader2, Plus } from 'lucide-react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Button } from '../../components/ui'
|
import { Button } from '../../components/ui'
|
||||||
import { useAuth } from '../../context/AuthProvider'
|
import { useAuth } from '../../context/AuthProvider'
|
||||||
|
import { useIntlLocale } from '../../i18n'
|
||||||
import { getClassesToday, getHomeSummary } from '../../lib/api'
|
import { getClassesToday, getHomeSummary } from '../../lib/api'
|
||||||
import { useMpStatus } from '../mp/useMpStatus'
|
import { useMpStatus } from '../mp/useMpStatus'
|
||||||
import { AttentionList } from './AttentionList'
|
import { AttentionList } from './AttentionList'
|
||||||
@@ -13,11 +15,13 @@ import { UpcomingPaymentRow } from './UpcomingPaymentRow'
|
|||||||
|
|
||||||
export function HomeView() {
|
export function HomeView() {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const { t } = useTranslation(['home', 'common'])
|
||||||
|
const locale = useIntlLocale()
|
||||||
const { user } = useAuth()
|
const { user } = useAuth()
|
||||||
const mpStatusQuery = useMpStatus()
|
const mpStatusQuery = useMpStatus()
|
||||||
const firstName = user?.name?.trim().split(/\s+/)[0]
|
const firstName = user?.name?.trim().split(/\s+/)[0]
|
||||||
// "martes 27 de octubre": the date anchors "Clase de hoy" and the due dates below.
|
// "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',
|
weekday: 'long',
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
month: 'long',
|
month: 'long',
|
||||||
@@ -38,7 +42,7 @@ export function HomeView() {
|
|||||||
<div>
|
<div>
|
||||||
<p className="text-sm font-medium first-letter:uppercase text-foreground/60">{today}</p>
|
<p className="text-sm font-medium first-letter:uppercase text-foreground/60">{today}</p>
|
||||||
<h1 className="mt-1 text-2xl font-bold text-primary">
|
<h1 className="mt-1 text-2xl font-bold text-primary">
|
||||||
{firstName ? `Hola, ${firstName}` : 'Hola'}
|
{firstName ? t('greetingName', { name: firstName }) : t('greeting')}
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -50,18 +54,18 @@ export function HomeView() {
|
|||||||
|
|
||||||
{summaryQuery.isError ? (
|
{summaryQuery.isError ? (
|
||||||
<div className="mt-8 space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
<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()}>
|
<Button variant="outline" size="sm" onClick={() => void summaryQuery.refetch()}>
|
||||||
Reintentar
|
{t('common:actions.retry')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{summaryQuery.isSuccess && summaryQuery.data.stats.groups === 0 ? (
|
{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">
|
<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">
|
<p className="mt-1 text-sm text-foreground/60">
|
||||||
Crea tu primer grupo para empezar a cobrar.
|
{t('empty.description')}
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
@@ -69,7 +73,7 @@ export function HomeView() {
|
|||||||
onClick={() => void navigate({ to: '/groups/new' })}
|
onClick={() => void navigate({ to: '/groups/new' })}
|
||||||
>
|
>
|
||||||
<Plus className="size-4" />
|
<Plus className="size-4" />
|
||||||
Crear tu primer grupo
|
{t('empty.cta')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
@@ -86,9 +90,9 @@ export function HomeView() {
|
|||||||
<NextClassHero nextClass={summaryQuery.data.nextClass} />
|
<NextClassHero nextClass={summaryQuery.data.nextClass} />
|
||||||
) : (
|
) : (
|
||||||
<div className="rounded-xl border border-dashed border-border bg-surface px-4 py-8 text-center">
|
<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">
|
<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>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
@@ -99,9 +103,9 @@ export function HomeView() {
|
|||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div className="flex items-center justify-between gap-3">
|
<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' })}>
|
<Button variant="ghost" size="sm" onClick={() => void navigate({ to: '/payments' })}>
|
||||||
Ver todos
|
{t('upcoming.seeAll')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -113,7 +117,7 @@ export function HomeView() {
|
|||||||
</ul>
|
</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">
|
<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
|
{/* The empty state says how to get out of it: without Mercado
|
||||||
Pago there is no way to create payment links. */}
|
Pago there is no way to create payment links. */}
|
||||||
{mpStatusQuery.data && mpStatusQuery.data.status !== 'active' ? (
|
{mpStatusQuery.data && mpStatusQuery.data.status !== 'active' ? (
|
||||||
@@ -121,10 +125,10 @@ export function HomeView() {
|
|||||||
to="/settings"
|
to="/settings"
|
||||||
className="mt-2 inline-block font-medium text-accent hover:underline"
|
className="mt-2 inline-block font-medium text-accent hover:underline"
|
||||||
>
|
>
|
||||||
Vinculá Mercado Pago para cobrar
|
{t('upcoming.linkMp')}
|
||||||
</Link>
|
</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>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import { useNavigate } from '@tanstack/react-router'
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import type { NextClassDto } from '@gruperly/shared'
|
import type { NextClassDto } from '@gruperly/shared'
|
||||||
import { CalendarClock } from 'lucide-react'
|
import { CalendarClock } from 'lucide-react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Badge, Button } from '../../components/ui'
|
import { Badge, Button } from '../../components/ui'
|
||||||
import { formatRelativeDateTime, formatSchedule } from '../../lib/format'
|
import { formatRelativeDateTime, formatSchedule } from '../../lib/format'
|
||||||
|
|
||||||
export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const { t } = useTranslation('home')
|
||||||
const hasSchedule = (nextClass.days?.length ?? 0) > 0
|
const hasSchedule = (nextClass.days?.length ?? 0) > 0
|
||||||
|
|
||||||
return (
|
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="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
|
||||||
<div className="min-w-0">
|
<div className="min-w-0">
|
||||||
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
<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>
|
</p>
|
||||||
<h2 className="mt-1 truncate text-xl font-bold text-primary">{nextClass.name}</h2>
|
<h2 className="mt-1 truncate text-xl font-bold text-primary">{nextClass.name}</h2>
|
||||||
{hasSchedule ? (
|
{hasSchedule ? (
|
||||||
@@ -25,7 +27,7 @@ export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="flex shrink-0 items-center gap-2">
|
<div className="flex shrink-0 items-center gap-2">
|
||||||
<Badge variant={nextClass.isNow ? 'success' : 'neutral'}>
|
<Badge variant={nextClass.isNow ? 'success' : 'neutral'}>
|
||||||
{nextClass.isNow ? 'En curso ahora' : formatRelativeDateTime(nextClass.occurrenceAt)}
|
{nextClass.isNow ? t('nextClass.nowBadge') : formatRelativeDateTime(nextClass.occurrenceAt)}
|
||||||
</Badge>
|
</Badge>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -35,7 +37,7 @@ export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
|||||||
size="sm"
|
size="sm"
|
||||||
onClick={() => void navigate({ to: `/groups/${nextClass.groupId}` })}
|
onClick={() => void navigate({ to: `/groups/${nextClass.groupId}` })}
|
||||||
>
|
>
|
||||||
Ver grupo
|
{t('nextClass.seeGroup')}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useNavigate } from '@tanstack/react-router'
|
import { useNavigate } from '@tanstack/react-router'
|
||||||
import type { HomeSummaryDto } from '@gruperly/shared'
|
import type { HomeSummaryDto } from '@gruperly/shared'
|
||||||
import { UserCheck, Users, Wallet, type LucideIcon } from 'lucide-react'
|
import { UserCheck, Users, Wallet, type LucideIcon } from 'lucide-react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { cn } from '../../lib/utils'
|
import { cn } from '../../lib/utils'
|
||||||
import { formatPrice } from '../../lib/format'
|
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". */
|
the label for a sub-line and read "0 / 0 por cobrar". */
|
||||||
export function SummaryStats({ summary }: { summary: HomeSummaryDto }) {
|
export function SummaryStats({ summary }: { summary: HomeSummaryDto }) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
const { t } = useTranslation('home')
|
||||||
const { pendingAmount, pendingPayments } = summary.stats
|
const { pendingAmount, pendingPayments } = summary.stats
|
||||||
const stats: {
|
const stats: {
|
||||||
label: string
|
label: string
|
||||||
@@ -20,19 +22,19 @@ export function SummaryStats({ summary }: { summary: HomeSummaryDto }) {
|
|||||||
to: StatTarget
|
to: StatTarget
|
||||||
}[] = [
|
}[] = [
|
||||||
{
|
{
|
||||||
label: summary.stats.groups === 1 ? 'Grupo' : 'Grupos',
|
label: t('stats.groups', { count: summary.stats.groups }),
|
||||||
value: String(summary.stats.groups),
|
value: String(summary.stats.groups),
|
||||||
icon: Users,
|
icon: Users,
|
||||||
to: '/groups',
|
to: '/groups',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: pendingPayments > 0 ? `Por cobrar · ${pendingPayments}` : 'Por cobrar',
|
label: pendingPayments > 0 ? t('stats.toCollectCount', { count: pendingPayments }) : t('stats.toCollect'),
|
||||||
value: formatPrice(pendingAmount),
|
value: formatPrice(pendingAmount),
|
||||||
icon: Wallet,
|
icon: Wallet,
|
||||||
to: '/payments',
|
to: '/payments',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: summary.stats.attendees === 1 ? 'Alumno' : 'Alumnos',
|
label: t('stats.students', { count: summary.stats.attendees }),
|
||||||
value: String(summary.stats.attendees),
|
value: String(summary.stats.attendees),
|
||||||
icon: UserCheck,
|
icon: UserCheck,
|
||||||
to: '/groups',
|
to: '/groups',
|
||||||
|
|||||||
@@ -1,25 +1,25 @@
|
|||||||
import { Link, useNavigate } from '@tanstack/react-router'
|
import { Link, useNavigate } from '@tanstack/react-router'
|
||||||
import type { ClassTodayDto } from '@gruperly/shared'
|
import type { ClassTodayDto } from '@gruperly/shared'
|
||||||
import { CalendarClock, ChevronRight, ClipboardCheck } from 'lucide-react'
|
import { CalendarClock, ChevronRight, ClipboardCheck } from 'lucide-react'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Badge, Button } from '../../components/ui'
|
import { Badge, Button } from '../../components/ui'
|
||||||
|
import { useIntlLocale } from '../../i18n'
|
||||||
|
|
||||||
export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const time = new Date(item.startsAt).toLocaleTimeString('es-MX', {
|
const { t } = useTranslation('home')
|
||||||
hour: '2-digit',
|
const locale = useIntlLocale()
|
||||||
minute: '2-digit',
|
const time = new Date(item.startsAt).toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' })
|
||||||
hour12: false,
|
|
||||||
})
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className="relative overflow-hidden rounded-xl border border-accent/30 bg-surface p-5">
|
<article className="relative overflow-hidden rounded-xl border border-accent/30 bg-surface p-5">
|
||||||
<div className="flex items-start justify-between gap-3">
|
<div className="flex items-start justify-between gap-3">
|
||||||
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
||||||
Clase de hoy
|
{t('today.label')}
|
||||||
</p>
|
</p>
|
||||||
{/* Only the done state earns a badge: "Por tomar" repeated what the
|
{/* Only the done state earns a badge: "Por tomar" repeated what the
|
||||||
button below already says. */}
|
button below already says. */}
|
||||||
{item.hasAttendance ? <Badge variant="success">Asistencia tomada</Badge> : null}
|
{item.hasAttendance ? <Badge variant="success">{t('today.attendanceTaken')}</Badge> : null}
|
||||||
</div>
|
</div>
|
||||||
<Link
|
<Link
|
||||||
to="/groups/$groupId"
|
to="/groups/$groupId"
|
||||||
@@ -34,13 +34,11 @@ export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
|||||||
</Link>
|
</Link>
|
||||||
<div className="mt-2 flex items-center gap-2 text-sm text-foreground/70">
|
<div className="mt-2 flex items-center gap-2 text-sm text-foreground/70">
|
||||||
<CalendarClock className="size-4 shrink-0 text-accent" />
|
<CalendarClock className="size-4 shrink-0 text-accent" />
|
||||||
<span>Hoy · {time} hs</span>
|
<span>{t('today.time', { time })}</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="mt-1 text-xs text-foreground/60">
|
<p className="mt-1 text-xs text-foreground/60">
|
||||||
{item.enrolledCount} inscrito{item.enrolledCount === 1 ? '' : 's'}
|
{t('today.enrolled', { count: item.enrolledCount })}
|
||||||
{item.availableSlots != null
|
{item.availableSlots != null ? ` · ${t('today.slots', { count: item.availableSlots })}` : ''}
|
||||||
? ` · ${item.availableSlots} cupo${item.availableSlots === 1 ? '' : 's'} disponible${item.availableSlots === 1 ? '' : 's'}`
|
|
||||||
: ''}
|
|
||||||
</p>
|
</p>
|
||||||
<Button
|
<Button
|
||||||
variant={item.hasAttendance ? 'outline' : 'primary'}
|
variant={item.hasAttendance ? 'outline' : 'primary'}
|
||||||
@@ -48,7 +46,7 @@ export function TodayClassCard({ item }: { item: ClassTodayDto }) {
|
|||||||
onClick={() => void navigate({ to: `/class/${item.sessionId}/attendance` })}
|
onClick={() => void navigate({ to: `/class/${item.sessionId}/attendance` })}
|
||||||
>
|
>
|
||||||
<ClipboardCheck className="size-4" />
|
<ClipboardCheck className="size-4" />
|
||||||
{item.hasAttendance ? 'Ver asistencia' : 'Tomar asistencia'}
|
{item.hasAttendance ? t('today.seeAttendance') : t('today.takeAttendance')}
|
||||||
</Button>
|
</Button>
|
||||||
</article>
|
</article>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
import type { UpcomingPaymentDto } from '@gruperly/shared'
|
import type { UpcomingPaymentDto } from '@gruperly/shared'
|
||||||
|
import { useTranslation } from 'react-i18next'
|
||||||
import { Badge } from '../../components/ui'
|
import { Badge } from '../../components/ui'
|
||||||
import { formatPrice, formatRelativeDateTime, paymentStatusLabel } from '../../lib/format'
|
import { formatPrice, formatRelativeDateTime, paymentStatusLabel } from '../../lib/format'
|
||||||
import { PAYMENT_BADGE_VARIANT } from './constants'
|
import { PAYMENT_BADGE_VARIANT } from './constants'
|
||||||
|
|
||||||
export function UpcomingPaymentRow({ payment }: { payment: UpcomingPaymentDto }) {
|
export function UpcomingPaymentRow({ payment }: { payment: UpcomingPaymentDto }) {
|
||||||
|
// Re-render on language change: the labels come from lib/format.
|
||||||
|
useTranslation()
|
||||||
return (
|
return (
|
||||||
<li className="flex items-center justify-between gap-3 rounded-xl border border-border bg-surface px-4 py-3">
|
<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">
|
<div className="min-w-0">
|
||||||
|
|||||||
2
apps/web/src/i18n/i18next.d.ts
vendored
2
apps/web/src/i18n/i18next.d.ts
vendored
@@ -5,6 +5,7 @@ import type errors from './locales/es-AR/errors.json'
|
|||||||
import type layout from './locales/es-AR/layout.json'
|
import type layout from './locales/es-AR/layout.json'
|
||||||
import type pwa from './locales/es-AR/pwa.json'
|
import type pwa from './locales/es-AR/pwa.json'
|
||||||
import type settings from './locales/es-AR/settings.json'
|
import type settings from './locales/es-AR/settings.json'
|
||||||
|
import type home from './locales/es-AR/home.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.
|
||||||
@@ -19,6 +20,7 @@ declare module 'i18next' {
|
|||||||
pwa: typeof pwa
|
pwa: typeof pwa
|
||||||
settings: typeof settings
|
settings: typeof settings
|
||||||
validation: typeof validation
|
validation: typeof validation
|
||||||
|
'home': typeof home
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export const NAMESPACES = [
|
|||||||
'pwa',
|
'pwa',
|
||||||
'errors',
|
'errors',
|
||||||
'validation',
|
'validation',
|
||||||
|
'home',
|
||||||
] as const
|
] as const
|
||||||
export type Namespace = (typeof NAMESPACES)[number]
|
export type Namespace = (typeof NAMESPACES)[number]
|
||||||
|
|
||||||
|
|||||||
56
apps/web/src/i18n/locales/en/home.json
Normal file
56
apps/web/src/i18n/locales/en/home.json
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"greeting": "Hi",
|
||||||
|
"greetingName": "Hi, {{name}}",
|
||||||
|
"loadError": "We couldn't load your summary.",
|
||||||
|
"empty": {
|
||||||
|
"title": "You don't have any groups yet",
|
||||||
|
"description": "Create your first group to start collecting payments.",
|
||||||
|
"cta": "Create your first group"
|
||||||
|
},
|
||||||
|
"noClasses": {
|
||||||
|
"title": "No classes scheduled",
|
||||||
|
"description": "Add days and times to your groups to see your next class here."
|
||||||
|
},
|
||||||
|
"upcoming": {
|
||||||
|
"title": "Upcoming payments",
|
||||||
|
"seeAll": "See all",
|
||||||
|
"empty": "No pending payments for now.",
|
||||||
|
"linkMp": "Link Mercado Pago to get paid",
|
||||||
|
"hint": "You create them from each group's page."
|
||||||
|
},
|
||||||
|
"stats": {
|
||||||
|
"groups_one": "Group",
|
||||||
|
"groups_other": "Groups",
|
||||||
|
"toCollect": "To collect",
|
||||||
|
"toCollectCount": "To collect · {{count}}",
|
||||||
|
"students_one": "Student",
|
||||||
|
"students_other": "Students"
|
||||||
|
},
|
||||||
|
"nextClass": {
|
||||||
|
"now": "Class in progress",
|
||||||
|
"next": "Next class",
|
||||||
|
"nowBadge": "Happening now",
|
||||||
|
"seeGroup": "View group"
|
||||||
|
},
|
||||||
|
"today": {
|
||||||
|
"label": "Today's class",
|
||||||
|
"attendanceTaken": "Attendance taken",
|
||||||
|
"time": "Today · {{time}}",
|
||||||
|
"enrolled_one": "{{count}} enrolled",
|
||||||
|
"enrolled_other": "{{count}} enrolled",
|
||||||
|
"slots_one": "{{count}} spot left",
|
||||||
|
"slots_other": "{{count}} spots left",
|
||||||
|
"seeAttendance": "View attendance",
|
||||||
|
"takeAttendance": "Take attendance"
|
||||||
|
},
|
||||||
|
"attention": {
|
||||||
|
"title": "Needs attention",
|
||||||
|
"allGood": "All good: no one at risk, no overdue payments or pre-registrations.",
|
||||||
|
"overdue_one": "{{count}} overdue payment",
|
||||||
|
"overdue_other": "{{count}} overdue payments",
|
||||||
|
"overdueHint": "Review them in Payments",
|
||||||
|
"preRegistrations_one": "{{count}} pre-registration to approve",
|
||||||
|
"preRegistrations_other": "{{count}} pre-registrations to approve",
|
||||||
|
"moreAtRisk": "And {{count}} more at risk. Check each group's stats."
|
||||||
|
}
|
||||||
|
}
|
||||||
56
apps/web/src/i18n/locales/es-419/home.json
Normal file
56
apps/web/src/i18n/locales/es-419/home.json
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"greeting": "Hola",
|
||||||
|
"greetingName": "Hola, {{name}}",
|
||||||
|
"loadError": "No pudimos cargar tu resumen.",
|
||||||
|
"empty": {
|
||||||
|
"title": "Todavía no tienes grupos",
|
||||||
|
"description": "Crea tu primer grupo para empezar a cobrar.",
|
||||||
|
"cta": "Crear tu primer grupo"
|
||||||
|
},
|
||||||
|
"noClasses": {
|
||||||
|
"title": "Sin clases programadas",
|
||||||
|
"description": "Agrega días y horario a tus grupos para ver aquí tu próxima clase."
|
||||||
|
},
|
||||||
|
"upcoming": {
|
||||||
|
"title": "Próximos cobros",
|
||||||
|
"seeAll": "Ver todos",
|
||||||
|
"empty": "Sin cobros pendientes por ahora.",
|
||||||
|
"linkMp": "Vincula Mercado Pago para cobrar",
|
||||||
|
"hint": "Los creas desde la ficha de cada grupo."
|
||||||
|
},
|
||||||
|
"stats": {
|
||||||
|
"groups_one": "Grupo",
|
||||||
|
"groups_other": "Grupos",
|
||||||
|
"toCollect": "Por cobrar",
|
||||||
|
"toCollectCount": "Por cobrar · {{count}}",
|
||||||
|
"students_one": "Alumno",
|
||||||
|
"students_other": "Alumnos"
|
||||||
|
},
|
||||||
|
"nextClass": {
|
||||||
|
"now": "Clase en curso",
|
||||||
|
"next": "Próxima clase",
|
||||||
|
"nowBadge": "En curso ahora",
|
||||||
|
"seeGroup": "Ver grupo"
|
||||||
|
},
|
||||||
|
"today": {
|
||||||
|
"label": "Clase de hoy",
|
||||||
|
"attendanceTaken": "Asistencia tomada",
|
||||||
|
"time": "Hoy · {{time}} h",
|
||||||
|
"enrolled_one": "{{count}} inscrito",
|
||||||
|
"enrolled_other": "{{count}} inscritos",
|
||||||
|
"slots_one": "{{count}} lugar disponible",
|
||||||
|
"slots_other": "{{count}} lugares disponibles",
|
||||||
|
"seeAttendance": "Ver asistencia",
|
||||||
|
"takeAttendance": "Tomar asistencia"
|
||||||
|
},
|
||||||
|
"attention": {
|
||||||
|
"title": "Para atender",
|
||||||
|
"allGood": "Todo en orden: nadie en riesgo, sin cobros vencidos ni preinscripciones.",
|
||||||
|
"overdue_one": "{{count}} cobro vencido",
|
||||||
|
"overdue_other": "{{count}} cobros vencidos",
|
||||||
|
"overdueHint": "Revísalos en Cobros",
|
||||||
|
"preRegistrations_one": "{{count}} preinscripción por aprobar",
|
||||||
|
"preRegistrations_other": "{{count}} preinscripciones por aprobar",
|
||||||
|
"moreAtRisk": "Y {{count}} más en riesgo. Revisa las estadísticas de cada grupo."
|
||||||
|
}
|
||||||
|
}
|
||||||
56
apps/web/src/i18n/locales/es-AR/home.json
Normal file
56
apps/web/src/i18n/locales/es-AR/home.json
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"greeting": "Hola",
|
||||||
|
"greetingName": "Hola, {{name}}",
|
||||||
|
"loadError": "No pudimos cargar tu resumen.",
|
||||||
|
"empty": {
|
||||||
|
"title": "Todavía no tenés grupos",
|
||||||
|
"description": "Creá tu primer grupo para empezar a cobrar.",
|
||||||
|
"cta": "Crear tu primer grupo"
|
||||||
|
},
|
||||||
|
"noClasses": {
|
||||||
|
"title": "Sin clases programadas",
|
||||||
|
"description": "Agregá días y horario a tus grupos para ver tu próxima clase acá."
|
||||||
|
},
|
||||||
|
"upcoming": {
|
||||||
|
"title": "Próximos cobros",
|
||||||
|
"seeAll": "Ver todos",
|
||||||
|
"empty": "Sin cobros pendientes por ahora.",
|
||||||
|
"linkMp": "Vinculá Mercado Pago para cobrar",
|
||||||
|
"hint": "Los creás desde la ficha de cada grupo."
|
||||||
|
},
|
||||||
|
"stats": {
|
||||||
|
"groups_one": "Grupo",
|
||||||
|
"groups_other": "Grupos",
|
||||||
|
"toCollect": "Por cobrar",
|
||||||
|
"toCollectCount": "Por cobrar · {{count}}",
|
||||||
|
"students_one": "Alumno",
|
||||||
|
"students_other": "Alumnos"
|
||||||
|
},
|
||||||
|
"nextClass": {
|
||||||
|
"now": "Clase en curso",
|
||||||
|
"next": "Próxima clase",
|
||||||
|
"nowBadge": "En curso ahora",
|
||||||
|
"seeGroup": "Ver grupo"
|
||||||
|
},
|
||||||
|
"today": {
|
||||||
|
"label": "Clase de hoy",
|
||||||
|
"attendanceTaken": "Asistencia tomada",
|
||||||
|
"time": "Hoy · {{time}} hs",
|
||||||
|
"enrolled_one": "{{count}} inscrito",
|
||||||
|
"enrolled_other": "{{count}} inscritos",
|
||||||
|
"slots_one": "{{count}} cupo disponible",
|
||||||
|
"slots_other": "{{count}} cupos disponibles",
|
||||||
|
"seeAttendance": "Ver asistencia",
|
||||||
|
"takeAttendance": "Tomar asistencia"
|
||||||
|
},
|
||||||
|
"attention": {
|
||||||
|
"title": "Para atender",
|
||||||
|
"allGood": "Todo en orden: nadie en riesgo, sin cobros vencidos ni preinscripciones.",
|
||||||
|
"overdue_one": "{{count}} cobro vencido",
|
||||||
|
"overdue_other": "{{count}} cobros vencidos",
|
||||||
|
"overdueHint": "Revisalos en Cobros",
|
||||||
|
"preRegistrations_one": "{{count}} preinscripción por aprobar",
|
||||||
|
"preRegistrations_other": "{{count}} preinscripciones por aprobar",
|
||||||
|
"moreAtRisk": "Y {{count}} más en riesgo. Mirá las estadísticas de cada grupo."
|
||||||
|
}
|
||||||
|
}
|
||||||
56
apps/web/src/i18n/locales/pt-BR/home.json
Normal file
56
apps/web/src/i18n/locales/pt-BR/home.json
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"greeting": "Olá",
|
||||||
|
"greetingName": "Olá, {{name}}",
|
||||||
|
"loadError": "Não conseguimos carregar seu resumo.",
|
||||||
|
"empty": {
|
||||||
|
"title": "Você ainda não tem grupos",
|
||||||
|
"description": "Crie seu primeiro grupo para começar a cobrar.",
|
||||||
|
"cta": "Criar seu primeiro grupo"
|
||||||
|
},
|
||||||
|
"noClasses": {
|
||||||
|
"title": "Nenhuma aula agendada",
|
||||||
|
"description": "Adicione dias e horário aos seus grupos para ver sua próxima aula aqui."
|
||||||
|
},
|
||||||
|
"upcoming": {
|
||||||
|
"title": "Próximas cobranças",
|
||||||
|
"seeAll": "Ver todas",
|
||||||
|
"empty": "Nenhuma cobrança pendente por enquanto.",
|
||||||
|
"linkMp": "Vincule o Mercado Pago para cobrar",
|
||||||
|
"hint": "Você cria as cobranças na página de cada grupo."
|
||||||
|
},
|
||||||
|
"stats": {
|
||||||
|
"groups_one": "Grupo",
|
||||||
|
"groups_other": "Grupos",
|
||||||
|
"toCollect": "A receber",
|
||||||
|
"toCollectCount": "A receber · {{count}}",
|
||||||
|
"students_one": "Aluno",
|
||||||
|
"students_other": "Alunos"
|
||||||
|
},
|
||||||
|
"nextClass": {
|
||||||
|
"now": "Aula em andamento",
|
||||||
|
"next": "Próxima aula",
|
||||||
|
"nowBadge": "Acontecendo agora",
|
||||||
|
"seeGroup": "Ver grupo"
|
||||||
|
},
|
||||||
|
"today": {
|
||||||
|
"label": "Aula de hoje",
|
||||||
|
"attendanceTaken": "Presença registrada",
|
||||||
|
"time": "Hoje · {{time}}",
|
||||||
|
"enrolled_one": "{{count}} inscrito",
|
||||||
|
"enrolled_other": "{{count}} inscritos",
|
||||||
|
"slots_one": "{{count}} vaga disponível",
|
||||||
|
"slots_other": "{{count}} vagas disponíveis",
|
||||||
|
"seeAttendance": "Ver presença",
|
||||||
|
"takeAttendance": "Fazer chamada"
|
||||||
|
},
|
||||||
|
"attention": {
|
||||||
|
"title": "Para resolver",
|
||||||
|
"allGood": "Tudo certo: ninguém em risco, sem cobranças vencidas nem pré-inscrições.",
|
||||||
|
"overdue_one": "{{count}} cobrança vencida",
|
||||||
|
"overdue_other": "{{count}} cobranças vencidas",
|
||||||
|
"overdueHint": "Confira em Cobranças",
|
||||||
|
"preRegistrations_one": "{{count}} pré-inscrição para aprovar",
|
||||||
|
"preRegistrations_other": "{{count}} pré-inscrições para aprovar",
|
||||||
|
"moreAtRisk": "E mais {{count}} em risco. Veja as estatísticas de cada grupo."
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -37,11 +37,8 @@ function startOfDay(date: Date): number {
|
|||||||
export function formatRelativeDateTime(iso: string, now: Date = new Date()): string {
|
export function formatRelativeDateTime(iso: string, now: Date = new Date()): string {
|
||||||
const locale = i18n.language
|
const locale = i18n.language
|
||||||
const date = new Date(iso)
|
const date = new Date(iso)
|
||||||
const time = date.toLocaleTimeString(locale, {
|
// No hour cycle is forced: each language uses its own (24 h in es/pt, 12 h in en).
|
||||||
hour: '2-digit',
|
const time = date.toLocaleTimeString(locale, { hour: '2-digit', minute: '2-digit' })
|
||||||
minute: '2-digit',
|
|
||||||
hour12: false,
|
|
||||||
})
|
|
||||||
const diffDays = Math.round((startOfDay(date) - startOfDay(now)) / DAY_MS)
|
const diffDays = Math.round((startOfDay(date) - startOfDay(now)) / DAY_MS)
|
||||||
|
|
||||||
if (diffDays === 0) return i18n.t('common:relativeDay.today', { time })
|
if (diffDays === 0) return i18n.t('common:relativeDay.today', { time })
|
||||||
|
|||||||
Reference in New Issue
Block a user