mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
73 lines
1.6 KiB
TypeScript
73 lines
1.6 KiB
TypeScript
import { DashboardLayout } from "@/components/layouts/dashboard-layout";
|
|
import { appRouter } from "@/server/api/root";
|
|
import { validateRequest } from "@/server/auth/auth";
|
|
import { createServerSideHelpers } from "@trpc/react-query/server";
|
|
import type { GetServerSidePropsContext } from "next";
|
|
import React, { type ReactElement } from "react";
|
|
import superjson from "superjson";
|
|
import { ShowTraefikSystem } from "@/components/dashboard/file-system/show-traefik-system";
|
|
|
|
const Dashboard = () => {
|
|
return <ShowTraefikSystem />;
|
|
};
|
|
|
|
export default Dashboard;
|
|
|
|
Dashboard.getLayout = (page: ReactElement) => {
|
|
return <DashboardLayout tab={"traefik"}>{page}</DashboardLayout>;
|
|
};
|
|
export async function getServerSideProps(
|
|
ctx: GetServerSidePropsContext<{ serviceId: string }>,
|
|
) {
|
|
const { user, session } = await validateRequest(ctx.req, ctx.res);
|
|
if (!user) {
|
|
return {
|
|
redirect: {
|
|
permanent: true,
|
|
destination: "/",
|
|
},
|
|
};
|
|
}
|
|
const { req, res } = ctx;
|
|
|
|
const helpers = createServerSideHelpers({
|
|
router: appRouter,
|
|
ctx: {
|
|
req: req as any,
|
|
res: res as any,
|
|
db: null as any,
|
|
session: session,
|
|
user: user,
|
|
},
|
|
transformer: superjson,
|
|
});
|
|
try {
|
|
await helpers.project.all.prefetch();
|
|
const auth = await helpers.auth.get.fetch();
|
|
|
|
if (auth.rol === "user") {
|
|
const user = await helpers.user.byAuthId.fetch({
|
|
authId: auth.id,
|
|
});
|
|
|
|
if (!user.canAccessToTraefikFiles) {
|
|
return {
|
|
redirect: {
|
|
permanent: true,
|
|
destination: "/",
|
|
},
|
|
};
|
|
}
|
|
}
|
|
return {
|
|
props: {
|
|
trpcState: helpers.dehydrate(),
|
|
},
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
props: {},
|
|
};
|
|
}
|
|
}
|