'use client'; import { useMemo, useState } from 'react'; import { BookmakerCode, generateBetSlipUrl } from '@/lib/betting-utils'; const logoMap: Record = { bet365: 'Bet365', pinnacle: 'Pinnacle', draftkings: 'DraftKings', }; type Props = { bookmakerId: BookmakerCode; matchId: string; selection: string; odds: number; disabled?: boolean; }; export function QuickBetButton({ bookmakerId, matchId, selection, odds, disabled = false }: Props) { const [isRedirecting, setIsRedirecting] = useState(false); const label = logoMap[bookmakerId]; const oddsText = odds.toFixed(2); const href = useMemo( () => generateBetSlipUrl({ bookmakerId, matchId, selection, odds, }), [bookmakerId, matchId, selection, odds], ); const handleClick = () => { if (disabled) { return; } setIsRedirecting(true); window.open(href, '_blank', 'noopener,noreferrer'); window.setTimeout(() => setIsRedirecting(false), 900); }; return ( ); }