mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-13 05:06:25 +00:00
add subscription violation banner
This commit is contained in:
committed by
Owen Schwartz
parent
f129654074
commit
cf4747d381
@@ -23,6 +23,8 @@ import logger from "@server/logger";
|
||||
import { fromZodError } from "zod-validation-error";
|
||||
import { OpenAPITags, registry } from "@server/openApi";
|
||||
import { GetOrgSubscriptionResponse } from "@server/routers/billing/types";
|
||||
import { usageService } from "@server/lib/billing/usageService";
|
||||
import { build } from "@server/build";
|
||||
|
||||
// Import tables for billing
|
||||
import {
|
||||
@@ -70,9 +72,19 @@ export async function getOrgSubscriptions(
|
||||
throw err;
|
||||
}
|
||||
|
||||
let limitsExceeded = false;
|
||||
if (build === "saas") {
|
||||
try {
|
||||
limitsExceeded = await usageService.checkLimitSet(orgId);
|
||||
} catch (err) {
|
||||
logger.error("Error checking limits for org %s: %s", orgId, err);
|
||||
}
|
||||
}
|
||||
|
||||
return response<GetOrgSubscriptionResponse>(res, {
|
||||
data: {
|
||||
subscriptions
|
||||
subscriptions,
|
||||
...(build === "saas" ? { limitsExceeded } : {})
|
||||
},
|
||||
success: true,
|
||||
error: false,
|
||||
|
||||
@@ -2,6 +2,8 @@ import { Limit, Subscription, SubscriptionItem, Usage } from "@server/db";
|
||||
|
||||
export type GetOrgSubscriptionResponse = {
|
||||
subscriptions: Array<{ subscription: Subscription; items: SubscriptionItem[] }>;
|
||||
/** When build === saas, true if org has exceeded plan limits (sites, users, etc.) */
|
||||
limitsExceeded?: boolean;
|
||||
};
|
||||
|
||||
export type GetOrgUsageResponse = {
|
||||
|
||||
Reference in New Issue
Block a user