Files
twenty/packages/twenty-front/src/modules/billing/hooks/useGetWorkflowNodeExecutionUsage.ts
T
Antoine Moreaux 1c4568c8b1 feat(pricing/ai): improve billing metered pricing + add pricing on ai chat (#14092)
## TODO:

- [x] display "yearly" or "monthly" wording everywhere it's needed
- [ ] Add button with "downgrade" or "upgrade" to save the change of
credits price + modal to validate
- [x] Add renewal date 
- [ ] Implement
https://docs.stripe.com/billing/subscriptions/subscription-schedules for
`switchFromYearlyToMonthly` and decrease number of credits
2025-08-29 16:23:07 +00:00

28 lines
698 B
TypeScript

import {
BillingProductKey,
useGetMeteredProductsUsageQuery,
} from '~/generated-metadata/graphql';
export const useGetWorkflowNodeExecutionUsage = () => {
const { data, loading } = useGetMeteredProductsUsageQuery();
const workflowUsage = data?.getMeteredProductsUsage.find(
(productUsage) =>
productUsage.productKey === BillingProductKey.WORKFLOW_NODE_EXECUTION,
);
if (loading === true || !workflowUsage) {
return {
usedCredits: 0,
grantedCredits: 10000,
unitPriceCents: 0,
};
}
return {
usedCredits: workflowUsage.usedCredits,
grantedCredits: workflowUsage.grantedCredits,
unitPriceCents: workflowUsage.unitPriceCents,
};
};