limit ranges for buy in selector
This commit is contained in:
parent
f04496bf24
commit
bfa66d5856
@ -10,6 +10,14 @@ interface BuyInSelectorProps {
|
||||
}
|
||||
|
||||
const defaultBuyInOptions = [10, 25, 50];
|
||||
const MIN = 1;
|
||||
const MAX = 200;
|
||||
|
||||
const parseRoundClamp = (num: string): number => {
|
||||
const parsed = parseFloat(num);
|
||||
const rounded = Math.round(parsed);
|
||||
return Math.min(Math.max(rounded, MIN), MAX);
|
||||
};
|
||||
|
||||
const BuyInSelector: React.FC<BuyInSelectorProps> = ({
|
||||
setBuyInAmount,
|
||||
@ -19,9 +27,9 @@ const BuyInSelector: React.FC<BuyInSelectorProps> = ({
|
||||
const [buyInAmount, setBuyInAmountState] = useState<number | null>(null);
|
||||
|
||||
const handleCustomAmountChange = (value: string) => {
|
||||
const numericValue = parseFloat(value);
|
||||
const numericValue = parseRoundClamp(value);
|
||||
if (!isNaN(numericValue) && numericValue >= 0) {
|
||||
setCustomAmount(value);
|
||||
setCustomAmount(numericValue.toString());
|
||||
setBuyInAmountState(numericValue);
|
||||
setBuyInAmount(numericValue);
|
||||
} else {
|
||||
@ -55,6 +63,7 @@ const BuyInSelector: React.FC<BuyInSelectorProps> = ({
|
||||
<TextInput
|
||||
style={styles.input}
|
||||
value={customAmount}
|
||||
maxLength={3}
|
||||
onChangeText={handleCustomAmountChange}
|
||||
placeholder={i18n.t("enter_custom_buy_in")}
|
||||
keyboardType="numeric"
|
||||
|
@ -196,7 +196,7 @@ const ChipDistributionSummary = ({
|
||||
</View>
|
||||
<View style={{ flexDirection: "row", justifyContent: "space-between" }}>
|
||||
<Text style={styles.p}>
|
||||
{i18n.t("total_value")}: {selectedCurrency} {totalValue}
|
||||
{i18n.t("total_value")}: {selectedCurrency} {totalValue.toFixed(2)}
|
||||
</Text>
|
||||
<Text style={styles.p}>
|
||||
{selectedCurrency} {potValue} {i18n.t("pot")}
|
||||
|
Loading…
Reference in New Issue
Block a user