feat(i18n): traducir la ficha del alumno

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Jose Selesan
2026-11-03 12:30:11 -03:00
parent ecdbbbbca6
commit 8a5768e0c0
27 changed files with 856 additions and 164 deletions

View File

@@ -1,6 +1,7 @@
import type { AttendeePaymentSummary } from '@gruperly/shared'
import { UpdateAttendeeSchema } from '@gruperly/shared'
import { validationMessage } from '../../i18n/validation'
import { i18n } from '../../i18n/instance'
export function contactEmailError(email: string): string | null {
const result = UpdateAttendeeSchema.safeParse({ email })
@@ -21,47 +22,50 @@ export function paymentPresentation(
): PaymentPresentation {
const periodLabel = capitalize(formatMonthAndYear(today))
if (!payment) {
return { periodLabel, statusLabel: 'Sin cobro registrado', chipLabel: 'Al día', isDue: false }
return {
periodLabel,
statusLabel: i18n.t('attendeeDetail:payments.noCharge'),
chipLabel: i18n.t('attendeeDetail:payments.upToDate'),
isDue: false,
}
}
const isDue = payment.status === 'PENDING' || payment.status === 'OVERDUE'
return {
periodLabel,
statusLabel: paymentStatusLabel(payment.status),
chipLabel: isDue ? `Debe ${formatMonth(new Date(payment.dueDate))}` : 'Al día',
chipLabel: isDue
? i18n.t('attendeeDetail:payments.owes', { month: formatMonth(new Date(payment.dueDate)) })
: i18n.t('attendeeDetail:payments.upToDate'),
isDue,
}
}
export function formatNotesUpdatedAt(updatedAt: string, today = new Date()): string {
const date = new Date(updatedAt)
if (sameCalendarDate(date, today)) return 'Editado hoy'
return `Editado ${date.toLocaleDateString('es-MX', {
day: 'numeric',
month: 'short',
year: 'numeric',
})}`
if (sameCalendarDate(date, today)) return i18n.t('attendeeDetail:notes.editedToday')
return i18n.t('attendeeDetail:notes.edited', {
date: date.toLocaleDateString(i18n.language, { day: 'numeric', month: 'short', year: 'numeric' }),
})
}
function paymentStatusLabel(status: AttendeePaymentSummary['status']): string {
switch (status) {
case 'PAID':
return 'Pagado'
case 'OVERDUE':
return 'Vencido'
case 'CANCELLED':
return 'Cancelado'
return i18n.t(`common:paymentStatus.${status}`)
default:
return 'Pendiente'
return i18n.t('common:paymentStatus.PENDING')
}
}
function formatMonth(date: Date): string {
return date.toLocaleDateString('es-MX', { month: 'long' })
return date.toLocaleDateString(i18n.language, { month: 'long' })
}
function formatMonthAndYear(date: Date): string {
const parts = new Intl.DateTimeFormat('es-MX', { month: 'long', year: 'numeric' }).formatToParts(date)
const parts = new Intl.DateTimeFormat(i18n.language, { month: 'long', year: 'numeric' }).formatToParts(date)
const month = parts.find((part) => part.type === 'month')?.value ?? ''
const year = parts.find((part) => part.type === 'year')?.value ?? ''
return `${month} ${year}`.trim()