import { Group, Stack, Text, Card, Badge, Box, ActionIcon } from "@mantine/core"; import { UserIcon, PhoneIcon } from "@phosphor-icons/react"; import { useFreeAgents } from "../../queries"; import UnenrollFreeAgent from "./unenroll-free-agent"; import toast from "@/lib/sonner"; const EnrolledFreeAgent: React.FC<{ tournamentId: string }> = ({ tournamentId }) => { const { data: freeAgents } = useFreeAgents(tournamentId); const copyToClipboard = async (phone: string) => { try { await navigator.clipboard.writeText(phone); toast.success("Phone number copied!"); } catch (err) { toast.success("Failed to copy"); } }; return ( Enrolled as Free Agent You're on the free agent list. Other free agents looking for teams: {freeAgents.length > 1 ? ( {freeAgents .filter(agent => agent.player) .map((agent) => ( {agent.player?.first_name} {agent.player?.last_name} {agent.phone && ( copyToClipboard(agent.phone!)} style={{ cursor: 'pointer' }} > copyToClipboard(agent.phone!)} > {agent.phone} )} ))} {freeAgents.length > 1 && ( {freeAgents.length} free agents total )} ) : ( You're the only free agent so far )} ); }; export default EnrolledFreeAgent;