"use client"
import { useState } from "react"
import { useBetslipStore } from "@/lib/store/betslip-store"
import { X, ChevronDown, Trash2 } from "lucide-react"
import { cn } from "@/lib/utils"
const quickStakes = [5, 10, 20, 50, 100, 200]
export function Betslip() {
const { bets, removeBet, clearBets, updateStake, getPotentialWin, getTotalOdds } = useBetslipStore()
const [activeTab, setActiveTab] = useState<"single" | "accumulator">("single")
const [globalStake, setGlobalStake] = useState("10")
const potentialWin = getPotentialWin()
const totalOdds = getTotalOdds()
return (
{/* Header */}
Betslip
{bets.length > 0 && (
{bets.length}
)}
{bets.length > 0 && (
)}
{/* Tabs */}
{bets.length > 1 && (
{(["single", "accumulator"] as const).map((tab) => (
))}
)}
{/* Content */}
{bets.length === 0 ? (
🎯
No bets selected. Click on odds to add selections.
) : (
<>
{/* Bet items */}
{bets.map((bet) => (
{bet.event}
{bet.league}
{bet.market}: {bet.selection}
{bet.odds.toFixed(2)}
{/* Stake input for single */}
{(activeTab === "single" || bets.length === 1) && (
Stake (ETB)
updateStake(bet.id, Number(e.target.value))}
className="flex-1 bg-input border border-border rounded px-2 py-1 text-xs text-foreground w-full min-w-0 focus:outline-none focus:border-primary"
min="1"
/>
{quickStakes.map((s) => (
))}
{/* Potential win */}
Potential win:
{((bet.stake ?? 10) * bet.odds).toFixed(2)} ETB
)}
))}
{/* Accumulator stake section */}
{activeTab === "accumulator" && bets.length > 1 && (
Total Odds:
{totalOdds.toFixed(2)}
Stake (ETB)
setGlobalStake(e.target.value)}
className="w-full bg-input border border-border rounded px-2 py-1 text-xs text-foreground focus:outline-none focus:border-primary"
min="1"
/>
{quickStakes.map((s) => (
))}
Potential win:
{(Number(globalStake) * totalOdds).toFixed(2)} ETB
)}
{/* Place bet button */}
>
)}
)
}