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

Function handleThresholdChange

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

Source from the content-addressed store, hash-verified

287 )
288
289 const handleThresholdChange = (rawValue: number) => {
290 // Allow any value for UI display
291 setThreshold(rawValue)
292
293 if (isEnabled && canManageAutoTopup) {
294 // Make sure we send a valid value to the server
295 const validValue = clamp(
296 rawValue,
297 ORG_AUTO_TOPUP_CONSTANTS.MIN_THRESHOLD_CREDITS,
298 ORG_AUTO_TOPUP_CONSTANTS.MAX_THRESHOLD_CREDITS,
299 )
300 pendingSettings.current = { threshold: validValue, topUpAmountDollars }
301
302 // Only save if the value is valid
303 if (
304 rawValue >= ORG_AUTO_TOPUP_CONSTANTS.MIN_THRESHOLD_CREDITS &&
305 rawValue <= ORG_AUTO_TOPUP_CONSTANTS.MAX_THRESHOLD_CREDITS
306 ) {
307 debouncedSaveSettings()
308 }
309 }
310 }
311
312 const handleTopUpAmountChange = (rawValue: number) => {
313 // Allow any value for UI display

Callers

nothing calls this directly

Calls 1

clampFunction · 0.90

Tested by

no test coverage detected