Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+17
-13
@@ -2,14 +2,15 @@ import { LoaderFunctionArgs, MetaFunction, redirect, useLoaderData } from "react
|
||||
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 { getTenantSessionIdentityForUser } from "~/utils/db/tenants.db.server";
|
||||
import { loadRequiredWebConfig } from "@hivegrid/config";
|
||||
import { absoluteAppRootPath } from "~/utils/app/CrossHostUrls";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import { requireUserId } from "~/utils/session.server";
|
||||
import { runWithRlsContext } from "@hivegrid/db/rls-context.server";
|
||||
|
||||
export function planRequiredSubscriptionSettingsPath(tenantSlug: string) {
|
||||
return appPath({ tenantSlug, path: "settings/subscription", mode: "host-aware" });
|
||||
return appPath({ tenantSlug, path: "settings/billing", mode: "host-aware" });
|
||||
}
|
||||
|
||||
type LoaderData = {
|
||||
@@ -18,25 +19,28 @@ type LoaderData = {
|
||||
subscriptionPath: string;
|
||||
};
|
||||
|
||||
export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.title ?? "Plan required" }];
|
||||
export const meta: MetaFunction<typeof loader> = ({ data }) => [{ title: data?.title }];
|
||||
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
const { t } = await getTranslations(request);
|
||||
const tenantId = await getTenantIdFromUrl(params);
|
||||
const tenant = await getTenant(tenantId);
|
||||
const requestUrl = new URL(request.url);
|
||||
const userId = await requireUserId(request, `${requestUrl.pathname}${requestUrl.search}`);
|
||||
const tenant = await getTenantSessionIdentityForUser({ userId, tenant: params.tenant });
|
||||
|
||||
if (!tenant) {
|
||||
throw redirect(absoluteAppRootPath(loadRequiredWebConfig().routing));
|
||||
}
|
||||
await verifyUserHasPermission(request, "app.settings.subscription.view", tenantId);
|
||||
return runWithRlsContext({ tenantId: tenant.id, userId }, async () => {
|
||||
await verifyUserHasPermission(request, "app.settings.subscription.view", tenant.id);
|
||||
|
||||
const data: LoaderData = {
|
||||
title: `${t("shared.planRequired")} | ${process.env.APP_NAME}`,
|
||||
tenantSlug: tenant.slug,
|
||||
subscriptionPath: planRequiredSubscriptionSettingsPath(tenant.slug),
|
||||
};
|
||||
const data: LoaderData = {
|
||||
title: `${t("shared.planRequired")} | ${process.env.APP_NAME}`,
|
||||
tenantSlug: tenant.slug,
|
||||
subscriptionPath: planRequiredSubscriptionSettingsPath(tenant.slug),
|
||||
};
|
||||
|
||||
return data;
|
||||
return data;
|
||||
});
|
||||
};
|
||||
|
||||
export default function PlanRequiredTenantRoute() {
|
||||
|
||||
Reference in new issue
Block a user