[PULSE-10] Billing usage in dashboard – frontend #9
Reference in New Issue
Block a user
No description provided.
Delete Branch "staging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Work Item
PULSE-10
Summary
Changes
SubscriptionDetailswith optionalsites_countandpageview_usage(for backward compatibility).useSearchParamsto syncactiveTabfrom?tab=billingor?tab=members(initial state +useEffect). Billing tab: in the Current Plan card, added Sites (e.g.3or1/1for Solo) and Pageviews this period (e.g.X / Ywhenpageview_limit > 0); grid expanded to five columns (Sites, Pageviews this period, Billing Interval, Pageview Limit, Renews On)./pricing) or Manage billing (→/org-settings?tab=billing) depending onhas_payment_method.<OrganizationSettings />in<Suspense fallback={...}>souseSearchParams()is used inside a Suspense boundary (fixes Next.js prerender for/org-settings).Test Plan
/pricing; “Manage billing” links to/org-settings?tab=billingand opens the Billing tab.npm run buildpasses (including/org-settingswith Suspense).Greptile Overview
Greptile Summary
This PR adds billing usage information (sites count and pageviews) to both the dashboard home page and Organization Settings → Billing tab. The changes properly handle optional fields for backward compatibility and implement deep linking to the Billing tab via
?tab=billingquery parameter.Key Changes:
SubscriptionDetailsAPI interface with optionalsites_countandpageview_usagefieldspageview_limit > 0(shows "Unlimited" otherwise)OrganizationSettingsin Suspense boundary to fix Next.js prerender withuseSearchParams()useEffectinfinite loop with proper guard conditionImplementation Quality:
typeofguardsConfidence Score: 5/5
Important Files Changed
Sequence Diagram
4 files reviewed, 2 comments
Edit Code Review Agent Settings | Greptile
For a Solo plan with 0 sites, this displays "Sites: 0/1". For consistency with free plans and better UX, showing just "0" might be clearer when there are no sites yet.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Prompt To Fix With AI
@@ -135,6 +139,13 @@ export default function OrganizationSettings() {}This
useEffectcan cause infinite re-renders if the URL updates programmatically. WhensetActiveTabis called, if other code updates the URL, it will trigger this effect again. Consider adding a guard or removing this effect since initial state is already set fromsearchParamsin theuseStateinitializer.Prompt To Fix With AI
Change: For Solo, show the “X/1” format only when there is at least one site; when there are 0 sites, show just “0” (same style as free plans).
How: Replaced
subscription.plan_id === 'solo' ? ${subscription.sites_count}/1\ : subscription.sites_count
with
subscription.plan_id === 'solo' && subscription.sites_count > 0 ? ${subscription.sites_count}/1\ : subscription.sites_count.
Result: Solo with 0 sites now shows “Sites: 0” instead of “Sites: 0/1”; Solo with 1+ sites still shows “Sites: 1/1”.
@@ -135,6 +139,13 @@ export default function OrganizationSettings() {}Change: Only call setActiveTab(tab) when the tab from the URL is different from the current activeTab.
How: Added && tab !== activeTab so we don’t set state when the URL and state already match, and added activeTab to the effect dependency array so the guard is correct.
Result: The effect no longer triggers repeated updates when the URL is updated programmatically; it only syncs when the URL tab actually changes (e.g. client-side navigation to ?tab=billing).
4 files reviewed, 1 comment
Edit Code Review Agent Settings | Greptile
Additional Comments (1)
components/settings/OrganizationSettings.tsxFor free plans with
pageview_limit: 0, this displays "0 / month" which is inconsistent with the conditional rendering used in the "Pageviews this period" field above (line 621) which shows "—" when limit is 0.Prompt To Fix With AI