This commit is contained in:
 Илья Шалонин 2025-10-29 13:43:43 +05:00
commit 8538ab969a
434 changed files with 44051 additions and 0 deletions

View file

@ -0,0 +1,53 @@
import type { config } from "@repo/config";
import { useTranslations } from "next-intl";
import type { ReactNode } from "react";
type ProductReferenceId = keyof (typeof config)["payments"]["plans"];
export function usePlanData() {
const t = useTranslations();
const planData: Record<
ProductReferenceId,
{
title: string;
description: ReactNode;
features: ReactNode[];
}
> = {
free: {
title: t("pricing.products.free.title"),
description: t("pricing.products.free.description"),
features: [
t("pricing.products.free.features.anotherFeature"),
t("pricing.products.free.features.limitedSupport"),
],
},
pro: {
title: t("pricing.products.pro.title"),
description: t("pricing.products.pro.description"),
features: [
t("pricing.products.pro.features.anotherFeature"),
t("pricing.products.pro.features.fullSupport"),
],
},
enterprise: {
title: t("pricing.products.enterprise.title"),
description: t("pricing.products.enterprise.description"),
features: [
t("pricing.products.enterprise.features.unlimitedProjects"),
t("pricing.products.enterprise.features.enterpriseSupport"),
],
},
lifetime: {
title: t("pricing.products.lifetime.title"),
description: t("pricing.products.lifetime.description"),
features: [
t("pricing.products.lifetime.features.noRecurringCosts"),
t("pricing.products.lifetime.features.extendSupport"),
],
},
};
return { planData };
}

View 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);