import React from 'react'; import { StyleSheet, TouchableOpacity, Image, ScrollView, Share } from 'react-native'; import { View, Text, useTheme } from '@bettoredge/styles'; import { Ionicons } from '@expo/vector-icons'; import type { CalcuttaCompetitionProps, CalcuttaRoundProps, CalcuttaPayoutRuleProps, CalcuttaEscrowProps, } from '@bettoredge/types'; import type { CalcuttaLifecycleState } from '../../helpers/lifecycleState'; import { canManageEscrow } from '../../helpers/lifecycleState'; import { formatCurrency } from '../../helpers/formatting'; import { CalcuttaEscrow } from '../CalcuttaEscrow'; interface SealedBidInfoTabProps { competition: CalcuttaCompetitionProps; rounds: CalcuttaRoundProps[]; payout_rules: CalcuttaPayoutRuleProps[]; escrow?: CalcuttaEscrowProps; market_type: string; player_balance?: number; onDepositFunds?: (amount: number) => void; onEscrowUpdate: () => void; lifecycleState: CalcuttaLifecycleState; } export const SealedBidInfoTab: React.FC = ({ competition, rounds, payout_rules, escrow, market_type, player_balance, onDepositFunds, onEscrowUpdate, lifecycleState, }) => { const { theme } = useTheme(); const totalPot = Number(competition.total_pot) || 0; const escrowInteractive = canManageEscrow(lifecycleState); const showEscrow = lifecycleState !== 'pending'; const handleCopyCode = () => { // Copy is handled by the share flow or parent component }; const handleShare = async () => { try { const msg = competition.competition_code ? `Join my Calcutta auction "${competition.competition_name}"! Code: ${competition.competition_code}` : `Check out the Calcutta auction "${competition.competition_name}" on BettorEdge!`; await Share.share({ message: msg }); } catch {} }; return ( {/* Hero image */} {competition.image?.url ? ( ) : ( )} {/* Name + description */} {competition.competition_name} {competition.competition_description ? ( {competition.competition_description} ) : null} {/* Payout structure */} {payout_rules.length > 0 && ( Payout Structure {payout_rules.map((rule, i) => { const round = rounds.find(r => r.round_number === rule.round_number); const pct = Number(rule.payout_pct); const amount = totalPot > 0 ? (pct / 100) * totalPot : 0; return ( {rule.description || round?.round_name || `Round ${rule.round_number}`} {pct}% {totalPot > 0 && ( {formatCurrency(amount, market_type)} )} ); })} )} {/* Rules card */} {(competition.min_bid > 0 || competition.bid_increment > 0 || competition.max_escrow || competition.min_spend_pct) && ( Rules {competition.min_bid > 0 && ( Min Bid: {formatCurrency(competition.min_bid, market_type)} )} {competition.bid_increment > 0 && ( Bid Increment: {formatCurrency(competition.bid_increment, market_type)} )} {competition.max_escrow != null && Number(competition.max_escrow) > 0 && ( Budget Cap: {formatCurrency(Number(competition.max_escrow), market_type)} )} {competition.min_spend_pct != null && Number(competition.min_spend_pct) > 0 && ( Min Spend: {competition.min_spend_pct}% of deposited funds )} )} {/* Rounds */} {rounds.length > 0 && ( Rounds {rounds.map(r => ( {r.round_number} {r.round_name} ))} )} {/* Competition code */} {competition.competition_code && ( {competition.competition_code} )} {/* Share button */} Share {/* Escrow management — hidden in pending, read-only in tournament/completed */} {showEscrow && ( Escrow )} ); }; const styles = StyleSheet.create({ content: { paddingBottom: 60, }, heroImage: { width: '100%', height: 180, }, heroPlaceholder: { width: '100%', height: 120, alignItems: 'center', justifyContent: 'center', }, section: { padding: 16, borderTopWidth: 1, }, payoutRow: { flexDirection: 'row', alignItems: 'center', paddingVertical: 10, }, rulesCard: { margin: 16, marginTop: 0, padding: 14, borderRadius: 10, borderWidth: 1, }, ruleItem: { marginBottom: 4, }, roundRow: { flexDirection: 'row', alignItems: 'center', paddingVertical: 6, }, codeRow: { flexDirection: 'row', alignItems: 'center', paddingHorizontal: 14, paddingVertical: 10, borderRadius: 10, }, shareBtn: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', paddingVertical: 10, borderRadius: 10, borderWidth: 1, }, });