Skip to content

Conversation

@jnsdls
Copy link
Member

@jnsdls jnsdls commented Oct 3, 2025

TL;DR

Fixed invoice status logic and refactored invoice-related functions for better code organization.

What changed?

  • Extracted getStatusBadge and isInvoicePayable functions from the component to the module level
  • Fixed a bug in the "Past Due" badge logic - it was showing "Past Due" when the due date was in the future (inverted condition)
  • Updated the pay button visibility logic to use the new isInvoicePayable function instead of checking only for "open" status

How to test?

  1. Navigate to the billing/invoices page for a team
  2. Verify that invoices with status "open" or "uncollectible" show the payment button
  3. Verify that invoices with due dates in the past correctly show "Past Due" badge
  4. Verify that invoices with due dates in the future correctly show "Open" badge

Why make this change?

The previous implementation had a logic error in the "Past Due" badge condition, showing the wrong status for invoices. Additionally, refactoring the functions improves code organization and makes the invoice payment logic more consistent by using a dedicated function to determine if an invoice is payable.


PR-Codex overview

This PR refactors the getStatusBadge function in the billing-history.tsx file and introduces a new function isInvoicePayable. These changes improve the handling of invoice statuses and their display in the billing history component.

Detailed summary

  • Moved the getStatusBadge function to a standalone function.
  • Introduced a new function isInvoicePayable to check if an invoice can be paid.
  • Simplified the logic for determining badge display based on invoice status.
  • Updated the condition for rendering the payment button in the UI.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Summary by CodeRabbit

  • New Features

    • None.
  • Bug Fixes

    • Correctly marks invoices as “Past due” using the effective due date.
    • Shows payment options only when an invoice is payable (open or uncollectible).
    • Improves accuracy of invoice status badges.
  • Refactor

    • Simplified billing history by extracting status/payable helpers to top-level, removing inline logic for clearer, more maintainable code.

@changeset-bot
Copy link

changeset-bot bot commented Oct 3, 2025

⚠️ No Changeset found

Latest commit: 7a2dd35

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

@vercel vercel bot temporarily deployed to Preview – nebula October 3, 2025 03:30 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 October 3, 2025 03:30 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui October 3, 2025 03:30 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground October 3, 2025 03:30 Inactive
@vercel
Copy link

vercel bot commented Oct 3, 2025

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

Project Deployment Preview Comments Updated (UTC)
thirdweb-www Ready Ready Preview Comment Oct 3, 2025 3:54am
4 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs-v2 Skipped Skipped Oct 3, 2025 3:54am
nebula Skipped Skipped Oct 3, 2025 3:54am
thirdweb_playground Skipped Skipped Oct 3, 2025 3:54am
wallet-ui Skipped Skipped Oct 3, 2025 3:54am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Refactors BillingHistory by extracting getStatusBadge and isInvoicePayable helpers, replacing inline logic. Updates payment-option rendering to use isInvoicePayable. Adjusts past-due comparison to use invoice.due_date directly against Date.now(), implying unit change. Removes the previous inline getStatusBadge and defines helpers at module scope.

Changes

