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,54 @@
|
||||
import { Entity } from "@toolctrl/db/prisma-browser";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { LoaderFunctionArgs, redirect } from "react-router";
|
||||
import { Outlet, useLoaderData, useParams } from "react-router";
|
||||
import EditPageLayout from "~/components/ui/layouts/EditPageLayout";
|
||||
import { getEntityBySlug } from "~/utils/db/entities/entities.db.server";
|
||||
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
|
||||
import ServerError from "~/components/ui/errors/ServerError";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
type LoaderData = {
|
||||
item: Entity;
|
||||
};
|
||||
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
|
||||
await verifyUserHasPermission(request, "admin.entities.update");
|
||||
const item = await getEntityBySlug({ tenantId: null, slug: params.entity! });
|
||||
if (!item) {
|
||||
return redirect(adminPath("entities", { mode: "host-aware" }));
|
||||
}
|
||||
|
||||
const pathname = new URL(request.url).pathname;
|
||||
if (pathname === adminPath(`entities/${params.entity}`, { mode: "host-aware" })) {
|
||||
return redirect(adminPath(`entities/${params.entity}/details`, { mode: "host-aware" }));
|
||||
}
|
||||
const data: LoaderData = {
|
||||
item,
|
||||
};
|
||||
return data;
|
||||
};
|
||||
|
||||
export default function EntityCrudPreviewRoute() {
|
||||
const { t } = useTranslation();
|
||||
const data = useLoaderData<LoaderData>();
|
||||
const params = useParams();
|
||||
return (
|
||||
<EditPageLayout
|
||||
title={t("models.entity.noCode.sampleViewsTitle", { entity: t(data.item.title) })}
|
||||
menu={[
|
||||
{ title: t("models.entity.plural"), routePath: adminPath("entities", { mode: "host-aware" }) },
|
||||
{ title: t(data.item.title), routePath: adminPath(`entities/${params.entity}/details`, { mode: "host-aware" }) },
|
||||
{ title: t("models.entity.noCode.menu"), routePath: adminPath(`entities/${params.entity}/no-code`, { mode: "host-aware" }) },
|
||||
]}
|
||||
withHome={false}
|
||||
>
|
||||
<div className="border-border h-[calc(100vh-200px)] overflow-y-auto rounded-lg border-2 border-dashed sm:h-[calc(100vh-160px)]">
|
||||
<Outlet />
|
||||
</div>
|
||||
</EditPageLayout>
|
||||
);
|
||||
}
|
||||
|
||||
export function ErrorBoundary() {
|
||||
return <ServerError />;
|
||||
}
|
||||
Reference in new issue
Block a user