mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-12 16:06:38 +00:00
♻️ load branding only if correctly subscribed
This commit is contained in:
21
src/lib/api/isOrgSubscribed.ts
Normal file
21
src/lib/api/isOrgSubscribed.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
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 isOrgSubscribed = 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 &&
|
||||
subscriptionStatus.active;
|
||||
|
||||
return subscribed;
|
||||
});
|
||||
Reference in New Issue
Block a user