-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
deprocate getProductPrices query in front end #10397
base: main
Are you sure you want to change the base?
Conversation
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.
PR Summary
This PR deprecates the getProductPrices
query in favor of a new BillingBaseProductPrices
query, streamlining the billing system's architecture.
- Added new
BILLING_BASE_PRODUCT_PRICES
query in/packages/twenty-front/src/modules/billing/graphql/billingBaseProductPrices.ts
to fetch plan-based pricing information - Added
getPlanKeyFromSubscription
utility in/packages/twenty-server/src/engine/core-modules/billing/utils/get-plan-key-from-subscription.util.ts
to dynamically map subscription metadata to plan keys - Updated
ChooseYourPlan
component to use the new query structure with plan-based filtering - Improved error messaging in
billing-plan.service.ts
to guide users on runningbilling:sync-products
command when base product is missing - Removed deprecated
BillingProductPricesOutput
DTO and related query implementations
9 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile
const baseProductPrices = plans?.plans | ||
?.find((plan) => plan.planKey === BillingPlanKey.PRO) | ||
?.baseProduct.prices?.filter( | ||
( | ||
price, | ||
): price is NonNullable<typeof price> & { | ||
recurringInterval: SubscriptionInterval; | ||
unitAmount: number; | ||
} => price !== null && 'recurringInterval' in price, | ||
); |
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.
logic: Type guard could fail silently if price has unitAmount but not recurringInterval. Consider splitting the type check.
const baseProductPrices = plans?.plans | |
?.find((plan) => plan.planKey === BillingPlanKey.PRO) | |
?.baseProduct.prices?.filter( | |
( | |
price, | |
): price is NonNullable<typeof price> & { | |
recurringInterval: SubscriptionInterval; | |
unitAmount: number; | |
} => price !== null && 'recurringInterval' in price, | |
); | |
const baseProductPrices = plans?.plans | |
?.find((plan) => plan.planKey === BillingPlanKey.PRO) | |
?.baseProduct.prices?.filter( | |
( | |
price, | |
): price is NonNullable<typeof price> & { | |
recurringInterval: SubscriptionInterval; | |
unitAmount: number; | |
} => price !== null && 'recurringInterval' in price && 'unitAmount' in price, | |
); |
TLDR:
Deprecate getProductPrices in the frontEnd and replace it with BillingBaseProductPrices.
In order to test: