import { useMemo } from 'react';
import { StyleSheet, View, Text } from 'react-native';
import { useDubsTheme } from '../theme';
import type { GameDetail } from '../../types';
export interface LivePoolsCardProps {
game: GameDetail;
/** Custom short-name function for team labels. Defaults to full name. */
shortName?: (name: string | null) => string;
/** Override bar colors. Defaults to blue/red. */
homeColor?: string;
awayColor?: string;
}
/**
* Pool breakdown card showing each side's SOL amount, bar chart, and implied odds.
*/
export function LivePoolsCard({
game,
shortName,
homeColor = '#3B82F6',
awayColor = '#EF4444',
}: LivePoolsCardProps) {
const t = useDubsTheme();
const opponents = game.opponents || [];
const homeName = shortName ? shortName(opponents[0]?.name) : (opponents[0]?.name || 'Home');
const awayName = shortName ? shortName(opponents[1]?.name) : (opponents[1]?.name || 'Away');
const homePool = game.homePool || 0;
const awayPool = game.awayPool || 0;
const totalPool = game.totalPool || 0;
const { homePercent, awayPercent, homeOdds, awayOdds } = useMemo(() => {
return {
homePercent: totalPool > 0 ? (homePool / totalPool) * 100 : 50,
awayPercent: totalPool > 0 ? (awayPool / totalPool) * 100 : 50,
homeOdds: homePool > 0 ? (totalPool / homePool).toFixed(2) : '—',
awayOdds: awayPool > 0 ? (totalPool / awayPool).toFixed(2) : '—',
};
}, [homePool, awayPool, totalPool]);
return (
Live Pools
{totalPool} SOL total
{homeName}: {homeOdds}x
{awayName}: {awayOdds}x
);
}
function PoolBar({ name, amount, percent, color, t }: { name: string; amount: number; percent: number; color: string; t: any }) {
return (
{name}
{amount} SOL
);
}
const styles = StyleSheet.create({
card: { borderRadius: 16, borderWidth: 1, padding: 16 },
title: { fontSize: 17, fontWeight: '700', marginBottom: 4 },
total: { fontSize: 14, fontWeight: '600', marginBottom: 14 },
bars: { gap: 10 },
barRow: { flexDirection: 'row', alignItems: 'center', gap: 10 },
barLabel: { width: 80, fontSize: 13, fontWeight: '600' },
barTrack: { flex: 1, height: 10, borderRadius: 5, overflow: 'hidden' },
barFill: { height: '100%', borderRadius: 5 },
barAmount: { width: 70, textAlign: 'right', fontSize: 13, fontWeight: '700' },
oddsRow: { flexDirection: 'row', justifyContent: 'space-between', marginTop: 12 },
oddsText: { fontSize: 12 },
});