Improve Chip Distribution (Issue #40) #55

Merged
djwesty merged 9 commits from djwesty/40 into main 2025-03-09 17:55:23 -07:00
2 changed files with 12 additions and 3 deletions
Showing only changes of commit bfa66d5856 - Show all commits

View File

@ -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"

View File

@ -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")}