feat: rediseño de Grupos y pantalla "Requiere atención"
- Grupos: subtítulo con resumen (grupos · alumnos · lugares libres), sección "Requiere atención" con los 4 alumnos más urgentes y tarjetas con avatares (punteados por lugar libre en grupos chicos, superpuestos con "+N" en grandes; con alerta primero y anillo de gravedad). - Pantalla nueva /groups/attention: filtros Todos/Asistencia/Pagos, secciones Urgente y A vigilar, Contactar / Enviar recordatorio por wa.me y "Resuelto" persistente con update optimista. - FAB "Nuevo grupo" que se pliega al scrollear (respeta reduced motion); los toasts en mobile suben para no quedar debajo. - Alertas centralizadas en computeStudentAlerts (shared). La regla de asistencia pasa a: urgente = 3 seguidas o 4 de las últimas 6; a vigilar = 2 de las últimas 4 (sin inactividad por días ni tendencia). Cuotas: 1 vencida vigilar, 2+ urgente. - Backend: GET /attention y POST /attention/:attendeeId/resolve; tabla attendee_alert_resolutions (la alerta vuelve si cambia la firma). - Tokens de gravedad para claro y oscuro; se quita el indicador de pills. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import { CalendarPlus, Loader2, Plus } from 'lucide-react'
|
||||
import { useState } from 'react'
|
||||
import { Button } from '../../components/ui'
|
||||
import { getGroups, getGroupsRiskOverview } from '../../lib/api'
|
||||
import { getGroups } from '../../lib/api'
|
||||
import { flaggedStudents } from '../attention/attention'
|
||||
import { attentionQueryOptions } from '../attention/queries'
|
||||
import { AttentionPreview } from './AttentionPreview'
|
||||
import { GroupCard } from './GroupCard'
|
||||
import { MOCK_TEST_CASES } from './card'
|
||||
import { groupsSummary, membersOf } from './card'
|
||||
import { NewGroupFab } from './NewGroupFab'
|
||||
|
||||
export function GroupsView() {
|
||||
const navigate = useNavigate()
|
||||
@@ -13,49 +16,16 @@ export function GroupsView() {
|
||||
queryKey: ['groups'],
|
||||
queryFn: getGroups,
|
||||
})
|
||||
const riskQuery = useQuery({
|
||||
queryKey: ['groups-risk-overview'],
|
||||
queryFn: getGroupsRiskOverview,
|
||||
})
|
||||
const attentionQuery = useQuery(attentionQueryOptions)
|
||||
|
||||
const [showExamples, setShowExamples] = useState(() => {
|
||||
if (typeof window !== 'undefined') {
|
||||
return new URLSearchParams(window.location.search).get('mock') === 'true'
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
const riskByGroup = new Map(
|
||||
(riskQuery.data?.items ?? []).map((item) => [item.groupId, item]),
|
||||
)
|
||||
|
||||
const hasGroups = groupsQuery.isSuccess && groupsQuery.data.data.length > 0
|
||||
const groups = groupsQuery.data?.data ?? []
|
||||
const hasGroups = groupsQuery.isSuccess && groups.length > 0
|
||||
|
||||
return (
|
||||
<section>
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<h1 className="text-2xl font-bold text-primary">Grupos</h1>
|
||||
<div className="flex items-center gap-2">
|
||||
{!hasGroups && groupsQuery.isSuccess ? (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-11"
|
||||
onClick={() => setShowExamples((prev) => !prev)}
|
||||
>
|
||||
{showExamples ? 'Ocultar ejemplos' : 'Ver ejemplos'}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
variant="primary"
|
||||
className="h-11"
|
||||
onClick={() => void navigate({ to: '/groups/new' })}
|
||||
>
|
||||
<Plus className="size-4" />
|
||||
Nuevo grupo
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
// The FAB floats over the last card: 88px of room so it can be read.
|
||||
<section className="pb-[88px]">
|
||||
<h1 className="text-2xl font-bold text-primary">Grupos</h1>
|
||||
{hasGroups ? <p className="mt-1 text-sm text-secondary">{groupsSummary(groups)}</p> : null}
|
||||
|
||||
{groupsQuery.isPending ? (
|
||||
<div className="mt-8 flex items-center justify-center py-16" role="status">
|
||||
@@ -73,15 +43,7 @@ export function GroupsView() {
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{showExamples ? (
|
||||
<div className="mt-6 grid gap-4">
|
||||
{MOCK_TEST_CASES.map((group) => (
|
||||
<GroupCard key={group.id} {...group} />
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{groupsQuery.isSuccess && groupsQuery.data.data.length === 0 && !showExamples ? (
|
||||
{groupsQuery.isSuccess && groups.length === 0 ? (
|
||||
/* A single icon, one focal point, and the text in secondary: the empty
|
||||
state competes with the action and must not win. */
|
||||
<div className="mt-8 rounded-xl bg-primary-soft px-5 py-12 text-center">
|
||||
@@ -92,38 +54,48 @@ export function GroupsView() {
|
||||
<p className="mx-auto mt-1.5 max-w-[30ch] text-sm leading-relaxed text-secondary">
|
||||
Creá tu primer grupo y empezá a cobrar las cuotas de tus alumnos.
|
||||
</p>
|
||||
<div className="mt-6 flex items-center justify-center gap-3">
|
||||
<Button
|
||||
variant="outline"
|
||||
className="h-11"
|
||||
onClick={() => setShowExamples(true)}
|
||||
>
|
||||
Ver tarjetas de ejemplo
|
||||
</Button>
|
||||
<Button
|
||||
variant="primary"
|
||||
className="h-11"
|
||||
onClick={() => void navigate({ to: '/groups/new' })}
|
||||
>
|
||||
<Plus className="size-4" />
|
||||
Crear primer grupo
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
variant="primary"
|
||||
className="mt-6 h-11"
|
||||
onClick={() => void navigate({ to: '/groups/new' })}
|
||||
>
|
||||
<Plus className="size-4" />
|
||||
Crear primer grupo
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{hasGroups && !showExamples ? (
|
||||
<div className="mt-6 grid gap-4">
|
||||
{groupsQuery.data.data.map((group) => (
|
||||
<GroupCard
|
||||
key={group.id}
|
||||
group={group}
|
||||
risk={riskByGroup.get(group.id)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
{hasGroups ? (
|
||||
<>
|
||||
<AttentionPreview students={flaggedStudents(attentionQuery.data)} />
|
||||
|
||||
<section aria-labelledby="my-groups-title" className="mt-6">
|
||||
<h2
|
||||
id="my-groups-title"
|
||||
className="text-xs font-semibold tracking-wider text-secondary uppercase"
|
||||
>
|
||||
Mis grupos
|
||||
</h2>
|
||||
<div className="mt-2 grid gap-3 lg:grid-cols-2">
|
||||
{groups.map((group) => (
|
||||
<GroupCard
|
||||
key={group.id}
|
||||
group={group}
|
||||
members={
|
||||
attentionQuery.isSuccess
|
||||
? (membersOf(attentionQuery.data.groups, group.id) ?? [])
|
||||
: attentionQuery.isError
|
||||
? null
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<NewGroupFab />
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user