mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-09 12:16:36 +00:00
add enterprise license system
This commit is contained in:
@@ -60,13 +60,6 @@ export default async function BillingSettingsPage({
|
||||
|
||||
const t = await getTranslations();
|
||||
|
||||
const navItems = [
|
||||
{
|
||||
title: t('billing'),
|
||||
href: `/{orgId}/settings/billing`,
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<>
|
||||
<OrgProvider org={org}>
|
||||
|
||||
@@ -45,7 +45,10 @@ export default async function OrgIdpPage(props: OrgIdpPageProps) {
|
||||
const subRes = await getSubscription();
|
||||
subscriptionStatus = subRes.data.data;
|
||||
} catch {}
|
||||
const subscribed = subscriptionStatus?.tier === TierId.STANDARD;
|
||||
const subscribed =
|
||||
build === "enterprise"
|
||||
? true
|
||||
: subscriptionStatus?.tier === TierId.STANDARD;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
42
src/app/[orgId]/settings/(private)/license/layout.tsx
Normal file
42
src/app/[orgId]/settings/(private)/license/layout.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import SettingsSectionTitle from "@app/components/SettingsSectionTitle";
|
||||
import { verifySession } from "@app/lib/auth/verifySession";
|
||||
import { redirect } from "next/navigation";
|
||||
import { cache } from "react";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { build } from "@server/build";
|
||||
|
||||
type LicensesSettingsProps = {
|
||||
children: React.ReactNode;
|
||||
params: Promise<{ orgId: string }>;
|
||||
};
|
||||
|
||||
export default async function LicensesSetingsLayoutProps({
|
||||
children,
|
||||
params
|
||||
}: LicensesSettingsProps) {
|
||||
const { orgId } = await params;
|
||||
|
||||
if (build !== "saas") {
|
||||
redirect(`/${orgId}/settings`);
|
||||
}
|
||||
|
||||
const getUser = cache(verifySession);
|
||||
const user = await getUser();
|
||||
|
||||
if (!user) {
|
||||
redirect(`/`);
|
||||
}
|
||||
|
||||
const t = await getTranslations();
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsSectionTitle
|
||||
title={t("saasLicenseKeysSettingsTitle")}
|
||||
description={t("saasLicenseKeysSettingsDescription")}
|
||||
/>
|
||||
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
}
|
||||
25
src/app/[orgId]/settings/(private)/license/page.tsx
Normal file
25
src/app/[orgId]/settings/(private)/license/page.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import GenerateLicenseKeysTable from "@app/components/GenerateLicenseKeysTable";
|
||||
import { internal } from "@app/lib/api";
|
||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
||||
import { ListGeneratedLicenseKeysResponse } from "@server/private/routers/generatedLicense";
|
||||
import { AxiosResponse } from "axios";
|
||||
|
||||
type Props = {
|
||||
params: Promise<{ orgId: string }>;
|
||||
};
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function Page({ params }: Props) {
|
||||
const { orgId } = await params;
|
||||
|
||||
let licenseKeys: ListGeneratedLicenseKeysResponse = [];
|
||||
try {
|
||||
const data = await internal.get<
|
||||
AxiosResponse<ListGeneratedLicenseKeysResponse>
|
||||
>(`/org/${orgId}/license`, await authCookieHeader());
|
||||
licenseKeys = data.data.data;
|
||||
} catch {}
|
||||
|
||||
return <GenerateLicenseKeysTable licenseKeys={licenseKeys} orgId={orgId} />;
|
||||
}
|
||||
Reference in New Issue
Block a user