Added routes
This commit is contained in:
43
apps/web/src/features/home/NextClassHero.tsx
Normal file
43
apps/web/src/features/home/NextClassHero.tsx
Normal file
@@ -0,0 +1,43 @@
|
||||
import { useNavigate } from '@tanstack/react-router'
|
||||
import type { NextClassDto } from '@gruperly/shared'
|
||||
import { CalendarClock } from 'lucide-react'
|
||||
import { Badge, Button } from '../../components/ui'
|
||||
import { formatRelativeDateTime, formatSchedule } from '../../lib/format'
|
||||
|
||||
export function NextClassHero({ nextClass }: { nextClass: NextClassDto }) {
|
||||
const navigate = useNavigate()
|
||||
const hasSchedule = (nextClass.days?.length ?? 0) > 0
|
||||
|
||||
return (
|
||||
<article className="relative overflow-hidden rounded-xl border border-accent/30 bg-surface p-5">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between sm:gap-4">
|
||||
<div className="min-w-0">
|
||||
<p className="text-xs font-medium uppercase tracking-wide text-foreground/50">
|
||||
{nextClass.isNow ? 'Clase en curso' : 'Próxima clase'}
|
||||
</p>
|
||||
<h2 className="mt-1 truncate text-xl font-bold text-primary">{nextClass.name}</h2>
|
||||
{hasSchedule ? (
|
||||
<div className="mt-2 flex items-center gap-2 text-sm text-foreground/70">
|
||||
<CalendarClock className="size-4 shrink-0 text-accent" />
|
||||
<span>{formatSchedule(nextClass.days ?? [], nextClass.time)}</span>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<Badge variant={nextClass.isNow ? 'success' : 'neutral'}>
|
||||
{nextClass.isNow ? 'En curso ahora' : formatRelativeDateTime(nextClass.occurrenceAt)}
|
||||
</Badge>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-4 flex justify-end border-t border-border pt-3">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => void navigate({ to: `/groups/${nextClass.groupId}` })}
|
||||
>
|
||||
Ver grupo
|
||||
</Button>
|
||||
</div>
|
||||
</article>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user