fix: provide timeZone to /insights from the server side (#21580)

This commit is contained in:
Eunjae Lee authored and GitHub committed 2025-06-12 15:26:44 +00:00
1 parent 5bb2a904ce
commit 6cccb1725f
10 files changed
+102 -98

No files matched your search

@@ -1,4 +1,10 @@
import { _generateMetadata } from "app/_utils";
import { cookies, headers } from "next/headers";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import prisma from "@calcom/prisma";
import { buildLegacyRequest } from "@lib/buildLegacyCtx";
import InsightsPage from "~/insights/insights-view";
@@ -11,6 +17,17 @@ export const generateMetadata = async () =>
"/insights"
);
export default async function Page() {
return <InsightsPage />;
}
const ServerPage = async () => {
const session = await getServerSession({ req: buildLegacyRequest(await headers(), await cookies()) });
const { timeZone } = await prisma.user.findUniqueOrThrow({
where: { id: session?.user.id ?? -1 },
select: {
timeZone: true,
},
});
return <InsightsPage timeZone={timeZone} />;
};
export default ServerPage;
+2 -2
View File
@@ -28,9 +28,9 @@ import { useInsightsBookings } from "@calcom/features/insights/hooks/useInsights
import { useInsightsOrgTeams } from "@calcom/features/insights/hooks/useInsightsOrgTeams";
import { useLocale } from "@calcom/lib/hooks/useLocale";
export default function InsightsPage() {
export default function InsightsPage({ timeZone }: { timeZone: string }) {
return (
<DataTableProvider>
<DataTableProvider timeZone={timeZone}>
<InsightsOrgTeamsProvider>
<InsightsPageContent />
</InsightsOrgTeamsProvider>