chore(billing): use new balance endpoint#45481
Conversation
We moved customer balance to a separate balance endpoint
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
This pull request has been ignored for the connected project Preview Branches by Supabase. |
📝 WalkthroughWalkthroughLazy organization credit balance fetching was added: a new balance API and React Query hook gated by billing-read permission and viewport visibility; UI components now consume this hook; several mutation success handlers invalidate the balance query to refresh state. ChangesOrganization Balance Query System
Sequence DiagramsequenceDiagram
participant User as User (Viewport)
participant Component as CreditBalance Component
participant Observer as IntersectionObserver
participant PermCheck as Permission Check
participant Query as useOrgBalanceQuery
participant API as Balance API
User->>Observer: Scrolls to CreditBalance section
Observer->>Component: Marks section in view (triggerOnce)
Component->>PermCheck: Check BILLING_READ permission
PermCheck-->>Component: Permission result
alt permission granted
Component->>Query: Enable query (enabled=true)
Query->>API: GET /platform/organizations/{slug}/billing/credits/balance
API-->>Query: CreditBalanceResponse
Query-->>Component: Balance data
Component->>Component: Compute combinedCreditBalance, hasCredits/hasDebt
Component-->>User: Render balance UI
else permission denied
Component-->>User: No balance data shown
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@apps/studio/components/interfaces/Organization/BillingSettings/CreditCodeRedemption.tsx`:
- Around line 60-63: The balance query is currently enabled with the prop
modalVisible instead of the component's runtime dialog state, so
useOrgBalanceQuery({ orgSlug: slug }, { enabled: modalVisible }) never fires
when the dialog is opened; change the enabled flag to the dialog's actual open
state variable used by the dialog trigger (e.g., open / isOpen / isDialogOpen)
instead of modalVisible. Locate useOrgBalanceQuery and replace the enabled
reference to point to the dialog control variable used around the Dialog trigger
(the one paired with setOpen or isOpen) so the query only enables when the
dialog is actually open.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro
Run ID: d3a72119-7c00-43e9-a3bc-f9ad09eb80d7
📒 Files selected for processing (9)
apps/studio/components/interfaces/Organization/BillingSettings/CreditBalance.tsxapps/studio/components/interfaces/Organization/BillingSettings/CreditCodeRedemption.tsxapps/studio/components/interfaces/Organization/BillingSettings/CreditTopUp.tsxapps/studio/data/organizations/organization-credit-code-redemption-mutation.tsapps/studio/data/subscriptions/keys.tsapps/studio/data/subscriptions/org-balance-query.tsapps/studio/data/subscriptions/org-subscription-confirm-pending-change.tsapps/studio/data/subscriptions/org-subscription-update-mutation.tspackages/api-types/types/platform.d.ts
🎭 Playwright Test ResultsDetails
Skipped testsFeatures › auth-users.spec.ts › should show web3 users as enabled when the matching web3 provider is enabled |
Braintrust eval report
|
New billing credits balance endpoint for improved transparency