Skip to content

account payments tab fix#1147

Merged
N2D4 merged 3 commits intodevfrom
fix-account-payments-tab
Feb 2, 2026
Merged

account payments tab fix#1147
N2D4 merged 3 commits intodevfrom
fix-account-payments-tab

Conversation

@BilalG1
Copy link
Copy Markdown
Collaborator

@BilalG1 BilalG1 commented Feb 2, 2026

Summary by CodeRabbit

  • New Features

    • Payments tab visibility is now conditional, appearing only when products are available for users or teams
    • Improved team selection in payment settings with automatic first-team selection and better data synchronization
    • Enhanced support for managing payments across multiple teams
  • Style

    • Minor import formatting updates

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
stack-backend Ready Ready Preview, Comment Feb 2, 2026 10:54pm
stack-dashboard Ready Ready Preview, Comment Feb 2, 2026 10:54pm
stack-demo Ready Ready Preview, Comment Feb 2, 2026 10:54pm
stack-docs Ready Ready Preview, Comment Feb 2, 2026 10:54pm

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 2, 2026

📝 Walkthrough

Walkthrough

This PR introduces conditional payment tab visibility and team management for the account settings component. It adds asynchronous data fetching to determine payment availability, expands PaymentsPage with new props for team filtering and personal mode control, and updates TeamSwitcher to accept teams from props.

Changes

Cohort / File(s) Summary
Formatting Changes
apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/analytics/tables/page-client.tsx, apps/dashboard/src/components/commands/run-query.tsx
Import statement re-indentation and alignment with no functional modifications.
Payments Feature Implementation
packages/template/src/components-page/account-settings.tsx, packages/template/src/components-page/account-settings/payments/payments-page.tsx, packages/template/src/components/team-switcher.tsx
Adds async payment availability detection in AccountSettings, expands PaymentsPage props for team filtering and personal mode control, and updates TeamSwitcher to accept optional teams prop for conditional team data sourcing.

Sequence Diagram(s)

sequenceDiagram
    participant AccountSettings
    participant AsyncFetch as Async Data Fetch
    participant PaymentsPage
    participant TeamSwitcher

    AccountSettings->>AccountSettings: Component mounts
    activate AccountSettings
    AccountSettings->>AsyncFetch: runAsynchronouslyWithAlert: fetch payment availability
    activate AsyncFetch
    AsyncFetch->>AsyncFetch: Check user/team products
    AsyncFetch-->>AccountSettings: Return paymentsAvailability data
    deactivate AsyncFetch
    AccountSettings->>AccountSettings: Compute shouldShowPaymentsTab
    alt shouldShowPaymentsTab === true
        AccountSettings->>PaymentsPage: Render with props (allowPersonal, availableTeams)
        activate PaymentsPage
        PaymentsPage->>PaymentsPage: useEffect: Sync team selection
        PaymentsPage->>TeamSwitcher: Pass teams prop and allowPersonal
        activate TeamSwitcher
        TeamSwitcher->>TeamSwitcher: Source teams from props.teams
        deactivate TeamSwitcher
        deactivate PaymentsPage
    else shouldShowPaymentsTab === false
        AccountSettings->>AccountSettings: Skip Payments tab rendering
    end
    deactivate AccountSettings
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • show products in account settings #1071: Directly related modifications to PaymentsPage, PaymentsPanel, TeamSwitcher, and customer billing hooks with overlapping account-settings payments UI changes.

Suggested reviewers

  • N2D4

Poem

🐰 Payments flow through the async breeze,
Teams now switchable with such ease,
Props and hooks dance side by side,
Availability checks open up wide,
The account page blooms anew! 🌸

🚥 Pre-merge checks | ❌ 3
❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is empty beyond a template comment. It provides no context about the changes, motivations, or specific details about the payments tab fix. Add a detailed description explaining the problem, the solution implemented, which components were affected, and how the new props (allowPersonal, availableTeams) are used to conditionally show the payments tab.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'account payments tab fix' is vague and overly generic. While it references 'account payments tab', it doesn't specify what the fix addresses or what the actual problem and solution are. Provide a more specific title that describes the actual problem being fixed, such as 'Fix payments tab visibility based on product ownership' or 'Make payments tab conditional on user/team products'.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-account-payments-tab

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 2, 2026

Greptile Overview

Greptile Summary

This PR implements conditional visibility for the Payments tab in account settings. The tab now only shows when users or their teams have associated products, preventing empty payment pages.

Key Changes:

  • Added product availability checking that runs on mount to determine if user/teams have products
  • Payments tab conditionally rendered based on shouldShowPaymentsTab flag
  • PaymentsPage now accepts availableTeams and allowPersonal props to control which payment options are shown
  • TeamSwitcher accepts optional teams prop to filter available teams
  • Auto-selects first team when personal payments are disallowed
  • Minor formatting fixes (2-space indentation) in dashboard files

