diff --git a/apps/backend/test/student-alerts.test.ts b/apps/backend/test/student-alerts.test.ts
index d3a32ea..9fd216e 100644
--- a/apps/backend/test/student-alerts.test.ts
+++ b/apps/backend/test/student-alerts.test.ts
@@ -95,6 +95,8 @@ describe('computeStudentAlerts: pagos', () => {
gravedad: 'vigilar',
etiqueta: 'Cuota vencida',
detalle: 'La cuota de octubre venció el 10/10.',
+ razon: 'cuota',
+ valores: { cuotas: 1, vencimientos: ['2026-10-10T12:00:00.000Z'] },
firma: 'pay_1',
peso: 1,
},
diff --git a/apps/web/src/features/attention/AttentionCard.tsx b/apps/web/src/features/attention/AttentionCard.tsx
index 6e325e0..73abff8 100644
--- a/apps/web/src/features/attention/AttentionCard.tsx
+++ b/apps/web/src/features/attention/AttentionCard.tsx
@@ -1,8 +1,9 @@
import { Link } from '@tanstack/react-router'
import { Check } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
import { cn } from '../../lib/utils'
import { AlertTag } from './AlertTag'
-import { reminderMessage, whatsappLink, type AttentionItem } from './attention'
+import { alertDetail, alertLabel, reminderMessage, whatsappLink, type AttentionItem } from './attention'
import { SeverityAvatar } from './SeverityAvatar'
const ACTION_CLASS =
@@ -15,10 +16,12 @@ type AttentionCardProps = {
export function AttentionCard({ item, onResolve }: AttentionCardProps) {
const { student, alert } = item
+ const { t } = useTranslation('attention')
+ const label = alertLabel(alert)
const urgent = alert.gravedad === 'urgente'
const isPayment = alert.tipo === 'pago'
- const actionLabel = isPayment ? 'Enviar recordatorio' : 'Contactar'
+ const actionLabel = isPayment ? t('card.remind') : t('card.contact')
const href = whatsappLink(student, isPayment ? reminderMessage(student) : undefined)
// Urgent: light fill, the strongest action on screen. To watch: subtle gray.
const primaryTone = urgent
@@ -39,10 +42,10 @@ export function AttentionCard({ item, onResolve }: AttentionCardProps) {
{student.groupName}
- {alert.etiqueta}
+ {label}
- {alert.detalle}
+ {alertDetail(alert)}
{href ? (
@@ -50,7 +53,7 @@ export function AttentionCard({ item, onResolve }: AttentionCardProps) {
href={href}
target="_blank"
rel="noopener noreferrer"
- aria-label={`${actionLabel} a ${student.fullName} por WhatsApp`}
+ aria-label={t('card.actionWhatsapp', { action: actionLabel, name: student.fullName })}
className={cn(ACTION_CLASS, primaryTone)}
>
{actionLabel}
@@ -59,7 +62,7 @@ export function AttentionCard({ item, onResolve }: AttentionCardProps) {
diff --git a/apps/web/src/features/attention/AttentionHeader.tsx b/apps/web/src/features/attention/AttentionHeader.tsx
index 69e1ea2..b127db5 100644
--- a/apps/web/src/features/attention/AttentionHeader.tsx
+++ b/apps/web/src/features/attention/AttentionHeader.tsx
@@ -1,5 +1,6 @@
import { Link } from '@tanstack/react-router'
import { ArrowLeft, ListFilter } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
import { createPortal } from 'react-dom'
import { useImmersiveBarHost } from '../../context/ImmersiveBarProvider'
@@ -10,18 +11,19 @@ import { useImmersiveBarHost } from '../../context/ImmersiveBarProvider'
sticky box, like `LargeTitle`. */
export function AttentionHeader({ subtitle }: { subtitle: string }) {
const host = useImmersiveBarHost()
+ const { t } = useTranslation('attention')
const bar = (
-
Requiere atención
+
{t('title')}
{subtitle}
@@ -29,7 +31,7 @@ export function AttentionHeader({ subtitle }: { subtitle: string }) {
{/* TODO: ordenar/filtrar por grupo. Por ahora no hace nada. */}
diff --git a/apps/web/src/features/attention/AttentionProvider.tsx b/apps/web/src/features/attention/AttentionProvider.tsx
index c988e84..b025be6 100644
--- a/apps/web/src/features/attention/AttentionProvider.tsx
+++ b/apps/web/src/features/attention/AttentionProvider.tsx
@@ -2,6 +2,7 @@ import { createContext, useContext, useMemo, useState } from 'react'
import type { ReactNode } from 'react'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import type { AttentionOverview, StudentAlert } from '@gruperly/shared'
+import { i18n } from '../../i18n/instance'
import { useToast } from '../../components/ui'
import { resolveAlert } from '../../lib/api'
import {
@@ -49,7 +50,7 @@ export function AttentionProvider({ children }: { children: ReactNode }) {
},
onError: (_error, _variables, context) => {
if (context?.previous) queryClient.setQueryData(attentionQueryOptions.queryKey, context.previous)
- toast.error('No pudimos marcarlo como resuelto. Probá de nuevo.')
+ toast.error(i18n.t('attention:card.resolveError'))
},
onSettled: () => {
void queryClient.invalidateQueries({ queryKey: attentionQueryOptions.queryKey })
diff --git a/apps/web/src/features/attention/AttentionSection.tsx b/apps/web/src/features/attention/AttentionSection.tsx
index cefebfe..11c9c22 100644
--- a/apps/web/src/features/attention/AttentionSection.tsx
+++ b/apps/web/src/features/attention/AttentionSection.tsx
@@ -1,11 +1,12 @@
import type { StudentAlertSeverity } from '@gruperly/shared'
+import { useTranslation } from 'react-i18next'
import { cn } from '../../lib/utils'
import { AttentionCard } from './AttentionCard'
import type { AttentionItem } from './attention'
-const SECTIONS: Record = {
- urgente: { title: 'Urgente', dot: 'bg-alert-urgent-ring', text: 'text-alert-urgent-fg' },
- vigilar: { title: 'A vigilar', dot: 'bg-alert-watch-ring', text: 'text-alert-watch-fg' },
+const SECTIONS: Record = {
+ urgente: { dot: 'bg-alert-urgent-ring', text: 'text-alert-urgent-fg' },
+ vigilar: { dot: 'bg-alert-watch-ring', text: 'text-alert-watch-fg' },
}
type AttentionSectionProps = {
@@ -16,6 +17,7 @@ type AttentionSectionProps = {
/** One severity block. Not rendered when it is empty. */
export function AttentionSection({ severity, items, onResolve }: AttentionSectionProps) {
+ const { t } = useTranslation('attention')
if (items.length === 0) return null
const section = SECTIONS[severity]
const headingId = `attention-${severity}`
@@ -27,7 +29,7 @@ export function AttentionSection({ severity, items, onResolve }: AttentionSectio
className={cn('flex items-center gap-2 text-xs font-semibold tracking-wider uppercase', section.text)}
>
- {section.title}
+ {t(`sections.${severity}`)}
·
{items.length}
diff --git a/apps/web/src/features/attention/AttentionView.tsx b/apps/web/src/features/attention/AttentionView.tsx
index 8a20037..0f45cbc 100644
--- a/apps/web/src/features/attention/AttentionView.tsx
+++ b/apps/web/src/features/attention/AttentionView.tsx
@@ -1,4 +1,5 @@
import { Loader2 } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
import { Button } from '../../components/ui'
import { AttentionHeader } from './AttentionHeader'
import { AttentionSection } from './AttentionSection'
@@ -9,6 +10,7 @@ import { FilterChips } from './FilterChips'
export function AttentionView() {
const { items, isPending, isError, retry, filter, setFilter, resolve } = useAttention()
+ const { t } = useTranslation(['attention', 'common'])
const visible = filterItems(items, filter)
const { urgente, vigilar } = itemsBySeverity(visible)
@@ -16,7 +18,7 @@ export function AttentionView() {
return (
-
+
{/* The chips stay under the bar (56px) while the cards scroll. */}
@@ -26,13 +28,13 @@ export function AttentionView() {
{isPending ? (
- Cargando alertas
+ {t('loadingAlerts')}
) : isError ? (
-
No pudimos cargar las alertas.
+
{t('loadError')}
- Reintentar
+ {t('common:actions.retry')}
) : visible.length === 0 ? (
diff --git a/apps/web/src/features/attention/EmptyAttention.tsx b/apps/web/src/features/attention/EmptyAttention.tsx
index f14d1f0..90531b9 100644
--- a/apps/web/src/features/attention/EmptyAttention.tsx
+++ b/apps/web/src/features/attention/EmptyAttention.tsx
@@ -1,14 +1,16 @@
import { Check } from 'lucide-react'
+import { useTranslation } from 'react-i18next'
export function EmptyAttention() {
+ const { t } = useTranslation('attention')
return (
-
Todo en orden
+
{t('empty.title')}
- No hay alumnos que requieran atención en este filtro.
+ {t('empty.description')}
)
diff --git a/apps/web/src/features/attention/FilterChips.tsx b/apps/web/src/features/attention/FilterChips.tsx
index ad6938c..7e86600 100644
--- a/apps/web/src/features/attention/FilterChips.tsx
+++ b/apps/web/src/features/attention/FilterChips.tsx
@@ -1,3 +1,4 @@
+import { useTranslation } from 'react-i18next'
import { cn } from '../../lib/utils'
import { ATTENTION_FILTERS, type AttentionFilter } from './attention'
@@ -8,16 +9,17 @@ type FilterChipsProps = {
}
export function FilterChips({ value, counts, onChange }: FilterChipsProps) {
+ const { t } = useTranslation('attention')
return (
-
+
{ATTENTION_FILTERS.map((filter) => {
- const active = filter.id === value
+ const active = filter === value
return (
onChange(filter.id)}
+ onClick={() => onChange(filter)}
className={cn(
'inline-flex min-h-11 shrink-0 items-center gap-1.5 rounded-full border px-4 text-sm font-semibold transition-colors focus-visible:ring-2 focus-visible:ring-accent focus-visible:outline-none motion-reduce:transition-none',
active
@@ -25,9 +27,9 @@ export function FilterChips({ value, counts, onChange }: FilterChipsProps) {
: 'border-border bg-surface text-primary hover:bg-primary-soft',
)}
>
- {filter.label}
+ {t(`filters.${filter}`)}
- {counts[filter.id]}
+ {counts[filter]}
)
diff --git a/apps/web/src/features/attention/attention.ts b/apps/web/src/features/attention/attention.ts
index 78431fe..f4d2f26 100644
--- a/apps/web/src/features/attention/attention.ts
+++ b/apps/web/src/features/attention/attention.ts
@@ -7,6 +7,7 @@ import type {
StudentAlertType,
} from '@gruperly/shared'
import { compareAlerts, compareByWorstAlert, worstAlert } from '@gruperly/shared'
+import { i18n } from '../../i18n/instance'
import { formatPrice } from '../../lib/format'
/* Derivations for "Requiere atención" (the Grupos preview and the "Ver todos"
@@ -16,11 +17,8 @@ import { formatPrice } from '../../lib/format'
export type AttentionFilter = 'todos' | StudentAlertType
-export const ATTENTION_FILTERS: { id: AttentionFilter; label: string }[] = [
- { id: 'todos', label: 'Todos' },
- { id: 'asistencia', label: 'Asistencia' },
- { id: 'pago', label: 'Pagos' },
-]
+/** Labels: `attention:filters.
`. */
+export const ATTENTION_FILTERS: AttentionFilter[] = ['todos', 'asistencia', 'pago']
/** A student with at least one alert, with their group. */
export type FlaggedStudent = AttentionMember & {
@@ -77,12 +75,12 @@ export function itemsBySeverity(items: AttentionItem[]): Record item.student.attendeeId))
- if (students.size === 0) return 'Nada pendiente'
+ if (students.size === 0) return i18n.t('attention:subtitle.none')
const urgent = new Set(
items.filter((item) => item.alert.gravedad === 'urgente').map((item) => item.student.attendeeId),
)
- const parts = [`${students.size} ${students.size === 1 ? 'alumno' : 'alumnos'}`]
- if (urgent.size > 0) parts.push(`${urgent.size} ${urgent.size === 1 ? 'urgente' : 'urgentes'}`)
+ const parts = [i18n.t('attention:subtitle.students', { count: students.size })]
+ if (urgent.size > 0) parts.push(i18n.t('attention:subtitle.urgent', { count: urgent.size }))
return parts.join(' · ')
}
@@ -119,17 +117,74 @@ export function reminderMessage(student: FlaggedStudent): string {
const amount = formatPrice(total, payments[0]?.currency)
const owed =
payments.length === 1
- ? `la cuota de ${student.groupName} (${amount}) que venció el ${shortDate(payments[0].dueDate)}`
- : `${payments.length} cuotas de ${student.groupName} (${amount} en total)`
+ ? i18n.t('attention:reminder.one', { group: student.groupName, amount, date: shortDate(payments[0].dueDate) })
+ : i18n.t('attention:reminder.many', { count: payments.length, group: student.groupName, amount })
const link = payments.find((payment) => payment.checkoutUrl)?.checkoutUrl
return (
- `¡Hola ${firstName}! 👋 Te escribo para recordarte que quedó pendiente ${owed}.` +
- (link ? ` Podés pagar acá: ${link}` : '') +
- ' Cualquier cosa, avisame.'
+ i18n.t('attention:reminder.message', { name: firstName, owed }) +
+ (link ? i18n.t('attention:reminder.pay', { link }) : '') +
+ i18n.t('attention:reminder.closing')
)
}
+/* Due dates are calendar days sent at 12:00 UTC: read in UTC so the day doesn't
+ shift with the time zone. */
function shortDate(iso: string): string {
- const date = new Date(iso)
- return `${date.getUTCDate()}/${date.getUTCMonth() + 1}`
+ return new Intl.DateTimeFormat(i18n.language, { day: 'numeric', month: 'numeric', timeZone: 'UTC' }).format(
+ new Date(iso),
+ )
+}
+
+function monthName(iso: string): string {
+ return new Intl.DateTimeFormat(i18n.language, { month: 'long', timeZone: 'UTC' }).format(new Date(iso))
+}
+
+/** The alert's short tag ("4 faltas") in the UI language. Alerts without
+ * `razon` (older API) keep the Spanish `etiqueta`. */
+export function alertLabel(alert: StudentAlert): string {
+ const values = alert.valores ?? {}
+ switch (alert.razon) {
+ case 'racha':
+ return i18n.t('attention:alert.racha', { count: values.faltas })
+ case 'ventana':
+ case 'ultimas':
+ return i18n.t('attention:alert.ventana', { count: values.faltas })
+ case 'cuotas':
+ return i18n.t('attention:alert.cuotas', { count: values.cuotas })
+ case 'cuota':
+ return i18n.t('attention:alert.cuota')
+ default:
+ return alert.etiqueta
+ }
+}
+
+/** The alert's sentence ("Faltó a 4 de las últimas 6 clases.") in the UI language. */
+export function alertDetail(alert: StudentAlert): string {
+ const values = alert.valores ?? {}
+ const dueDates = values.vencimientos ?? []
+ switch (alert.razon) {
+ case 'racha':
+ return i18n.t('attention:alert.rachaDetail', { count: values.faltas })
+ case 'ventana':
+ return i18n.t('attention:alert.ventanaDetail', { count: values.faltas, classes: values.clases })
+ case 'ultimas':
+ return i18n.t('attention:alert.ultimasDetail', { count: values.faltas })
+ case 'cuotas': {
+ // Two fees in the same month (a re-created link) would read "las cuotas
+ // de octubre": fall back to the count.
+ const months = [...new Set(dueDates.map(monthName))]
+ if (months.length === dueDates.length && months.length > 0) {
+ const list = new Intl.ListFormat(i18n.language, { type: 'conjunction' }).format(months)
+ return i18n.t('attention:alert.cuotasMonthsDetail', { months: list })
+ }
+ return i18n.t('attention:alert.cuotasDetail', { count: values.cuotas })
+ }
+ case 'cuota': {
+ const [dueDate] = dueDates
+ if (!dueDate) return alert.detalle
+ return i18n.t('attention:alert.cuotaDetail', { month: monthName(dueDate), date: shortDate(dueDate) })
+ }
+ default:
+ return alert.detalle
+ }
}
diff --git a/apps/web/src/features/groups/AttentionPreview.tsx b/apps/web/src/features/groups/AttentionPreview.tsx
index e862f46..6265dad 100644
--- a/apps/web/src/features/groups/AttentionPreview.tsx
+++ b/apps/web/src/features/groups/AttentionPreview.tsx
@@ -2,7 +2,7 @@ import { Link } from '@tanstack/react-router'
import { ChevronRight } from 'lucide-react'
import { useTranslation } from 'react-i18next'
import { AlertTag } from '../attention/AlertTag'
-import type { FlaggedStudent } from '../attention/attention'
+import { alertLabel, type FlaggedStudent } from '../attention/attention'
import { SeverityAvatar } from '../attention/SeverityAvatar'
const PREVIEW_LIMIT = 4
@@ -54,7 +54,7 @@ export function AttentionPreview({ students }: { students: FlaggedStudent[] }) {
{student.groupName}
{student.worst.gravedad === 'urgente' ? t('attentionPreview.urgent') : t('attentionPreview.watch')}
- {student.worst.etiqueta}
+ {alertLabel(student.worst)}
))}
diff --git a/apps/web/src/i18n/i18next.d.ts b/apps/web/src/i18n/i18next.d.ts
index 8ae1a65..3077148 100644
--- a/apps/web/src/i18n/i18next.d.ts
+++ b/apps/web/src/i18n/i18next.d.ts
@@ -10,6 +10,7 @@ import type groups from './locales/es-AR/groups.json'
import type groupDetail from './locales/es-AR/groupDetail.json'
import type groupAdd from './locales/es-AR/groupAdd.json'
import type analytics from './locales/es-AR/analytics.json'
+import type attention from './locales/es-AR/attention.json'
import type validation from './locales/es-AR/validation.json'
// es-AR es la fuente: una clave que no exista ahí rompe el typecheck.
@@ -24,6 +25,7 @@ declare module 'i18next' {
pwa: typeof pwa
settings: typeof settings
validation: typeof validation
+ 'attention': typeof attention
'analytics': typeof analytics
'groupAdd': typeof groupAdd
'groupDetail': typeof groupDetail
diff --git a/apps/web/src/i18n/locales/en/attention.json b/apps/web/src/i18n/locales/en/attention.json
new file mode 100644
index 0000000..6c3e21c
--- /dev/null
+++ b/apps/web/src/i18n/locales/en/attention.json
@@ -0,0 +1,57 @@
+{
+ "title": "Needs attention",
+ "back": "Back",
+ "sortFilter": "Sort and filter",
+ "loading": "Loading…",
+ "loadingAlerts": "Loading alerts",
+ "loadError": "We couldn't load the alerts.",
+ "subtitle": {
+ "none": "Nothing pending",
+ "students_one": "{{count}} student",
+ "students_other": "{{count}} students",
+ "urgent_one": "{{count}} urgent",
+ "urgent_other": "{{count}} urgent"
+ },
+ "filters": {
+ "label": "Filter alerts",
+ "todos": "All",
+ "asistencia": "Attendance",
+ "pago": "Payments"
+ },
+ "sections": {
+ "urgente": "Urgent",
+ "vigilar": "Watch"
+ },
+ "empty": {
+ "title": "All good",
+ "description": "No students need attention in this filter."
+ },
+ "card": {
+ "remind": "Send reminder",
+ "contact": "Contact",
+ "actionWhatsapp": "{{action}} {{name}} on WhatsApp",
+ "noPhone": "{{action}}: {{name}} has no phone on file",
+ "resolve": "Resolved",
+ "resolveLabel": "Mark as resolved: {{name}}, {{alert}}",
+ "resolveError": "We couldn't mark it as resolved. Please try again."
+ },
+ "alert": {
+ "racha": "{{count}} in a row",
+ "rachaDetail": "Hasn't come for {{count}} classes in a row.",
+ "ventana": "{{count}} absences",
+ "ventanaDetail": "Missed {{count}} of the last {{classes}} classes.",
+ "ultimasDetail": "Missed the last {{count}} classes.",
+ "cuotas": "{{count}} fees",
+ "cuotasDetail": "Owes {{count}} overdue fees.",
+ "cuotasMonthsDetail": "Owes the fees for {{months}}.",
+ "cuota": "Overdue fee",
+ "cuotaDetail": "The {{month}} fee was due on {{date}}."
+ },
+ "reminder": {
+ "one": "the {{group}} fee ({{amount}}) that was due on {{date}}",
+ "many": "{{count}} {{group}} fees ({{amount}} in total)",
+ "message": "Hi {{name}}! 👋 Just a reminder that {{owed}} is still pending.",
+ "pay": " You can pay here: {{link}}",
+ "closing": " Let me know if you have any questions."
+ }
+}
diff --git a/apps/web/src/i18n/locales/es-419/attention.json b/apps/web/src/i18n/locales/es-419/attention.json
new file mode 100644
index 0000000..6d16f87
--- /dev/null
+++ b/apps/web/src/i18n/locales/es-419/attention.json
@@ -0,0 +1,57 @@
+{
+ "title": "Requiere atención",
+ "back": "Volver",
+ "sortFilter": "Ordenar y filtrar",
+ "loading": "Cargando…",
+ "loadingAlerts": "Cargando alertas",
+ "loadError": "No pudimos cargar las alertas.",
+ "subtitle": {
+ "none": "Nada pendiente",
+ "students_one": "{{count}} alumno",
+ "students_other": "{{count}} alumnos",
+ "urgent_one": "{{count}} urgente",
+ "urgent_other": "{{count}} urgentes"
+ },
+ "filters": {
+ "label": "Filtrar alertas",
+ "todos": "Todos",
+ "asistencia": "Asistencia",
+ "pago": "Pagos"
+ },
+ "sections": {
+ "urgente": "Urgente",
+ "vigilar": "Para vigilar"
+ },
+ "empty": {
+ "title": "Todo en orden",
+ "description": "No hay alumnos que requieran atención en este filtro."
+ },
+ "card": {
+ "remind": "Enviar recordatorio",
+ "contact": "Contactar",
+ "actionWhatsapp": "{{action}} a {{name}} por WhatsApp",
+ "noPhone": "{{action}}: {{name}} no tiene teléfono cargado",
+ "resolve": "Resuelto",
+ "resolveLabel": "Marcar como resuelto: {{name}}, {{alert}}",
+ "resolveError": "No pudimos marcarlo como resuelto. Inténtalo de nuevo."
+ },
+ "alert": {
+ "racha": "{{count}} seguidas",
+ "rachaDetail": "No viene hace {{count}} clases seguidas.",
+ "ventana": "{{count}} faltas",
+ "ventanaDetail": "Faltó a {{count}} de las últimas {{classes}} clases.",
+ "ultimasDetail": "Faltó a las últimas {{count}} clases.",
+ "cuotas": "{{count}} cuotas",
+ "cuotasDetail": "Debe {{count}} cuotas vencidas.",
+ "cuotasMonthsDetail": "Debe las cuotas de {{months}}.",
+ "cuota": "Cuota vencida",
+ "cuotaDetail": "La cuota de {{month}} venció el {{date}}."
+ },
+ "reminder": {
+ "one": "la cuota de {{group}} ({{amount}}) que venció el {{date}}",
+ "many": "{{count}} cuotas de {{group}} ({{amount}} en total)",
+ "message": "¡Hola {{name}}! 👋 Te escribo para recordarte que quedó pendiente {{owed}}.",
+ "pay": " Puedes pagar aquí: {{link}}",
+ "closing": " Cualquier cosa, avísame."
+ }
+}
diff --git a/apps/web/src/i18n/locales/es-AR/attention.json b/apps/web/src/i18n/locales/es-AR/attention.json
new file mode 100644
index 0000000..7fd4fc8
--- /dev/null
+++ b/apps/web/src/i18n/locales/es-AR/attention.json
@@ -0,0 +1,57 @@
+{
+ "title": "Requiere atención",
+ "back": "Volver",
+ "sortFilter": "Ordenar y filtrar",
+ "loading": "Cargando…",
+ "loadingAlerts": "Cargando alertas",
+ "loadError": "No pudimos cargar las alertas.",
+ "subtitle": {
+ "none": "Nada pendiente",
+ "students_one": "{{count}} alumno",
+ "students_other": "{{count}} alumnos",
+ "urgent_one": "{{count}} urgente",
+ "urgent_other": "{{count}} urgentes"
+ },
+ "filters": {
+ "label": "Filtrar alertas",
+ "todos": "Todos",
+ "asistencia": "Asistencia",
+ "pago": "Pagos"
+ },
+ "sections": {
+ "urgente": "Urgente",
+ "vigilar": "A vigilar"
+ },
+ "empty": {
+ "title": "Todo en orden",
+ "description": "No hay alumnos que requieran atención en este filtro."
+ },
+ "card": {
+ "remind": "Enviar recordatorio",
+ "contact": "Contactar",
+ "actionWhatsapp": "{{action}} a {{name}} por WhatsApp",
+ "noPhone": "{{action}}: {{name}} no tiene teléfono cargado",
+ "resolve": "Resuelto",
+ "resolveLabel": "Marcar como resuelto: {{name}}, {{alert}}",
+ "resolveError": "No pudimos marcarlo como resuelto. Probá de nuevo."
+ },
+ "alert": {
+ "racha": "{{count}} seguidas",
+ "rachaDetail": "No viene hace {{count}} clases seguidas.",
+ "ventana": "{{count}} faltas",
+ "ventanaDetail": "Faltó a {{count}} de las últimas {{classes}} clases.",
+ "ultimasDetail": "Faltó a las últimas {{count}} clases.",
+ "cuotas": "{{count}} cuotas",
+ "cuotasDetail": "Debe {{count}} cuotas vencidas.",
+ "cuotasMonthsDetail": "Debe las cuotas de {{months}}.",
+ "cuota": "Cuota vencida",
+ "cuotaDetail": "La cuota de {{month}} venció el {{date}}."
+ },
+ "reminder": {
+ "one": "la cuota de {{group}} ({{amount}}) que venció el {{date}}",
+ "many": "{{count}} cuotas de {{group}} ({{amount}} en total)",
+ "message": "¡Hola {{name}}! 👋 Te escribo para recordarte que quedó pendiente {{owed}}.",
+ "pay": " Podés pagar acá: {{link}}",
+ "closing": " Cualquier cosa, avisame."
+ }
+}
diff --git a/apps/web/src/i18n/locales/pt-BR/attention.json b/apps/web/src/i18n/locales/pt-BR/attention.json
new file mode 100644
index 0000000..fc82b1f
--- /dev/null
+++ b/apps/web/src/i18n/locales/pt-BR/attention.json
@@ -0,0 +1,57 @@
+{
+ "title": "Precisa de atenção",
+ "back": "Voltar",
+ "sortFilter": "Ordenar e filtrar",
+ "loading": "Carregando…",
+ "loadingAlerts": "Carregando alertas",
+ "loadError": "Não conseguimos carregar os alertas.",
+ "subtitle": {
+ "none": "Nada pendente",
+ "students_one": "{{count}} aluno",
+ "students_other": "{{count}} alunos",
+ "urgent_one": "{{count}} urgente",
+ "urgent_other": "{{count}} urgentes"
+ },
+ "filters": {
+ "label": "Filtrar alertas",
+ "todos": "Todos",
+ "asistencia": "Presença",
+ "pago": "Pagamentos"
+ },
+ "sections": {
+ "urgente": "Urgente",
+ "vigilar": "Atenção"
+ },
+ "empty": {
+ "title": "Tudo certo",
+ "description": "Nenhum aluno precisa de atenção neste filtro."
+ },
+ "card": {
+ "remind": "Enviar lembrete",
+ "contact": "Contatar",
+ "actionWhatsapp": "{{action}} {{name}} pelo WhatsApp",
+ "noPhone": "{{action}}: {{name}} não tem telefone cadastrado",
+ "resolve": "Resolvido",
+ "resolveLabel": "Marcar como resolvido: {{name}}, {{alert}}",
+ "resolveError": "Não conseguimos marcar como resolvido. Tente novamente."
+ },
+ "alert": {
+ "racha": "{{count}} seguidas",
+ "rachaDetail": "Não vem há {{count}} aulas seguidas.",
+ "ventana": "{{count}} faltas",
+ "ventanaDetail": "Faltou a {{count}} das últimas {{classes}} aulas.",
+ "ultimasDetail": "Faltou às últimas {{count}} aulas.",
+ "cuotas": "{{count}} parcelas",
+ "cuotasDetail": "Deve {{count}} parcelas vencidas.",
+ "cuotasMonthsDetail": "Deve as parcelas de {{months}}.",
+ "cuota": "Parcela vencida",
+ "cuotaDetail": "A parcela de {{month}} venceu em {{date}}."
+ },
+ "reminder": {
+ "one": "a mensalidade de {{group}} ({{amount}}) que venceu em {{date}}",
+ "many": "{{count}} mensalidades de {{group}} ({{amount}} no total)",
+ "message": "Olá, {{name}}! 👋 Passando para lembrar que ficou pendente {{owed}}.",
+ "pay": " Você pode pagar aqui: {{link}}",
+ "closing": " Qualquer coisa, me avise."
+ }
+}
diff --git a/packages/shared/src/lib/student-alerts.ts b/packages/shared/src/lib/student-alerts.ts
index 154a11f..8dd57f6 100644
--- a/packages/shared/src/lib/student-alerts.ts
+++ b/packages/shared/src/lib/student-alerts.ts
@@ -63,6 +63,8 @@ function attendanceAlert(member: MemberAttendance, now: Date): StudentAlert | nu
gravedad: 'urgente',
etiqueta: `${streak} seguidas`,
detalle: `No viene hace ${streak} clases seguidas.`,
+ razon: 'racha',
+ valores: { faltas: streak },
firma,
peso: streak,
};
@@ -72,6 +74,8 @@ function attendanceAlert(member: MemberAttendance, now: Date): StudentAlert | nu
gravedad: 'urgente',
etiqueta: `${highWindow.absences} faltas`,
detalle: `Faltó a ${highWindow.absences} de las últimas ${highWindow.classes} clases.`,
+ razon: 'ventana',
+ valores: { faltas: highWindow.absences, clases: highWindow.classes },
firma,
peso: highWindow.absences,
};
@@ -87,6 +91,8 @@ function attendanceAlert(member: MemberAttendance, now: Date): StudentAlert | nu
absences === streak
? `Faltó a las últimas ${absences} clases.`
: `Faltó a ${absences} de las últimas ${classes} clases.`,
+ razon: absences === streak ? 'ultimas' : 'ventana',
+ valores: { faltas: absences, clases: classes },
firma,
peso: absences,
};
@@ -111,6 +117,8 @@ function paymentAlert(payments: StudentAlertInput['overduePayments']): StudentAl
months.length === count
? `Debe las cuotas de ${joinList(months)}.`
: `Debe ${count} cuotas vencidas.`,
+ razon: 'cuotas',
+ valores: { cuotas: count, vencimientos: sorted.map((payment) => payment.dueDate) },
firma,
peso: count,
};
@@ -122,6 +130,8 @@ function paymentAlert(payments: StudentAlertInput['overduePayments']): StudentAl
gravedad: 'vigilar',
etiqueta: 'Cuota vencida',
detalle: `La cuota de ${monthName(payment.dueDate)} venció el ${dayMonth(payment.dueDate)}.`,
+ razon: 'cuota',
+ valores: { cuotas: 1, vencimientos: [payment.dueDate] },
firma,
peso: count,
};
diff --git a/packages/shared/src/schemas/attention.ts b/packages/shared/src/schemas/attention.ts
index 1e5a4f7..f76c761 100644
--- a/packages/shared/src/schemas/attention.ts
+++ b/packages/shared/src/schemas/attention.ts
@@ -12,6 +12,30 @@ export type StudentAlertType = z.output;
export const studentAlertSeveritySchema = z.enum(['urgente', 'vigilar']);
export type StudentAlertSeverity = z.output;
+/** Why the alert fired, so a client can word it in its own language
+ * (`etiqueta`/`detalle` keep the Spanish wording). */
+export const studentAlertReasonSchema = z.enum([
+ /** N absences in a row (`faltas`). */
+ 'racha',
+ /** `faltas` out of the last `clases`. */
+ 'ventana',
+ /** The last `faltas` classes (window == streak). */
+ 'ultimas',
+ /** Two or more overdue fees (`cuotas`, `vencimientos`). */
+ 'cuotas',
+ /** One overdue fee (`vencimientos[0]`). */
+ 'cuota',
+]);
+export type StudentAlertReason = z.output;
+
+export const StudentAlertValuesSchema = z.object({
+ faltas: z.number().int().optional(),
+ clases: z.number().int().optional(),
+ cuotas: z.number().int().optional(),
+ /** Due dates (ISO) of the overdue fees, oldest first. */
+ vencimientos: z.array(z.string()).optional(),
+});
+
export const StudentAlertSchema = z.object({
tipo: studentAlertTypeSchema,
gravedad: studentAlertSeveritySchema,
@@ -19,6 +43,8 @@ export const StudentAlertSchema = z.object({
etiqueta: z.string(),
/** Natural-language line: "Faltó a 4 de las últimas 6 clases." */
detalle: z.string(),
+ razon: studentAlertReasonSchema.optional(),
+ valores: StudentAlertValuesSchema.optional(),
/** What the alert is about (last absence / overdue payments). "Resuelto"
* stores it, so a new absence or a new overdue fee brings the alert back. */
firma: z.string(),