first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
20
apps/web/modules/saas/payments/hooks/purchases.tsx
Normal file
20
apps/web/modules/saas/payments/hooks/purchases.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { type Config, config } from "@repo/config";
|
||||
import { createPurchasesHelper } from "@repo/payments/lib/helper";
|
||||
import { usePurchasesQuery } from "@saas/payments/lib/api";
|
||||
|
||||
const plans = config.payments.plans as Config["payments"]["plans"];
|
||||
|
||||
export const usePurchases = (organizationId?: string) => {
|
||||
const { data: purchases } = usePurchasesQuery(organizationId);
|
||||
|
||||
const { activePlan, hasSubscription, hasPurchase } = createPurchasesHelper(
|
||||
purchases ?? [],
|
||||
);
|
||||
|
||||
return { purchases, activePlan, hasSubscription, hasPurchase };
|
||||
};
|
||||
|
||||
export const useUserPurchases = () => usePurchases();
|
||||
|
||||
export const useOrganizationPurchases = (organizationId: string) =>
|
||||
usePurchases(organizationId);
|
||||
Loading…
Add table
Add a link
Reference in a new issue