Skip to content

refactor: migrate Critical Components: Payment.js#7004

Draft
talissoncosta wants to merge 4 commits intomainfrom
refactor/migrate-payment-component-6319
Draft

refactor: migrate Critical Components: Payment.js#7004
talissoncosta wants to merge 4 commits intomainfrom
refactor/migrate-payment-component-6319

Conversation

@talissoncosta
Copy link
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Contributes to #6319

Migrate Payment.js from a monolithic class component to modular functional components with TypeScript, behind a feature flag (rtk_payment).

  • Split into focused presentational components: PricingPanel, PricingToggle, PricingFeaturesList, PaymentButton
  • Extract business logic into custom hooks: usePaymentState, useChargebeeCheckout
  • Extract types (Chargebee SDK globals, PricingFeature), constants, and pricing config
  • Hooks currently wrap Flux stores — RTK Query swap planned as follow-up PR
  • Old Payment.js preserved untouched — feature flag toggles at BillingTab level

Follow-up PRs

  1. RTK Query migration (swap Flux → RTK inside hooks, no component changes)
  2. RTL tests for hooks and components
  3. Storybook stories (once Storybook is on main)

How did you test this code?

  • TypeScript compiles with no errors
  • ESLint passes
  • Manual testing pending with feature flag enabled

🤖 Generated with Claude Code

talissoncosta and others added 4 commits March 18, 2026 16:48
…ents

Split the monolithic Payment.js into smaller focused modules:
- types.ts: Chargebee SDK global types and shared PricingFeature type
- constants.ts: URLs, support email, icon colours
- pricingFeatures.tsx: startup and enterprise feature lists
- PricingFeaturesList.tsx: feature list rendering
- PricingToggle.tsx: annual/monthly toggle
- PricingPanel.tsx: pricing card with plan details and CTA

All components are pure presentational — they receive data via props
and contain no business logic or store dependencies.

Ref: #6319

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Decouple business logic from UI to enable independent testing:
- usePaymentState: organisation data, plan detection, AWS check, billing toggle
- useChargebeeCheckout: Chargebee SDK checkout flow and hosted page URL

Hooks currently wrap Flux stores (AccountStore, AppActions) — these
will be swapped to RTK Query in a follow-up PR without touching
the components or hook API.

Ref: #6319

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire up the main Payment component and PaymentButton to use the
extracted hooks (usePaymentState, useChargebeeCheckout) instead of
directly accessing Flux stores.

Add index.tsx barrel export with Chargebee async script loader wrapper.

Ref: #6319

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Toggle between legacy Payment.js and the new modular payment/
components in BillingTab using the rtk_payment feature flag.

When the flag is off, behaviour is unchanged. Old Payment.js is
preserved untouched for safe rollback.

Ref: #6319

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 20, 2026

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

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Mar 20, 2026 3:19pm
flagsmith-frontend-staging Ready Ready Preview, Comment Mar 20, 2026 3:19pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Mar 20, 2026 3:19pm

Request Review

@github-actions github-actions bot added the front-end Issue related to the React Front End Dashboard label Mar 20, 2026
@talissoncosta talissoncosta changed the title Migrate Critical Components: Payment.js refactor: migrate Critical Components: Payment.js Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant