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

Function handleTopUpAmountChange

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

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 1

clampFunction · 0.90

Tested by

no test coverage detected