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 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> = ({
|
const BuyInSelector: React.FC<BuyInSelectorProps> = ({
|
||||||
setBuyInAmount,
|
setBuyInAmount,
|
||||||
@ -19,9 +27,9 @@ const BuyInSelector: React.FC<BuyInSelectorProps> = ({
|
|||||||
const [buyInAmount, setBuyInAmountState] = useState<number | null>(null);
|
const [buyInAmount, setBuyInAmountState] = useState<number | null>(null);
|
||||||
|
|
||||||
const handleCustomAmountChange = (value: string) => {
|
const handleCustomAmountChange = (value: string) => {
|
||||||
const numericValue = parseFloat(value);
|
const numericValue = parseRoundClamp(value);
|
||||||
if (!isNaN(numericValue) && numericValue >= 0) {
|
if (!isNaN(numericValue) && numericValue >= 0) {
|
||||||
setCustomAmount(value);
|
setCustomAmount(numericValue.toString());
|
||||||
setBuyInAmountState(numericValue);
|
setBuyInAmountState(numericValue);
|
||||||
setBuyInAmount(numericValue);
|
setBuyInAmount(numericValue);
|
||||||
} else {
|
} else {
|
||||||
@ -55,6 +63,7 @@ const BuyInSelector: React.FC<BuyInSelectorProps> = ({
|
|||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
value={customAmount}
|
value={customAmount}
|
||||||
|
maxLength={3}
|
||||||
onChangeText={handleCustomAmountChange}
|
onChangeText={handleCustomAmountChange}
|
||||||
placeholder={i18n.t("enter_custom_buy_in")}
|
placeholder={i18n.t("enter_custom_buy_in")}
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
|
@ -196,7 +196,7 @@ const ChipDistributionSummary = ({
|
|||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: "row", justifyContent: "space-between" }}>
|
<View style={{ flexDirection: "row", justifyContent: "space-between" }}>
|
||||||
<Text style={styles.p}>
|
<Text style={styles.p}>
|
||||||
{i18n.t("total_value")}: {selectedCurrency} {totalValue}
|
{i18n.t("total_value")}: {selectedCurrency} {totalValue.toFixed(2)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text style={styles.p}>
|
<Text style={styles.p}>
|
||||||
{selectedCurrency} {potValue} {i18n.t("pot")}
|
{selectedCurrency} {potValue} {i18n.t("pot")}
|
||||||
|
Loading…
Reference in New Issue
Block a user