Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import { LoaderFunctionArgs, MetaFunction, redirect, useLoaderData } from "react-router";
|
||||
import PagePlanRequired from "~/components/pages/PagePlanRequired";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { appPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { getTenant } from "~/utils/db/tenants.db.server";
|
||||
import { getTenantIdFromUrl } from "~/utils/services/.server/urlService";
|
||||
import { loadRequiredWebConfig } from "@toolctrl/config";
|
||||
import { absoluteAppRootPath } from "~/utils/app/CrossHostUrls";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
|
||||
export function planRequiredSubscriptionSettingsPath(tenantSlug: string) {
|
||||
return appPath({ tenantSlug, path: "settings/subscription", mode: "host-aware" });
|
||||
}
|
||||
|
||||
type LoaderData = {
|
||||
title: string;
|
||||
tenantSlug: string;
|
||||
subscriptionPath: string;
|
||||
};
|
||||
|
||||
export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.title ?? "Plan required" }];
|
||||
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const { t } = await getTranslations(request);
|
||||
const tenantId = await getTenantIdFromUrl(params);
|
||||
const tenant = await getTenant(tenantId);
|
||||
|
||||
if (!tenant) {
|
||||
throw redirect(absoluteAppRootPath(loadRequiredWebConfig().routing));
|
||||
}
|
||||
await verifyUserHasPermission(request, "app.settings.subscription.view", tenantId);
|
||||
|
||||
const data: LoaderData = {
|
||||
title: `${t("shared.planRequired")} | ${process.env.APP_NAME}`,
|
||||
tenantSlug: tenant.slug,
|
||||
subscriptionPath: planRequiredSubscriptionSettingsPath(tenant.slug),
|
||||
};
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
export default function PlanRequiredTenantRoute() {
|
||||
const data = useLoaderData<LoaderData>();
|
||||
|
||||
return <PagePlanRequired tenantSlug={data.tenantSlug} subscriptionPath={data.subscriptionPath} />;
|
||||
}
|
||||
Reference in new issue
Block a user