MCPcopy Create free account
hub / github.com/CodebuffAI/codebuff / handleTopUpAmountChange

Function handleTopUpAmountChange

web/src/hooks/use-auto-topup.ts:289–303  ·  view source on GitHub ↗
(rawValue: number)

Source from the content-addressed store, hash-verified

287 }
288
289 const handleTopUpAmountChange = (rawValue: number) => {
290 // Allow any value for UI display
291 setTopUpAmountDollars(rawValue)
292
293 if (isEnabled) {
294 // Make sure we send a valid value to the server
295 const validValue = clamp(rawValue, MIN_TOPUP_DOLLARS, MAX_TOPUP_DOLLARS)
296 pendingSettings.current = { threshold, topUpAmountDollars: validValue }
297
298 // Only save if the value is valid
299 if (rawValue >= MIN_TOPUP_DOLLARS && rawValue <= MAX_TOPUP_DOLLARS) {
300 debouncedSaveSettings()
301 }
302 }
303 }
304
305 const enableAutoTopup = useCallback(() => {
306 setIsEnabled(true)

Callers 1

enableMinimumAutoTopupFunction · 0.50

Calls 1

clampFunction · 0.90

Tested by

no test coverage detected