Skip to content

Conversation

@jnsdls
Copy link
Member

@jnsdls jnsdls commented Jul 24, 2025

TL;DR

Added a custom amount input option to the credit balance top-up section.

What changed?

  • Added a new input field that allows users to enter a custom credit amount
  • Implemented validation to ensure the selected amount is a positive integer
  • Added state management for the custom amount input
  • Connected the custom input with the existing radio button selection
  • Disabled the top-up button when the selected amount is invalid

How to test?

  1. Navigate to the team billing page
  2. Verify the predefined credit amount options work as before
  3. Try entering a custom amount in the new input field
  4. Confirm that selecting a predefined amount clears the custom input
  5. Verify the top-up button is disabled when an invalid amount is entered
  6. Test that only positive integers are accepted in the custom field

Why make this change?

This enhancement provides users with more flexibility when adding credits to their account. Instead of being limited to predefined amounts, users can now specify exactly how many credits they want to purchase, improving the user experience and accommodating various budget requirements.

Summary by CodeRabbit

  • New Features
    • Added the ability for users to enter a custom credit top-up amount in addition to selecting from predefined options.
    • Input validation ensures only positive integer amounts can be entered for custom top-ups.
    • The top-up button is now only enabled when a valid amount is selected.

@vercel
Copy link

vercel bot commented Jul 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 24, 2025 7:34pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Jul 24, 2025 7:34pm
nebula ⬜️ Skipped (Inspect) Jul 24, 2025 7:34pm
thirdweb_playground ⬜️ Skipped (Inspect) Jul 24, 2025 7:34pm
wallet-ui ⬜️ Skipped (Inspect) Jul 24, 2025 7:34pm

@vercel vercel bot temporarily deployed to Preview – thirdweb_playground July 24, 2025 19:26 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui July 24, 2025 19:26 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula July 24, 2025 19:26 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 July 24, 2025 19:26 Inactive
@changeset-bot
Copy link

changeset-bot bot commented Jul 24, 2025

⚠️ No Changeset found

Latest commit: 1a77e11

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 24, 2025

Walkthrough

The CreditBalanceSection component was updated to allow users to enter a custom credit top-up amount in addition to selecting from predefined options. State management and input validation were added for the custom amount, and UI logic was adjusted to ensure only valid amounts enable the top-up button.

Changes

File(s) Change Summary
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx Added custom amount input, updated state management, input sanitization, validation, and button logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CreditBalanceSection

    User->>CreditBalanceSection: Selects predefined amount
    CreditBalanceSection->>CreditBalanceSection: Set selectedAmount, clear customAmount

    User->>CreditBalanceSection: Enters custom amount
    CreditBalanceSection->>CreditBalanceSection: Sanitize input, set customAmount, update selectedAmount

    CreditBalanceSection->>CreditBalanceSection: Validate selectedAmount

    User->>CreditBalanceSection: Clicks Top-up button
    CreditBalanceSection->>CreditBalanceSection: Proceed if selectedAmount is valid
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Add_custom_amount_input_to_credit_balance_section

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Member Author

jnsdls commented Jul 24, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Jul 24, 2025
@jnsdls jnsdls marked this pull request as ready for review July 24, 2025 19:26
@jnsdls jnsdls requested review from a team as code owners July 24, 2025 19:26
@codecov
Copy link

codecov bot commented Jul 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.31%. Comparing base (1659ae3) to head (1a77e11).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7697   +/-   ##
=======================================
  Coverage   56.31%   56.31%           
=======================================
  Files         908      908           
  Lines       58177    58177           
  Branches     4207     4207           
=======================================
  Hits        32765    32765           
  Misses      25302    25302           
  Partials      110      110           
Flag Coverage Δ
packages 56.31% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1659ae3 and 1a77e11.

