'use client' import { useState } from 'react' import { useRouter } from 'next/navigation' import { joinRound } from '@/app/actions/rounds' import { Button } from '@/components/ui/button' type Props = { roundId: string round: { name: string | null date: string holesCount: number course: { name: string } tee: { name: string; color: string } } } export function JoinRound({ roundId, round }: Props) { const router = useRouter() const [loading, setLoading] = useState(false) const [error, setError] = useState(null) async function handleJoin() { setLoading(true) setError(null) const result = await joinRound(roundId) if (result.error) { setError(result.error) setLoading(false) return } router.push(`/rounds/${roundId}`) } return (

You're invited!

{round.course.name}
{round.name &&
{round.name}
}
{round.tee.name} tees · {round.holesCount} holes
{new Date(round.date).toLocaleDateString()}
{error &&

{error}

}
) }