import { createClient } from '@/lib/supabase/server' import { redirect } from 'next/navigation' import Link from 'next/link' import { buttonVariants } from '@/components/ui/button' import { cn } from '@/lib/utils' export default async function DashboardPage() { const supabase = await createClient() const { data: { user }, } = await supabase.auth.getUser() if (!user) redirect('/login') type RoundRow = { round: { id: string name: string | null date: string status: string holes_count: number course: { name: string } | null tee: { name: string; color: string } | null } | null } // Fetch rounds the user is participating in // eslint-disable-next-line @typescript-eslint/no-explicit-any const { data: rounds } = (await (supabase as any) .from('round_players') .select( ` round:rounds ( id, name, date, status, holes_count, course:courses (name), tee:tees (name, color) ) `, ) .eq('user_id', user.id) .in('round.status', ['lobby', 'active']) .order('round(date)', { ascending: false })) as { data: RoundRow[] | null } return (
No active rounds. Start one!
)}