♻️refactor

This commit is contained in:
Fred KISSIE
2025-11-17 22:17:55 +01:00
parent 2466d24c1a
commit 83f36bce9d
2 changed files with 22 additions and 11 deletions

View File

@@ -17,6 +17,7 @@ import { GetOrgTierResponse } from "@server/routers/billing/types";
import { getCachedSubscription } from "@app/lib/api/getCachedSubscription";
import { build } from "@server/build";
import { TierId } from "@server/lib/billing/tiers";
import { isSubscribed } from "@app/lib/api/getSubscriptionStatus";
type GeneralSettingsProps = {
children: React.ReactNode;
@@ -51,16 +52,6 @@ export default async function GeneralSettingsPage({
redirect(`/${orgId}`);
}
let subscriptionStatus: GetOrgTierResponse | null = null;
try {
const subRes = await getCachedSubscription(orgId);
subscriptionStatus = subRes.data.data;
} catch {}
const subscribed =
build === "enterprise"
? true
: subscriptionStatus?.tier === TierId.STANDARD;
const t = await getTranslations();
const navItems: TabItem[] = [
@@ -70,7 +61,7 @@ export default async function GeneralSettingsPage({
exact: true
}
];
if (subscribed) {
if (build === "saas") {
navItems.push({
title: t("authPage"),
href: `/{orgId}/settings/general/auth-page`

View File

@@ -0,0 +1,20 @@
import { build } from "@server/build";
import { TierId } from "@server/lib/billing/tiers";
import { cache } from "react";
import { getCachedSubscription } from "./getCachedSubscription";
import type { GetOrgTierResponse } from "@server/routers/billing/types";
export const isSubscribed = cache(async (orgId: string) => {
let subscriptionStatus: GetOrgTierResponse | null = null;
try {
const subRes = await getCachedSubscription(orgId);
subscriptionStatus = subRes.data.data;
} catch {}
const subscribed =
build === "enterprise"
? true
: subscriptionStatus?.tier === TierId.STANDARD;
return subscribed;
});