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 { GroupCard } from './GroupCard' import { MOCK_TEST_CASES } from './card' export function GroupsView() { const navigate = useNavigate() const groupsQuery = useQuery({ queryKey: ['groups'], queryFn: getGroups, }) const riskQuery = useQuery({ queryKey: ['groups-risk-overview'], queryFn: getGroupsRiskOverview, }) 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 return (

Grupos

{!hasGroups && groupsQuery.isSuccess ? ( ) : null}
{groupsQuery.isPending ? (
) : null} {groupsQuery.isError ? (

No pudimos cargar tus grupos.

) : null} {showExamples ? (
{MOCK_TEST_CASES.map((group) => ( ))}
) : null} {groupsQuery.isSuccess && groupsQuery.data.data.length === 0 && !showExamples ? ( /* A single icon, one focal point, and the text in secondary: the empty state competes with the action and must not win. */

Todavía no tenés grupos

Creá tu primer grupo y empezá a cobrar las cuotas de tus alumnos.

) : null} {hasGroups && !showExamples ? (
{groupsQuery.data.data.map((group) => ( ))}
) : null}
) }