1c4568c8b1
## 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
28 lines
698 B
TypeScript
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,
|
|
};
|
|
};
|