link-stack/apps/link/app/(main)/page.tsx

32 lines
874 B
TypeScript
Raw Normal View History

2023-06-26 10:07:12 +00:00
import { Metadata } from "next";
import { redirect } from "next/navigation";
2024-03-20 17:51:21 +01:00
import { getServerSession } from "app/_lib/authentication";
2024-06-05 08:52:41 +02:00
import { Home } from "@link-stack/leafcutter-ui";
import { getUserVisualizations } from "@link-stack/opensearch-common";
import { LeafcutterWrapper } from "@link-stack/leafcutter-ui";
2023-06-26 10:07:12 +00:00
export const metadata: Metadata = {
2024-08-07 12:02:33 +02:00
title: "CDR Link - Home",
2023-06-26 10:07:12 +00:00
};
2024-03-20 17:51:21 +01:00
export default async function Page() {
2024-08-07 12:02:33 +02:00
const leafcutterEnabled = process.env.LEAFCUTTER_ENABLED === "true";
if (!leafcutterEnabled) {
redirect("/overview/recent");
}
2024-03-20 17:51:21 +01:00
const session = await getServerSession();
const {
user: { email },
}: any = session;
2024-08-07 12:02:33 +02:00
const visualizations = await getUserVisualizations(email ?? "none", 20);
2024-03-20 17:51:21 +01:00
return (
<LeafcutterWrapper>
<Home visualizations={visualizations} showWelcome={false} />
</LeafcutterWrapper>
);
2023-06-26 10:07:12 +00:00
}