Cohort / File(s) Summary of Changes
Billing history helpers and payable logic
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/invoices/components/billing-history.tsx
- Extracted top-level helpers: getStatusBadge(invoice), isInvoicePayable(invoice)
- Replaced status === "open" check with isInvoicePayable()
- Past-due check now compares due_date directly to Date.now()
- Removed inline getStatusBadge inside component
- Minor structural shift: helpers defined outside component

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant UI as BillingHistory
  participant H1 as getStatusBadge
  participant H2 as isInvoicePayable

  User->>UI: View invoices
  UI->>H1: getStatusBadge(invoice.status)
  H1-->>UI: React node (badge)

  UI->>H2: isInvoicePayable(invoice)
  alt Invoice payable (open/uncollectible)
    UI-->>User: Render crypto/card payment options
  else Not payable
    UI-->>User: Hide payment options
  end

  Note over UI,H2: Past-due check compares invoice.due_date directly to Date.now()
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run `@coderabbitai generate docstrings` to improve docstring coverage.
Description Check ⚠️ Warning The pull request description does not follow the repository’s template: it lacks the required “## title your PR with this format…” header, omits the Linear issue tag section, and is missing the “## Notes for the reviewer” section. Although it includes a How to test section, the header level and content do not match the template exactly. Update the PR description to match the repository template by adding a properly formatted title line, including the Linear issue tag if needed, inserting a “## Notes for the reviewer” section, and ensuring the “## How to test” heading and content match the template exactly.
✅ Passed checks (1 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly summarizes the main changes by highlighting the fix to invoice status logic and the refactoring of billing components, matching the core purpose of the PR.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch Fix_invoice_status_logic_and_refactor_billing_components

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

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Oct 3, 2025
Copy link
Member Author

jnsdls commented Oct 3, 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.

@jnsdls jnsdls marked this pull request as ready for review October 3, 2025 03:31
@jnsdls jnsdls requested review from a team as code owners October 3, 2025 03:31
@jnsdls jnsdls force-pushed the Fix_invoice_status_logic_and_refactor_billing_components branch from 7210b29 to 41bac4a Compare October 3, 2025 03:32
@vercel vercel bot temporarily deployed to Preview – nebula October 3, 2025 03:32 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui October 3, 2025 03:32 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 October 3, 2025 03:32 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground October 3, 2025 03:32 Inactive
@codecov
Copy link

codecov bot commented Oct 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 56.29%. Comparing base (2dbb9e2) to head (7a2dd35).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8175   +/-   ##
=======================================
  Coverage   56.29%   56.29%           
=======================================
  Files         906      906           
  Lines       59209    59209           
  Branches     4182     4182           
=======================================
  Hits        33330    33330           
  Misses      25774    25774           
  Partials      105      105           
Flag Coverage Δ
packages 56.29% <ø> (ø)
🚀 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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2dbb9e2 and 41bac4a.

📒 Files selected for processing (1)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/invoices/components/billing-history.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
**/*.{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

**/*.{ts,tsx}: Use explicit function declarations and explicit return types in TypeScript
Limit each file to one stateless, single‑responsibility function
Re‑use shared types from @/types where applicable
Prefer type aliases over interface except for nominal shapes
Avoid any and unknown unless unavoidable; narrow generics when possible
Prefer composition over inheritance; use utility types (Partial, Pick, etc.)
Lazy‑import optional features and avoid top‑level side‑effects to reduce bundle size

Files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/invoices/components/billing-history.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/invoices/components/billing-history.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/invoices/components/billing-history.tsx
apps/{dashboard,playground}/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

apps/{dashboard,playground}/**/*.{ts,tsx}: Import UI primitives from @/components/ui/_ (e.g., Button, Input, Tabs, Card)
Use NavLink for internal navigation to get active state handling
Use Tailwind CSS for styling; no inline styles
Merge class names with cn() from @/lib/utils for conditional classes
Stick to design tokens (e.g., bg-card, border-border, text-muted-foreground)
Server Components must start with import "server-only"; use next/headers, server‑only env, heavy data fetching, and redirect() where appropriate
Client Components must start with 'use client'; handle interactivity with hooks and browser APIs
Server-side data fetching: call getAuthToken() from cookies, send Authorization: Bearer <token> header, and return typed results (avoid any)
Client-side data fetching: wrap calls in React Query with descriptive, stable queryKeys and set sensible staleTime/cacheTime (≥ 60s default); keep tokens secret via internal routes or server actions
Do not import posthog-js in server components (client-side only)

Files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/invoices/components/billing-history.tsx
apps/{dashboard,playground}/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Expose a className prop on the root element of every component

Files:

  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/invoices/components/billing-history.tsx
⏰ 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). (2)
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/billing/invoices/components/billing-history.tsx (2)

49-51: LGTM!

The helper function correctly identifies payable invoices by including both "open" and "uncollectible" statuses, which aligns with the business logic.


133-133: LGTM! Improved payment logic consistency.

The refactored payment button visibility now correctly includes both "open" and "uncollectible" invoices, which aligns with the intended business logic as mentioned in the PR objectives.

@jnsdls jnsdls force-pushed the Fix_invoice_status_logic_and_refactor_billing_components branch from 41bac4a to 93a0a03 Compare October 3, 2025 03:36
@vercel vercel bot temporarily deployed to Preview – wallet-ui October 3, 2025 03:36 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula October 3, 2025 03:36 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground October 3, 2025 03:36 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 October 3, 2025 03:36 Inactive
@jnsdls jnsdls force-pushed the Fix_invoice_status_logic_and_refactor_billing_components branch from 93a0a03 to c6cb579 Compare October 3, 2025 03:37
@vercel vercel bot temporarily deployed to Preview – wallet-ui October 3, 2025 03:37 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground October 3, 2025 03:37 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 October 3, 2025 03:37 Inactive
@vercel vercel bot temporarily deployed to Preview – nebula October 3, 2025 03:37 Inactive
@jnsdls jnsdls force-pushed the Fix_invoice_status_logic_and_refactor_billing_components branch from c6cb579 to 7a2dd35 Compare October 3, 2025 03:38
@vercel vercel bot temporarily deployed to Preview – nebula October 3, 2025 03:38 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground October 3, 2025 03:38 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 October 3, 2025 03:38 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui October 3, 2025 03:38 Inactive
@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 64.6 KB (0%) 1.3 s (0%) 278 ms (+246.41% 🔺) 1.6 s
thirdweb (cjs) 365.75 KB (0%) 7.4 s (0%) 916 ms (+18.27% 🔺) 8.3 s
thirdweb (minimal + tree-shaking) 5.73 KB (0%) 115 ms (0%) 139 ms (+3841.48% 🔺) 254 ms
thirdweb/chains (tree-shaking) 526 B (0%) 11 ms (0%) 50 ms (+1860.48% 🔺) 60 ms
thirdweb/react (minimal + tree-shaking) 19.13 KB (0%) 383 ms (0%) 71 ms (+1734.64% 🔺) 453 ms

@jnsdls jnsdls merged commit 9095041 into main Oct 3, 2025
23 of 24 checks passed
@jnsdls jnsdls deleted the Fix_invoice_status_logic_and_refactor_billing_components branch October 3, 2025 03:44
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