import React, { useState } from "react"; import { View, Text, TextInput, TouchableOpacity, StyleSheet, } from "react-native"; import { MaterialIcons } from "@expo/vector-icons"; interface BuyInSelectorProps { setBuyInAmount: React.Dispatch>; selectedCurrency: string; // Accept selectedCurrency as a prop } const defaultBuyInOptions = [10, 25, 50]; const BuyInSelector: React.FC = ({ setBuyInAmount, selectedCurrency, }) => { const [customAmount, setCustomAmount] = useState(""); const [buyInAmount, setBuyInAmountState] = useState(null); const handleCustomAmountChange = (value: string) => { const numericValue = parseFloat(value); if (!isNaN(numericValue) && numericValue >= 0) { setCustomAmount(value); setBuyInAmountState(numericValue); setBuyInAmount(numericValue); } else { setCustomAmount(""); setBuyInAmountState(25); setBuyInAmount(25); } }; const handleBuyInSelection = (amount: number) => { setBuyInAmountState(amount); setCustomAmount(""); setBuyInAmount(amount); }; return ( Select Buy-in Amount: {defaultBuyInOptions.map((amount) => ( handleBuyInSelection(amount)} > {selectedCurrency} {amount}{" "} {/* Display the selected currency before the amount */} ))} Or enter a custom amount: Selected Buy-in:{" "} {buyInAmount !== null ? `${selectedCurrency} ${buyInAmount}` : "None"}{" "} {/* Display the currency here */} ); }; const styles = StyleSheet.create({ container: { padding: 20, }, header: { flexDirection: "row", alignItems: "center", marginBottom: 10, }, title: { fontSize: 22, marginLeft: 10, }, optionsContainer: { flexDirection: "row", justifyContent: "space-around", marginVertical: 10, }, buyInButton: { backgroundColor: "#ddd", padding: 10, borderRadius: 5, }, selectedButton: { backgroundColor: "#4caf50", }, buttonText: { fontSize: 16, }, orText: { marginTop: 10, textAlign: "center", }, input: { borderWidth: 1, borderColor: "#ccc", padding: 8, marginVertical: 10, borderRadius: 5, }, selectionText: { marginTop: 15, fontSize: 16, fontWeight: "bold", }, }); export default BuyInSelector;