Added routes

This commit is contained in:
Jose Selesan
2026-09-25 10:05:56 -03:00
parent 336e1af523
commit 94c353f4f2
100 changed files with 6126 additions and 183 deletions

View File

@@ -0,0 +1,78 @@
import { useNavigate } from '@tanstack/react-router'
import type { GroupDto, GroupRiskLevel } from '@gruperly/shared'
import { CalendarClock, Users } from 'lucide-react'
import { Badge, Button } from '../../components/ui'
import { BILLING_LABELS, formatPrice, formatSchedule } from '../../lib/format'
import { cn } from '../../lib/utils'
import { RISK_LABELS } from './constants'
export function GroupCard({
group,
riskLevel,
}: {
group: GroupDto
riskLevel: GroupRiskLevel
}) {
const navigate = useNavigate()
const hasSchedule = (group.days?.length ?? 0) > 0
const hasRisk = riskLevel === 'HIGH' || riskLevel === 'MEDIUM'
return (
<article className="rounded-xl border border-border bg-surface p-5 transition-all hover:border-accent/40">
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">
<h3 className="truncate text-base font-semibold text-primary">{group.name}</h3>
{group.description ? (
<p className="mt-0.5 truncate text-sm text-foreground/60">{group.description}</p>
) : null}
</div>
<div className="flex flex-col items-end gap-1.5">
{hasRisk ? (
<Badge variant={riskLevel === 'HIGH' ? 'danger' : 'warning'} className="gap-1.5">
<span
className={cn(
'size-2 rounded-full',
riskLevel === 'HIGH' ? 'bg-danger' : 'bg-warning',
)}
aria-hidden="true"
/>
{RISK_LABELS[riskLevel]}
</Badge>
) : null}
<Badge variant="success">Activo</Badge>
</div>
</div>
{hasSchedule ? (
<dl className="mt-4 space-y-2 text-sm">
<div className="flex items-center gap-2 text-foreground/70">
<CalendarClock className="size-4 shrink-0 text-accent" />
<span>{formatSchedule(group.days ?? [], group.time)}</span>
</div>
<div className="flex items-center gap-2 text-foreground/70">
<Users className="size-4 shrink-0 text-accent" />
<span>
Cupo {group.capacity ?? '—'} miembros
{group.price != null
? ` · ${formatPrice(group.price)}${group.billingType ? ` · ${BILLING_LABELS[group.billingType]}` : ''}`
: ''}
{group.dueDay != null ? ` · vence el día ${group.dueDay}` : ''}
</span>
</div>
</dl>
) : (
<p className="mt-4 text-sm text-foreground/50">Aún sin plan de cobro configurado.</p>
)}
<div className="mt-4 flex items-center justify-end gap-2 border-t border-border pt-3">
<Button
variant="outline"
size="sm"
onClick={() => void navigate({ to: `/groups/${group.id}` })}
>
Gestionar Miembros
</Button>
</div>
</article>
)
}