📒 Files selected for processing (1)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx (5 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.{ts,tsx}: Write idiomatic TypeScript with explicit function declarations and return types
Limit each file to one stateless, single-responsibility function for clarity
Re-use shared types from @/types or local types.ts barrels
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Choose composition over inheritance; leverage utility types (Partial, Pick, etc.)
Comment only ambiguous logic; avoid restating TypeScript in prose

Files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

Load heavy dependencies inside async paths to keep initial bundle lean (lazy loading)

Files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx
apps/{dashboard,playground-web}/**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (CLAUDE.md)

apps/{dashboard,playground-web}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps
Use NavLink for internal navigation with automatic active states in dashboard and playground apps
Use Tailwind CSS only – no inline styles or CSS modules
Use cn() from @/lib/utils for conditional class logic
Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components (Node edge): Start files with import "server-only";
Client Components (browser): Begin files with 'use client';
Always call getAuthToken() to retrieve JWT from cookies on server side
Use Authorization: Bearer header – never embed tokens in URLs
Return typed results (e.g., Project[], User[]) – avoid any
Wrap client-side data fetching calls in React Query (@tanstack/react-query)
Use descriptive, stable queryKeys for React Query cache hits
Configure staleTime/cacheTime in React Query based on freshness (default ≥ 60s)
Keep tokens secret via internal API routes or server actions
Never import posthog-js in server components

Files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Surface breaking changes prominently in PR descriptions
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (`useState`, `useEffect`, React Query, wallet hooks).
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx (15)

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Interactive UI that relies on hooks (useState, useEffect, React Query, wallet hooks).

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : Prefer composable primitives over custom markup: Button, Input, Select, Tabs, Card, Sidebar, Separator, Badge.

Learnt from: arcoraven
PR: #7505
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/components/WebhookAnalyticsCharts.tsx:186-204
Timestamp: 2025-07-10T10:18:33.238Z
Learning: The ThirdwebBarChart component in apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/analytics/components/WebhookAnalyticsCharts.tsx does not accept standard accessibility props like aria-label and role in its TypeScript interface, causing compilation errors when added.

Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Import UI primitives from @/components/ui/* (Button, Input, Select, Tabs, Card, Sidebar, Badge, Separator) in dashboard and playground apps

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*client.tsx : Components that listen to user events, animations or live updates.

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : Stick to design-tokens: background (bg-card), borders (border-border), muted text (text-muted-foreground) etc.

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : Reuse core UI primitives; avoid re-implementing buttons, cards, modals.

Learnt from: MananTank
PR: #7315
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/launch-nft.tsx:153-226
Timestamp: 2025-06-10T00:50:20.795Z
Learning: In apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/assets/create/nft/launch-nft.tsx, the updateStatus function correctly expects a complete MultiStepState["status"] object. For pending states, { type: "pending" } is the entire status object. For error states, { type: "error", message: React.ReactNode } is the entire status object. The current code incorrectly spreads the entire step object instead of passing just the status object.

Learnt from: gregfromstl
PR: #7450
File: packages/thirdweb/src/bridge/Webhook.ts:57-81
Timestamp: 2025-06-26T19:46:04.024Z
Learning: In the onramp webhook schema (packages/thirdweb/src/bridge/Webhook.ts), the currencyAmount field is intentionally typed as z.number() while other amount fields use z.string() because currencyAmount represents fiat currency amounts in decimals (like $10.50), whereas other amount fields represent token amounts in wei (very large integers that benefit from bigint representation). The different naming convention (currencyAmount vs amount) reflects this intentional distinction.

Learnt from: CR
PR: thirdweb-dev/js#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-18T19:19:55.613Z
Learning: Applies to apps/{dashboard,playground-web}/**/*.{ts,tsx} : Use design system tokens (e.g., bg-card, border-border, text-muted-foreground)

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : Always import from the central UI library under @/components/ui/* – e.g. import { Button } from "@/components/ui/button".

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : For notices & skeletons rely on AnnouncementBanner, GenericLoadingPage, EmptyStateCard.

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : Merge class names with cn from @/lib/utils to keep conditional logic readable.

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard//components//index.ts : Group related components in their own folder and expose a single barrel index.ts where necessary.

Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/components/*.client.tsx : Client components must start with 'use client'; before imports.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Size
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/components/credit-balance-section.client.tsx (5)

14-14: LGTM: Proper UI component import

The Input component import follows the established pattern of importing from the central UI library.


43-43: LGTM: Well-typed state variable

The customAmount state is properly typed as a string, which is appropriate for handling input values before validation.


84-87: LGTM: Proper state synchronization

The RadioGroup handler correctly clears the custom amount when a predefined amount is selected, maintaining proper state synchronization between the two input methods.


162-162: LGTM: Comprehensive button validation

The button's disabled condition correctly combines both permission check (!isOwnerAccount) and amount validation (!isSelectedAmountValid), ensuring users can only proceed with valid amounts.


45-48: Improve validation logic for better user experience

The validation logic has a potential issue: it will consider an empty string as invalid, but when users clear the input, selectedAmount becomes an empty string, making the button always disabled during typing.

Consider this improved validation:

-  const isSelectedAmountValid =
-    selectedAmount !== "" &&
-    Number.isInteger(Number(selectedAmount)) &&
-    Number(selectedAmount) > 0;
+  const isSelectedAmountValid = (() => {
+    if (selectedAmount === "") return false;
+    const num = Number(selectedAmount);
+    return Number.isInteger(num) && num > 0;
+  })();

This approach makes the validation more explicit and handles edge cases better.

⛔ Skipped due to learnings
Learnt from: CR
PR: thirdweb-dev/js#0
File: .cursor/rules/dashboard.mdc:0-0
Timestamp: 2025-07-18T19:20:32.530Z
Learning: Applies to dashboard/**/*.{tsx,jsx} : Prefer composable primitives over custom markup: `Button`, `Input`, `Select`, `Tabs`, `Card`, `Sidebar`, `Separator`, `Badge`.

@github-actions
Copy link
Contributor

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 63.33 KB (0%) 1.3 s (0%) 245 ms (+97.84% 🔺) 1.6 s
thirdweb (cjs) 353.15 KB (0%) 7.1 s (0%) 995 ms (+10.7% 🔺) 8.1 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 99 ms (+1538.71% 🔺) 213 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 22 ms (+502.24% 🔺) 32 ms
thirdweb/react (minimal + tree-shaking) 19.22 KB (0%) 385 ms (0%) 120 ms (+656.33% 🔺) 504 ms

@jnsdls jnsdls merged commit 48361f9 into main Jul 24, 2025
27 checks passed
@jnsdls jnsdls deleted the Add_custom_amount_input_to_credit_balance_section branch July 24, 2025 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dashboard Involves changes to the Dashboard.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants