-
Notifications
You must be signed in to change notification settings - Fork 370
chore(clerk-js,types,localizations): Refactor statement page and payment attempt page #6420
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 56352ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@clerk/agent-toolkit
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/elements
@clerk/clerk-expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/clerk-react
@clerk/react-router
@clerk/remix
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/themes
@clerk/types
@clerk/upgrade
@clerk/vue
commit: |
📝 WalkthroughWalkthroughThis change set refactors the data loading logic for the billing statement and payment attempt pages by introducing new asynchronous methods ( Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (9)
.changeset/slow-foxes-lay.md
(1 hunks)packages/clerk-js/bundlewatch.config.json
(2 hunks)packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
(2 hunks)packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
(2 hunks)packages/clerk-js/src/ui/components/Statements/Statement.tsx
(3 hunks)packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
(2 hunks)packages/localizations/src/en-US.ts
(1 hunks)packages/types/src/commerce.ts
(2 hunks)packages/types/src/localization.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (13)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/components/Statements/Statement.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/types/src/localization.ts
packages/clerk-js/bundlewatch.config.json
packages/localizations/src/en-US.ts
packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/components/Statements/Statement.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/components/Statements/Statement.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/components/Statements/Statement.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/components/Statements/Statement.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/types/src/localization.ts
packages/localizations/src/en-US.ts
packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/components/Statements/Statement.tsx
**/*
⚙️ CodeRabbit Configuration File
**/*
: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.Whenever reviewing a pull request, if there are any changes that could impact security, always tag
@clerk/security
in the PR.Security-impacting changes include, but are not limited to:
- Changes to authentication logic or mechanisms (e.g. login, session handling, token issuance)
- Any modification to access control, authorization checks, or role-based permissions
- Introduction or modification of hashing algorithms, signature verification, or cryptographic primitives
- Handling of sensitive data (e.g. passwords, tokens, secrets, PII)
- Integration with external identity providers (e.g. SSO, OAuth, OpenID Connect)
- Modifications to security headers, cookie flags, CORS policies, or CSRF protections
- Bypass mechanisms (e.g. feature flags, testing overrides) that could weaken protections
- Changes to rate limiting, abuse prevention, or input validation
If you're unsure whether a change is security-relevant, err on the side of caution and tag
@clerk/security
.Any time that you tag
@clerk/security
, please do so explicitly in a code comment, rather than within a collapsed section in a coderabbit comment, such as the "recent review details" section. If you do use the team name in any thinking or non-direct-code-comment content, it can be referred to as "clerk security team" to avoid accidentally printing the tag which sends a notification to the team.
Files:
packages/types/src/localization.ts
packages/clerk-js/bundlewatch.config.json
packages/localizations/src/en-US.ts
packages/types/src/commerce.ts
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
packages/clerk-js/src/ui/components/Statements/Statement.tsx
packages/localizations/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Localization files must be placed in 'packages/localizations/'.
Files:
packages/localizations/src/en-US.ts
**/localizations/**/*.ts
⚙️ CodeRabbit Configuration File
**/localizations/**/*.ts
: Review the changes to localization files with the following guidelines:
- Ensure that no existing translations are accidentally removed unless they are being replaced or fixed. If a string is removed, verify that it is intentional and justified.
- Check that all translations are friendly, formal, or semi-formal. Explicit, offensive, or inappropriate language is not allowed. If you find any potentially offensive language or are unsure, tag the @clerk/sdk-infra team in a separate comment. If you do not intend to tag the team, refer to it as "Clerk SDK Infra team" instead.
- Use the most up-to-date base localization file (https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts) to validate changes, ensuring consistency and completeness.
- Confirm that new translations are accurate, contextually appropriate, and match the intent of the original English strings.
- Check for formatting issues, such as missing placeholders, incorrect variable usage, or syntax errors.
- Ensure that all keys are unique and that there are no duplicate or conflicting entries.
- If you notice missing translations for new keys, flag them for completion.
Files:
packages/localizations/src/en-US.ts
.changeset/**
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Automated releases must use Changesets.
Files:
.changeset/slow-foxes-lay.md
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/ui/components/Statements/Statement.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/ui/components/Statements/Statement.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/clerk-js/src/ui/components/Statements/Statement.tsx
🧬 Code Graph Analysis (2)
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx (2)
packages/clerk-js/src/ui/contexts/components/SubscriberType.ts (2)
useSubscriberTypeContext
(7-7)useSubscriberTypeLocalizationRoot
(9-12)packages/react/src/isomorphicClerk.ts (1)
organization
(680-686)
packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts (1)
packages/types/src/commerce.ts (2)
CommerceStatementResource
(857-895)CommercePaymentResource
(732-816)
⏰ 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). (7)
- GitHub Check: pr-title-lint
- GitHub Check: pr-title-lint
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (15)
packages/localizations/src/en-US.ts (1)
150-151
: AddviewPayment
copy looks good – ensure parity across localesString is concise, capitalisation matches neighbouring keys (‘View features’).
Please confirm the new key has been added (even as a placeholder) to every other locale file to avoid runtime fall-backs.packages/types/src/localization.ts (1)
187-190
: Type addition is correct and consistent
viewPayment: LocalizationValue;
is correctly inserted in thecommerce
block and keeps the semi-colon style used throughout. No further action required.packages/clerk-js/bundlewatch.config.json (1)
4-7
: Raising bundle limits – double-check the actual size deltaThe thresholds for three bundles were bumped by ~0.2 KB each.
Before merging, please verify the current build indeed needs this head-room and that tree-shaking hasn’t regressed unexpectedly.Also applies to: 26-26
.changeset/slow-foxes-lay.md (1)
1-8
: Changeset validPackages and bump type are declared correctly; summary is clear. ✅
packages/clerk-js/src/ui/components/Statements/Statement.tsx (2)
1-1
: LGTM: React import added forReact.isValidElement()
The explicit React import is correctly added to support the new
React.isValidElement()
check in the rendering logic.
284-284
: LGTM: Well-implemented type extension to support React elementsThe changes correctly extend the
value
prop to accept React elements while maintaining backward compatibility. The rendering logic properly usesReact.isValidElement()
to handle the different value types, and the type assertion is safe given the conditional checks.This enhancement supports the PR's objective of adding interactive elements like the "View Payment" button in statement details.
Also applies to: 353-355, 360-360
packages/types/src/commerce.ts (2)
29-37
: LGTM: Consistent type definition for new payment attempt methodThe
getPaymentAttempt
method signature is well-defined with appropriate parameter types and return type. The experimental API documentation follows the established pattern and provides clear guidance for users.
92-100
: LGTM: Consistent type definition for new statement methodThe
getStatement
method signature mirrors the pattern established bygetPaymentAttempt
with consistent parameter types and return type. The experimental API documentation is appropriately included.packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts (2)
106-116
: LGTM: Consistent implementation following established patternsThe
getStatement
method correctly implements the expected functionality:
- Proper conditional path logic for organization vs user context
- Consistent API request structure with other methods in the class
- Appropriate response casting and resource wrapping
137-145
: LGTM: Consistent implementation mirroring the statement methodThe
getPaymentAttempt
method follows the same reliable pattern asgetStatement
with appropriate API endpoint paths for payment attempts and consistent response handling.packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx (2)
1-2
: LGTM: Appropriate imports and hooks for SWR-based data fetchingThe import changes correctly bring in the necessary dependencies for the new data fetching approach:
useClerk
anduseOrganization
for accessing the billing API and organization contextuseSWR
for the new data fetching pattern- Context imports were appropriately cleaned up
The hook usage follows established patterns and correctly provides the needed data and functions.
Also applies to: 9-9, 28-31
33-40
: LGTM: Well-structured SWR implementation for direct API fetchingThe SWR implementation effectively replaces the context-based data fetching:
- Proper conditional key structure prevents unnecessary requests
- Correct usage of the new
clerk.billing.getPaymentAttempt
method- Appropriate organization context handling based on subscriber type
- Clean separation of data fetching from component logic
This refactor aligns well with the PR's objective to fetch resources directly by ID rather than iterating through paginated cached data.
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx (3)
1-3
: LGTM! Import statements align with refactoring objectives.The new imports properly support the data fetching refactoring (useClerk, useOrganization, useSWR) and UI enhancements (SimpleButton, Icon, ArrowRightIcon). The imports are well-organized and follow the project's conventions.
Also applies to: 7-19
40-50
: LGTM! Loading state follows established patterns.The loading state implementation correctly uses useSWR's
isLoading
flag, follows the project's design system with element descriptors, and provides appropriate visual feedback with a centered spinner.
116-133
: Excellent UX improvement with proper implementation!The replacement of static text with an interactive button significantly improves user experience by making payment attempts actionable. The implementation demonstrates several best practices:
- Uses
SimpleButton
with appropriatelink
variant for navigation- Includes proper localization with
localizationKeys('commerce.viewPayment')
- Follows accessibility guidelines with
aria-hidden
on decorative icon- Uses theme tokens for consistent spacing via
sx
prop- Implements proper navigation pattern with void async handling
This change aligns perfectly with the refactoring objectives and enhances the overall user interface.
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
Outdated
Show resolved
Hide resolved
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
Show resolved
Hide resolved
packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
Outdated
Show resolved
Hide resolved
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx (1)
59-70
: Proper error handling implementation addressing previous feedbackThe error handling correctly addresses the previous review comment by:
- Extracting the
error
from useSWR- Using the
translateError
utility for proper localization- Displaying errors with consistent styling using the Alert component
- Maintaining the same layout structure as the loading state
This properly implements the error handling that was suggested in the previous review.
🧹 Nitpick comments (1)
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx (1)
4-4
: Import path inconsistencyThe Alert component is imported using an absolute path
@/ui/elements/Alert
while other similar components use relative paths. This inconsistency could indicate a path mapping issue or inconsistent import patterns.Consider using a consistent import pattern:
-import { Alert } from '@/ui/elements/Alert'; +import { Alert } from '@/ui/elements';Or verify if the path mapping is correctly configured for this specific import.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
packages/clerk-js/bundlewatch.config.json
(2 hunks)packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
(2 hunks)packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
(3 hunks)packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
(3 hunks)packages/clerk-js/src/ui/contexts/components/PaymentAttempts.tsx
(0 hunks)packages/clerk-js/src/ui/contexts/components/Statements.tsx
(0 hunks)packages/types/src/commerce.ts
(2 hunks)
💤 Files with no reviewable changes (2)
- packages/clerk-js/src/ui/contexts/components/Statements.tsx
- packages/clerk-js/src/ui/contexts/components/PaymentAttempts.tsx
✅ Files skipped from review due to trivial changes (1)
- packages/clerk-js/bundlewatch.config.json
🚧 Files skipped from review as they are similar to previous changes (3)
- packages/clerk-js/src/core/modules/commerce/CommerceBilling.ts
- packages/types/src/commerce.ts
- packages/clerk-js/src/ui/components/PaymentAttempts/PaymentAttemptPage.tsx
🧰 Additional context used
📓 Path-based instructions (10)
packages/clerk-js/src/ui/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/clerk-js-ui.mdc)
packages/clerk-js/src/ui/**/*.{ts,tsx}
: Element descriptors should always be camelCase
Use element descriptors in UI components to enable consistent theming and styling via appearance.elements
Element descriptors should generate unique, stable CSS classes for theming
Element descriptors should handle state classes (e.g., cl-loading, cl-active, cl-error, cl-open) automatically based on component state
Do not render hard-coded values; all user-facing strings must be localized using provided localization methods
Use the useLocalizations hook and localizationKeys utility for all text and error messages
Use the styled system (sx prop, theme tokens, responsive values) for custom component styling
Use useCardState for card-level state, useFormState for form-level state, and useLoadingStatus for loading states
Always use handleError utility for API errors and use translateError for localized error messages
Use useFormControl for form field state, implement proper validation, and handle loading and error states in forms
Use localization keys for all form labels and placeholders
Use element descriptors for consistent styling and follow the theme token system
Use the Card and FormContainer patterns for consistent UI structure
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
**/*.{jsx,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{jsx,tsx}
: Use error boundaries in React components
Minimize re-renders in React components
**/*.{jsx,tsx}
: Always use functional components with hooks instead of class components
Follow PascalCase naming for components:UserProfile
,NavigationMenu
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
**/*.tsx
📄 CodeRabbit Inference Engine (.cursor/rules/react.mdc)
**/*.tsx
: Use proper type definitions for props and state
Leverage TypeScript's type inference where possible
Use proper event types for handlers
Implement proper generic types for reusable components
Use proper type guards for conditional rendering
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx
**/*
⚙️ CodeRabbit Configuration File
**/*
: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.Whenever reviewing a pull request, if there are any changes that could impact security, always tag
@clerk/security
in the PR.Security-impacting changes include, but are not limited to:
- Changes to authentication logic or mechanisms (e.g. login, session handling, token issuance)
- Any modification to access control, authorization checks, or role-based permissions
- Introduction or modification of hashing algorithms, signature verification, or cryptographic primitives
- Handling of sensitive data (e.g. passwords, tokens, secrets, PII)
- Integration with external identity providers (e.g. SSO, OAuth, OpenID Connect)
- Modifications to security headers, cookie flags, CORS policies, or CSRF protections
- Bypass mechanisms (e.g. feature flags, testing overrides) that could weaken protections
- Changes to rate limiting, abuse prevention, or input validation
If you're unsure whether a change is security-relevant, err on the side of caution and tag
@clerk/security
.Any time that you tag
@clerk/security
, please do so explicitly in a code comment, rather than within a collapsed section in a coderabbit comment, such as the "recent review details" section. If you do use the team name in any thinking or non-direct-code-comment content, it can be referred to as "clerk security team" to avoid accidentally printing the tag which sends a notification to the team.
Files:
packages/clerk-js/src/ui/components/Statements/StatementPage.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). (5)
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (5)
packages/clerk-js/src/ui/components/Statements/StatementPage.tsx (5)
1-2
: LGTM: Clean import additions for new functionalityThe addition of
useClerk
,useOrganization
from React hooks anduseSWR
for data fetching aligns well with the refactoring objectives to move away from context-based data fetching.
8-20
: Well-organized imports following project patternsThe imports are properly structured with clear separation between contexts, customizables, and icons. The additions support the new functionality while maintaining consistency with existing patterns.
26-30
: Good hook organization and localization setupThe hooks are well-organized and the addition of
translateError
fromuseLocalizations
properly supports the error handling functionality introduced later in the component.
32-45
: Excellent data fetching implementation with proper conditional logicThe useSWR implementation correctly:
- Uses conditional fetching with a proper key structure
- Includes organization ID when subscriber type is 'org'
- Maintains consistency between the SWR key and the fetcher function parameters
- Extracts error for proper error handling
The refactor successfully replaces context-based data fetching with direct API calls, improving data freshness and reducing complexity.
136-153
: Excellent UI enhancement with proper accessibility and localizationThe payment button implementation is well-crafted:
- Uses
SimpleButton
with appropriate variant and color scheme- Includes proper navigation functionality
- Has proper spacing with theme tokens (
t.space.$1
)- Uses localized text with
localizationKeys('commerce.viewPayment')
- Includes an accessible arrow icon with
aria-hidden
- Follows the coding guidelines for element descriptors and localization
This is a significant improvement over the previous truncated ID display, providing better user experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (48)
packages/localizations/src/ar-SA.ts
(1 hunks)packages/localizations/src/be-BY.ts
(1 hunks)packages/localizations/src/bg-BG.ts
(1 hunks)packages/localizations/src/bn-IN.ts
(1 hunks)packages/localizations/src/ca-ES.ts
(1 hunks)packages/localizations/src/cs-CZ.ts
(1 hunks)packages/localizations/src/da-DK.ts
(1 hunks)packages/localizations/src/de-DE.ts
(1 hunks)packages/localizations/src/el-GR.ts
(1 hunks)packages/localizations/src/en-GB.ts
(1 hunks)packages/localizations/src/es-CR.ts
(1 hunks)packages/localizations/src/es-ES.ts
(1 hunks)packages/localizations/src/es-MX.ts
(1 hunks)packages/localizations/src/es-UY.ts
(1 hunks)packages/localizations/src/fa-IR.ts
(1 hunks)packages/localizations/src/fi-FI.ts
(1 hunks)packages/localizations/src/fr-FR.ts
(1 hunks)packages/localizations/src/he-IL.ts
(1 hunks)packages/localizations/src/hi-IN.ts
(1 hunks)packages/localizations/src/hr-HR.ts
(1 hunks)packages/localizations/src/hu-HU.ts
(1 hunks)packages/localizations/src/id-ID.ts
(1 hunks)packages/localizations/src/is-IS.ts
(1 hunks)packages/localizations/src/it-IT.ts
(1 hunks)packages/localizations/src/ja-JP.ts
(1 hunks)packages/localizations/src/kk-KZ.ts
(1 hunks)packages/localizations/src/ko-KR.ts
(1 hunks)packages/localizations/src/mn-MN.ts
(1 hunks)packages/localizations/src/ms-MY.ts
(1 hunks)packages/localizations/src/nb-NO.ts
(1 hunks)packages/localizations/src/nl-BE.ts
(1 hunks)packages/localizations/src/nl-NL.ts
(1 hunks)packages/localizations/src/pl-PL.ts
(1 hunks)packages/localizations/src/pt-BR.ts
(1 hunks)packages/localizations/src/pt-PT.ts
(1 hunks)packages/localizations/src/ro-RO.ts
(1 hunks)packages/localizations/src/ru-RU.ts
(1 hunks)packages/localizations/src/sk-SK.ts
(1 hunks)packages/localizations/src/sr-RS.ts
(1 hunks)packages/localizations/src/sv-SE.ts
(1 hunks)packages/localizations/src/ta-IN.ts
(1 hunks)packages/localizations/src/te-IN.ts
(1 hunks)packages/localizations/src/th-TH.ts
(1 hunks)packages/localizations/src/tr-TR.ts
(1 hunks)packages/localizations/src/uk-UA.ts
(1 hunks)packages/localizations/src/vi-VN.ts
(1 hunks)packages/localizations/src/zh-CN.ts
(1 hunks)packages/localizations/src/zh-TW.ts
(1 hunks)
✅ Files skipped from review due to trivial changes (46)
- packages/localizations/src/de-DE.ts
- packages/localizations/src/ar-SA.ts
- packages/localizations/src/bg-BG.ts
- packages/localizations/src/be-BY.ts
- packages/localizations/src/te-IN.ts
- packages/localizations/src/pl-PL.ts
- packages/localizations/src/hu-HU.ts
- packages/localizations/src/kk-KZ.ts
- packages/localizations/src/nb-NO.ts
- packages/localizations/src/ca-ES.ts
- packages/localizations/src/it-IT.ts
- packages/localizations/src/sv-SE.ts
- packages/localizations/src/es-MX.ts
- packages/localizations/src/pt-BR.ts
- packages/localizations/src/ms-MY.ts
- packages/localizations/src/ko-KR.ts
- packages/localizations/src/es-ES.ts
- packages/localizations/src/fi-FI.ts
- packages/localizations/src/uk-UA.ts
- packages/localizations/src/hi-IN.ts
- packages/localizations/src/es-CR.ts
- packages/localizations/src/da-DK.ts
- packages/localizations/src/ja-JP.ts
- packages/localizations/src/en-GB.ts
- packages/localizations/src/fr-FR.ts
- packages/localizations/src/ta-IN.ts
- packages/localizations/src/bn-IN.ts
- packages/localizations/src/he-IL.ts
- packages/localizations/src/tr-TR.ts
- packages/localizations/src/mn-MN.ts
- packages/localizations/src/th-TH.ts
- packages/localizations/src/pt-PT.ts
- packages/localizations/src/vi-VN.ts
- packages/localizations/src/ru-RU.ts
- packages/localizations/src/is-IS.ts
- packages/localizations/src/fa-IR.ts
- packages/localizations/src/sr-RS.ts
- packages/localizations/src/nl-BE.ts
- packages/localizations/src/zh-CN.ts
- packages/localizations/src/nl-NL.ts
- packages/localizations/src/sk-SK.ts
- packages/localizations/src/zh-TW.ts
- packages/localizations/src/el-GR.ts
- packages/localizations/src/cs-CZ.ts
- packages/localizations/src/es-UY.ts
- packages/localizations/src/hr-HR.ts
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
**/*.{js,jsx,ts,tsx}
: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use Prettier for consistent code formatting
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
packages/**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
TypeScript is required for all packages
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
packages/**/*.{ts,tsx,d.ts}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Packages should export TypeScript types alongside runtime code
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/development.mdc)
Use proper TypeScript error types
**/*.{ts,tsx}
: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoidany
type - preferunknown
when type is uncertain, then narrow with type guards
Useinterface
for object shapes that might be extended
Usetype
for unions, primitives, and computed types
Preferreadonly
properties for immutable data structures
Useprivate
for internal implementation details
Useprotected
for inheritance hierarchies
Usepublic
explicitly for clarity in public APIs
Preferreadonly
for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Useconst assertions
for literal types:as const
Usesatisfies
operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports:import type { ... } from ...
Noany
types without justification
Proper error handling with typed errors
Consistent use ofreadonly
for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
packages/localizations/**/*
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Localization files must be placed in 'packages/localizations/'.
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
**/*.{js,ts,tsx,jsx}
📄 CodeRabbit Inference Engine (.cursor/rules/monorepo.mdc)
Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
**/*
⚙️ CodeRabbit Configuration File
**/*
: If there are no tests added or modified as part of the PR, please suggest that tests be added to cover the changes.Whenever reviewing a pull request, if there are any changes that could impact security, always tag
@clerk/security
in the PR.Security-impacting changes include, but are not limited to:
- Changes to authentication logic or mechanisms (e.g. login, session handling, token issuance)
- Any modification to access control, authorization checks, or role-based permissions
- Introduction or modification of hashing algorithms, signature verification, or cryptographic primitives
- Handling of sensitive data (e.g. passwords, tokens, secrets, PII)
- Integration with external identity providers (e.g. SSO, OAuth, OpenID Connect)
- Modifications to security headers, cookie flags, CORS policies, or CSRF protections
- Bypass mechanisms (e.g. feature flags, testing overrides) that could weaken protections
- Changes to rate limiting, abuse prevention, or input validation
If you're unsure whether a change is security-relevant, err on the side of caution and tag
@clerk/security
.Any time that you tag
@clerk/security
, please do so explicitly in a code comment, rather than within a collapsed section in a coderabbit comment, such as the "recent review details" section. If you do use the team name in any thinking or non-direct-code-comment content, it can be referred to as "clerk security team" to avoid accidentally printing the tag which sends a notification to the team.
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
**/localizations/**/*.ts
⚙️ CodeRabbit Configuration File
**/localizations/**/*.ts
: Review the changes to localization files with the following guidelines:
- Ensure that no existing translations are accidentally removed unless they are being replaced or fixed. If a string is removed, verify that it is intentional and justified.
- Check that all translations are friendly, formal, or semi-formal. Explicit, offensive, or inappropriate language is not allowed. If you find any potentially offensive language or are unsure, tag the @clerk/sdk-infra team in a separate comment. If you do not intend to tag the team, refer to it as "Clerk SDK Infra team" instead.
- Use the most up-to-date base localization file (https://github.com/clerk/javascript/blob/main/packages/localizations/src/en-US.ts) to validate changes, ensuring consistency and completeness.
- Confirm that new translations are accurate, contextually appropriate, and match the intent of the original English strings.
- Check for formatting issues, such as missing placeholders, incorrect variable usage, or syntax errors.
- Ensure that all keys are unique and that there are no duplicate or conflicting entries.
- If you notice missing translations for new keys, flag them for completion.
Files:
packages/localizations/src/id-ID.ts
packages/localizations/src/ro-RO.ts
⏰ 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). (4)
- GitHub Check: Formatting | Dedupe | Changeset
- GitHub Check: Build Packages
- GitHub Check: semgrep/ci
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
packages/localizations/src/id-ID.ts (1)
157-157
: LGTM! New localization key added correctly.The addition of the
viewPayment
key under thecommerce
section is appropriate and follows the established pattern in this community-contributed localization file. Theundefined
value is consistent with other untranslated keys in this file.This change aligns with the broader update to support new payment viewing functionality in the commerce billing system.
@@ -154,6 +154,7 @@ export const roRO: LocalizationResource = { | |||
totalDue: undefined, | |||
totalDueToday: undefined, | |||
viewFeatures: undefined, | |||
viewPayment: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Missing Romanian translation for new viewPayment
key.
The new viewPayment
localization key has an undefined
value, meaning the Romanian translation is incomplete. Based on the English base localization, this should be translated to an appropriate Romanian equivalent of "View payment".
Consider providing a Romanian translation such as:
- viewPayment: undefined,
+ viewPayment: 'Vezi plata',
Or alternatively:
'Vizualizează plata'
(more formal)'Afișează plata'
(display payment)
Please verify with native Romanian speakers to ensure the most appropriate translation for the payment context.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
viewPayment: undefined, | |
- viewPayment: undefined, | |
+ viewPayment: 'Vezi plata', |
🤖 Prompt for AI Agents
In packages/localizations/src/ro-RO.ts at line 157, the viewPayment key is set
to undefined, indicating a missing Romanian translation. Replace undefined with
an appropriate Romanian translation for "View payment," such as 'Vizualizează
plata' or 'Afișează plata', after confirming the best choice with native
speakers for accuracy in the payment context.
Description
Reworks statement page and payment attempt page to fetch appropriate resource by id instead of looping through paginated cached data. Also adds View Payment button to statement detail, now that it's available.
Checklist
pnpm test
runs as expected.pnpm build
runs as expected.Type of change
Summary by CodeRabbit
New Features
Refactor
Localization
Style