feat(billing): split add-credits sheet into purchase and coupon tabs#3403
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds coupon redemption, tabbed credit purchasing, coupon-aware payment polling, sheet/onboarding callbacks, and updated invoice webhook top-up behavior. ChangesCoupon redemption and tabbed credits UI
Coupon-aware polling and invoice top-ups
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3403 +/- ##
==========================================
- Coverage 71.98% 71.01% -0.97%
==========================================
Files 1153 1065 -88
Lines 29228 26991 -2237
Branches 7207 6779 -428
==========================================
- Hits 21041 19169 -1872
+ Misses 7191 6858 -333
+ Partials 996 964 -32
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/deploy-web/src/components/billing-usage/RedeemCouponForm/RedeemCouponForm.tsx`:
- Around line 90-106: The redeem flow in RedeemCouponForm’s coupon submit
handler only shows feedback when applyCoupon returns an error or a positive
amountAdded, so successful zero-credit responses leave the user with no message.
Update the branch in RedeemCouponForm’s submit logic to add a fallback
success/info alert when response.error is absent and amountAdded is missing or
0, while keeping the existing pollForPayment, setSuccessAmount, and form.reset
behavior only for positive credits.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 66c53710-8e95-4647-8269-6e6aa19ace32
📒 Files selected for processing (6)
apps/deploy-web/src/components/auth/AddCreditsSheet/AddCreditsSheet.spec.tsxapps/deploy-web/src/components/auth/AddCreditsSheet/AddCreditsSheet.tsxapps/deploy-web/src/components/billing-usage/AddCreditsTabs/AddCreditsTabs.spec.tsxapps/deploy-web/src/components/billing-usage/AddCreditsTabs/AddCreditsTabs.tsxapps/deploy-web/src/components/billing-usage/RedeemCouponForm/RedeemCouponForm.spec.tsxapps/deploy-web/src/components/billing-usage/RedeemCouponForm/RedeemCouponForm.tsx
Reorganize the redesigned Add Credits sheet into two tabs: "Purchase credits" (the existing purchase flow, unchanged) and "Redeem coupon" (a new inline coupon-redemption flow). Adds: - RedeemCouponForm: reuses usePaymentMutations().applyCoupon, usePaymentPolling().pollForPayment and handleCouponError; feedback is inline (success/destructive Alert), the sheet stays open, and the redeem button is gated on wallet readiness. - AddCreditsTabs: controlled Radix tabs wrapper that lazy-mounts each flow, aggregates processing state from both children for the sheet's close-guard, and disables the inactive trigger mid-transaction. - AddCreditsSheet: renders the tabs, threads an initialTab prop, and uses the generic free-plan header copy. No backend changes — coupon apply already exists end-to-end. Ref CON-368
Coupon-claim invoice top-ups now end the user's trial like a card purchase does, so redeeming a coupon unlocks GPU access and the full plan. Reverses the coupon carve-out added in #2780.
…dback
- Show the redeemed coupon amount as a dollar value instead of "N credits"
- Auto-close the add-credits sheet shortly after a successful redeem and
return to the onboarding picker (no auto-deploy)
- Use coupon-specific snackbar copy ("Applying coupon..." / "Coupon
applied!") instead of the payment wording during the balance poll
2a6b26e to
c655c62
Compare
The split-tabs refactor changed the sheet copy to generic free-plan wording; restore the template-specific description that main uses.
Why
With coupons now being fixed-amount Stripe credits, the redesigned Add credits sheet needs a clear split between buying credit and redeeming a coupon. Today the new sheet only has a purchase flow; coupon redemption lives only in the legacy
PaymentPopup.Ref CON-368
What
Reorganizes the redesigned Add Credits sheet into two tabs — Purchase credits and Redeem coupon — reusing the existing coupon mutation and error handling. No backend changes (coupon apply already exists end-to-end).
RedeemCouponForm(new): reusesusePaymentMutations().applyCoupon,usePaymentPolling().pollForPayment, andhandleCouponError. Feedback is inline (success/destructiveAlert); on success it polls to refresh the balance, shows a confirmation, and resets the field — the sheet stays open so the user closes it via the X. The redeem button is gated on wallet readiness with a "Setting up your account…" hint.AddCreditsTabs(new): controlled Radix tabs wrapper. Only the active tab's content is mounted (so the purchase tab's Stripe SetupIntent lazy-mounts and the coupon form resets on switch). Aggregates processing state from both children for the sheet's close-guard and disables the inactive trigger mid-transaction.AddCreditsSheet(edit): rendersAddCreditsTabs, threads a newinitialTabprop, and uses the generic free-plan header copy. Close-guard behavior preserved.The legacy
PaymentPopupis left untouched.Follow-up (PR 2, out of scope here): hackathon entry points behind a
hackathonsfeature flag that open the sheet withinitialTab="coupon".Tests
Colocated
*.spec.tsxfor all three components (18 tests): coupon success/error/empty/wallet-gating/processing, tab default/initial/aggregated-processing/inactive-disable, and sheet render/thread/close-guard.Summary by CodeRabbit