Skip to content

The open alternative to Salesforce, designed for AI.

610 B
Raw Blame
import { usePlans } from '@/settings/billing/hooks/usePlans';
import {
  type BillingPriceLicensed,
  type BillingPriceMetered,
} from '~/generated-metadata/graphql';

export const useAllBillingPrices = () => {
  const { listPlans } = usePlans();

  const allBillingPrices = listPlans()
    .map(({ baseProducts, resourceCreditProducts, meteredProducts }) => {
      return [
        ...baseProducts,
        ...resourceCreditProducts,
        ...meteredProducts,
      ].map(({ prices }) => prices);
    })
    .flat(2) as Array<BillingPriceLicensed | BillingPriceMetered>;

  return { allBillingPrices };
};