Issues Found:

  • Missing dependency in useEffect array (line 21-32 in payments-page.tsx) could cause stale closure bugs
  • Misleading variable name teamsById that doesn't actually create an ID lookup
  • Custom error handler could be simplified by removing onError callback

Confidence Score: 3/5

  • Safe to merge after fixing the missing dependency array issue in payments-page.tsx
  • The missing teams dependency in the useEffect hook (payments-page.tsx:21-32) will cause the effect not to re-run when teams change, leading to stale state bugs. This should be fixed before merging. The other issues are style suggestions that can be addressed later.
  • packages/template/src/components-page/account-settings/payments/payments-page.tsx needs the missing dependency fix

Important Files Changed

Filename Overview
packages/template/src/components/team-switcher.tsx Added optional teams prop to allow filtering available teams in the switcher
packages/template/src/components-page/account-settings/payments/payments-page.tsx Added props to control personal/team payment visibility and logic to auto-select first team when personal is disallowed
packages/template/src/components-page/account-settings.tsx Added product availability checking logic that conditionally shows payments tab based on user/team products

Sequence Diagram

sequenceDiagram
    participant User
    participant AccountSettings
    participant PaymentsPage
    participant TeamSwitcher
    participant API

    User->>AccountSettings: Load account settings
    activate AccountSettings
    
    alt Products check
        AccountSettings->>API: listProducts() for user
        AccountSettings->>API: listProducts() for each team (if team_admin)
        API-->>AccountSettings: Product lists
        AccountSettings->>AccountSettings: Calculate paymentsAvailability
        AccountSettings->>AccountSettings: Determine shouldShowPaymentsTab
    end
    
    alt shouldShowPaymentsTab = true
        AccountSettings->>PaymentsPage: Render with availableTeams & allowPersonal
        activate PaymentsPage
        
        PaymentsPage->>PaymentsPage: Initialize selectedTeam state
        
        alt !allowPersonal && !selectedTeam && teams.length > 0
            PaymentsPage->>PaymentsPage: Auto-select teams[0]
        end
        
        alt hasTeams
            PaymentsPage->>TeamSwitcher: Render with filtered teams
            activate TeamSwitcher
            User->>TeamSwitcher: Select team/personal
            TeamSwitcher->>PaymentsPage: onChange(team)
            PaymentsPage->>PaymentsPage: setSelectedTeam(team)
            deactivate TeamSwitcher
        end
        
        PaymentsPage->>PaymentsPage: Render PaymentsPanel with customer
        deactivate PaymentsPage
    else shouldShowPaymentsTab = false
        AccountSettings->>AccountSettings: Hide Payments tab
    end
    
    deactivate AccountSettings
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment thread packages/template/src/components-page/account-settings.tsx
Comment thread packages/template/src/components-page/account-settings.tsx
@BilalG1 BilalG1 requested a review from N2D4 February 2, 2026 18:51
@BilalG1 BilalG1 assigned N2D4 and unassigned BilalG1 Feb 2, 2026
Copy link
Copy Markdown
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: 2

🤖 Fix all issues with AI agents
In
`@packages/template/src/components-page/account-settings/payments/payments-page.tsx`:
- Around line 3-19: The code conditionally calls the hook-like method
user?.useTeams(), breaking the Rules of Hooks; fix by introducing and calling a
stable hook (e.g., useTeamsFromUser) unconditionally at the top of PaymentsPage
that always runs and returns the user's teams or [] when no user exists, then
replace user?.useTeams() with that result (update usages: teams, hasTeams,
effectiveSelectedTeam, customer). Ensure the new hook (useTeamsFromUser)
internally handles the null user case and returns an array so PaymentsPage can
safely use props.availableTeams ?? userTeams ?? [] without conditional hook
invocation.

In `@packages/template/src/components/team-switcher.tsx`:
- Around line 80-82: The code conditionally calls the React hook user.useTeams()
which can break hook order; call useTeams() unconditionally and then choose
between props.teams and the result. Specifically, invoke user.useTeams() every
render (e.g., assign to a local like userTeams), then set rawTeams = props.teams
?? userTeams, leaving selectedTeam and the useMemo for teams unchanged; this
ensures the hook ordering for user.useTeams() (referencing props.teams,
user.useTeams(), rawTeams, selectedTeam, useMemo).

Comment thread packages/template/src/components/team-switcher.tsx
@N2D4 N2D4 merged commit 0f6ae49 into dev Feb 2, 2026
21 of 28 checks passed
@N2D4 N2D4 deleted the fix-account-payments-tab branch February 2, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants