| 310 | } |
| 311 | |
| 312 | const handleTopUpAmountChange = (rawValue: number) => { |
| 313 | // Allow any value for UI display |
| 314 | setTopUpAmountDollars(rawValue) |
| 315 | |
| 316 | if (isEnabled && canManageAutoTopup) { |
| 317 | // Make sure we send a valid value to the server |
| 318 | const validValue = clamp( |
| 319 | rawValue, |
| 320 | MIN_TOPUP_DOLLARS, |
| 321 | ORG_AUTO_TOPUP_CONSTANTS.MAX_TOPUP_DOLLARS, |
| 322 | ) |
| 323 | pendingSettings.current = { threshold, topUpAmountDollars: validValue } |
| 324 | |
| 325 | // Only save if the value is valid |
| 326 | if ( |
| 327 | rawValue >= MIN_TOPUP_DOLLARS && |
| 328 | rawValue <= ORG_AUTO_TOPUP_CONSTANTS.MAX_TOPUP_DOLLARS |
| 329 | ) { |
| 330 | debouncedSaveSettings() |
| 331 | } |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | const handleToggleAutoTopup = async (checked: boolean): Promise<boolean> => { |
| 336 | if (!canManageAutoTopup) { |