development #14
@@ -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,
|
||||
},
|
||||
|
||||
@@ -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) {
|
||||
</Link>
|
||||
<p className="truncate text-sm text-secondary">{student.groupName}</p>
|
||||
</div>
|
||||
<AlertTag severity={alert.gravedad}>{alert.etiqueta}</AlertTag>
|
||||
<AlertTag severity={alert.gravedad}>{label}</AlertTag>
|
||||
</div>
|
||||
|
||||
<p className="mt-3 text-sm text-primary">{alert.detalle}</p>
|
||||
<p className="mt-3 text-sm text-primary">{alertDetail(alert)}</p>
|
||||
|
||||
<div className="mt-3 grid grid-cols-2 gap-2">
|
||||
{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) {
|
||||
<button
|
||||
type="button"
|
||||
disabled
|
||||
aria-label={`${actionLabel}: ${student.fullName} no tiene teléfono cargado`}
|
||||
aria-label={t('card.noPhone', { action: actionLabel, name: student.fullName })}
|
||||
className={cn(ACTION_CLASS, primaryTone, 'cursor-not-allowed opacity-45')}
|
||||
>
|
||||
{actionLabel}
|
||||
@@ -68,11 +71,11 @@ export function AttentionCard({ item, onResolve }: AttentionCardProps) {
|
||||
<button
|
||||
type="button"
|
||||
onClick={onResolve}
|
||||
aria-label={`Marcar como resuelto: ${student.fullName}, ${alert.etiqueta}`}
|
||||
aria-label={t('card.resolveLabel', { name: student.fullName, alert: label })}
|
||||
className={cn(ACTION_CLASS, 'border border-border text-primary hover:bg-primary-soft')}
|
||||
>
|
||||
<Check className="size-4" aria-hidden="true" />
|
||||
Resuelto
|
||||
{t('card.resolve')}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
@@ -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 = (
|
||||
<div className="flex h-full items-center gap-1 border-b border-border bg-background/90 px-2 backdrop-blur-md lg:px-0">
|
||||
<Link
|
||||
to="/groups"
|
||||
aria-label="Volver"
|
||||
aria-label={t('back')}
|
||||
className="inline-flex size-11 shrink-0 items-center justify-center rounded-xl text-primary hover:bg-primary-soft focus-visible:ring-2 focus-visible:ring-accent focus-visible:outline-none"
|
||||
>
|
||||
<ArrowLeft className="size-5" aria-hidden="true" />
|
||||
</Link>
|
||||
<div className="min-w-0 flex-1 px-1">
|
||||
<h1 className="truncate text-base leading-tight font-semibold text-primary">Requiere atención</h1>
|
||||
<h1 className="truncate text-base leading-tight font-semibold text-primary">{t('title')}</h1>
|
||||
<p className="truncate text-xs text-secondary" aria-live="polite">
|
||||
{subtitle}
|
||||
</p>
|
||||
@@ -29,7 +31,7 @@ export function AttentionHeader({ subtitle }: { subtitle: string }) {
|
||||
{/* TODO: ordenar/filtrar por grupo. Por ahora no hace nada. */}
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Ordenar y filtrar"
|
||||
aria-label={t('sortFilter')}
|
||||
className="inline-flex size-11 shrink-0 items-center justify-center rounded-xl text-secondary hover:bg-primary-soft focus-visible:ring-2 focus-visible:ring-accent focus-visible:outline-none"
|
||||
>
|
||||
<ListFilter className="size-5" aria-hidden="true" />
|
||||
|
||||
@@ -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 })
|
||||
|
||||
@@ -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<StudentAlertSeverity, { title: string; dot: string; text: string }> = {
|
||||
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<StudentAlertSeverity, { dot: string; text: string }> = {
|
||||
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)}
|
||||
>
|
||||
<span className={cn('size-2 rounded-full', section.dot)} aria-hidden="true" />
|
||||
{section.title}
|
||||
{t(`sections.${severity}`)}
|
||||
<span aria-hidden="true">·</span>
|
||||
<span className="tabular-nums">{items.length}</span>
|
||||
</h2>
|
||||
|
||||
@@ -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 (
|
||||
<section className="pb-6">
|
||||
<AttentionHeader subtitle={isPending ? 'Cargando…' : attentionSubtitle(items)} />
|
||||
<AttentionHeader subtitle={isPending ? t('loading') : attentionSubtitle(items)} />
|
||||
|
||||
{/* The chips stay under the bar (56px) while the cards scroll. */}
|
||||
<div className="sticky top-14 z-30 -mx-4 bg-background px-4 lg:mx-0 lg:px-0">
|
||||
@@ -26,13 +28,13 @@ export function AttentionView() {
|
||||
{isPending ? (
|
||||
<div className="flex items-center justify-center py-16" role="status">
|
||||
<Loader2 className="size-6 animate-spin text-secondary/50" aria-hidden="true" />
|
||||
<span className="sr-only">Cargando alertas</span>
|
||||
<span className="sr-only">{t('loadingAlerts')}</span>
|
||||
</div>
|
||||
) : isError ? (
|
||||
<div className="mt-4 space-y-3 rounded-xl bg-danger-soft px-4 py-3 text-sm text-danger">
|
||||
<p>No pudimos cargar las alertas.</p>
|
||||
<p>{t('loadError')}</p>
|
||||
<Button variant="outline" size="sm" onClick={retry}>
|
||||
Reintentar
|
||||
{t('common:actions.retry')}
|
||||
</Button>
|
||||
</div>
|
||||
) : visible.length === 0 ? (
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import { Check } from 'lucide-react'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
|
||||
export function EmptyAttention() {
|
||||
const { t } = useTranslation('attention')
|
||||
return (
|
||||
<div className="mt-10 flex flex-col items-center px-6 text-center" role="status">
|
||||
<span className="flex size-14 items-center justify-center rounded-full bg-success-soft text-success">
|
||||
<Check className="size-7" strokeWidth={2.5} aria-hidden="true" />
|
||||
</span>
|
||||
<p className="mt-4 text-base font-semibold text-primary">Todo en orden</p>
|
||||
<p className="mt-4 text-base font-semibold text-primary">{t('empty.title')}</p>
|
||||
<p className="mt-1 max-w-[32ch] text-sm text-secondary">
|
||||
No hay alumnos que requieran atención en este filtro.
|
||||
{t('empty.description')}
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
|
||||
@@ -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 (
|
||||
<div role="group" aria-label="Filtrar alertas" className="flex gap-2 overflow-x-auto py-3">
|
||||
<div role="group" aria-label={t('filters.label')} className="flex gap-2 overflow-x-auto py-3">
|
||||
{ATTENTION_FILTERS.map((filter) => {
|
||||
const active = filter.id === value
|
||||
const active = filter === value
|
||||
return (
|
||||
<button
|
||||
key={filter.id}
|
||||
key={filter}
|
||||
type="button"
|
||||
aria-pressed={active}
|
||||
onClick={() => 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}`)}
|
||||
<span className={cn('tabular-nums', active ? 'text-background/70' : 'text-secondary')}>
|
||||
{counts[filter.id]}
|
||||
{counts[filter]}
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
|
||||
@@ -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.<id>`. */
|
||||
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<StudentAlertSeve
|
||||
/** "7 alumnos · 3 urgentes", or "Nada pendiente". Students, not cards. */
|
||||
export function attentionSubtitle(items: AttentionItem[]): string {
|
||||
const students = new Set(items.map((item) => 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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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[] }) {
|
||||
<span className="block truncate text-sm text-secondary">{student.groupName}</span>
|
||||
</span>
|
||||
<span className="sr-only">{student.worst.gravedad === 'urgente' ? t('attentionPreview.urgent') : t('attentionPreview.watch')}</span>
|
||||
<AlertTag severity={student.worst.gravedad}>{student.worst.etiqueta}</AlertTag>
|
||||
<AlertTag severity={student.worst.gravedad}>{alertLabel(student.worst)}</AlertTag>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
|
||||
2
apps/web/src/i18n/i18next.d.ts
vendored
2
apps/web/src/i18n/i18next.d.ts
vendored
@@ -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
|
||||
|
||||
57
apps/web/src/i18n/locales/en/attention.json
Normal file
57
apps/web/src/i18n/locales/en/attention.json
Normal file
@@ -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."
|
||||
}
|
||||
}
|
||||
57
apps/web/src/i18n/locales/es-419/attention.json
Normal file
57
apps/web/src/i18n/locales/es-419/attention.json
Normal file
@@ -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."
|
||||
}
|
||||
}
|
||||
57
apps/web/src/i18n/locales/es-AR/attention.json
Normal file
57
apps/web/src/i18n/locales/es-AR/attention.json
Normal file
@@ -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."
|
||||
}
|
||||
}
|
||||
57
apps/web/src/i18n/locales/pt-BR/attention.json
Normal file
57
apps/web/src/i18n/locales/pt-BR/attention.json
Normal file
@@ -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."
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -12,6 +12,30 @@ export type StudentAlertType = z.output<typeof studentAlertTypeSchema>;
|
||||
export const studentAlertSeveritySchema = z.enum(['urgente', 'vigilar']);
|
||||
export type StudentAlertSeverity = z.output<typeof studentAlertSeveritySchema>;
|
||||
|
||||
/** 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<typeof studentAlertReasonSchema>;
|
||||
|
||||
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(),
|
||||
|
||||
Reference in New Issue
Block a user