fix: future build and type fixes

This commit is contained in:
zomars
2024-01-17 12:01:32 -07:00
parent a9e50d76ca
commit 9076a7eb42
8 changed files with 35 additions and 21 deletions
@@ -1,10 +1,9 @@
import OldPage from "@pages/booking/[uid]";
import OldPage, { type PageProps, getServerSideProps } from "@pages/booking/[uid]";
import { withAppDirSsr } from "app/WithAppDirSsr";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import { WithLayout } from "app/layoutHOC";
import { getData } from "../page";
const getData = withAppDirSsr<PageProps>(getServerSideProps);
const getEmbedData = withEmbedSsrAppDir(getData);
// @ts-expect-error Type '(context: GetServerSidePropsContext) => Promise<any>' is not assignable to type '(arg: {
export default WithLayout({ getLayout: null, getData: getEmbedData, Page: OldPage });
+1 -1
View File
@@ -41,7 +41,7 @@ export const generateMetadata = async () =>
() => ""
);
export const getData = async (context: GetServerSidePropsContext) => {
const getData = async (context: GetServerSidePropsContext) => {
const ssr = await ssrInit(context);
const session = await getServerSession(context);
let tz: string | null = null;
@@ -1,9 +1,10 @@
import LegacyPage from "@pages/team/[slug]/[type]/embed";
import LegacyPage, { getServerSideProps } from "@pages/team/[slug]/[type]/embed";
import { withAppDirSsr } from "app/WithAppDirSsr";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import { WithLayout } from "app/layoutHOC";
import { getData } from "../page";
const getData = withAppDirSsr(getServerSideProps);
const getEmbedData = withEmbedSsrAppDir(getData);
// @ts-expect-error Type is missing the following properties from type: entity, duration, booking, away, and 7 more.
export default WithLayout({ getLayout: null, getData: getEmbedData, Page: LegacyPage })<"P">;
@@ -1,5 +1,5 @@
import LegacyPage, { type PageProps, getServerSideProps } from "@pages/team/[slug]/[type]";
import { withAppDir } from "app/AppDirSSRHOC";
import { withAppDirSsr } from "app/WithAppDirSsr";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { type GetServerSidePropsContext } from "next";
@@ -7,8 +7,14 @@ import { cookies, headers } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
export const generateMetadata = async ({ params }: { params: Record<string, string | string[]> }) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params);
export const generateMetadata = async ({
params,
searchParams,
}: {
params: Record<string, string | string[]>;
searchParams: { [key: string]: string | string[] | undefined };
}) => {
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
const props = await getData(legacyCtx as unknown as GetServerSidePropsContext);
const { entity, user, slug, booking } = props;
const { trpc } = await import("@calcom/trpc");
@@ -25,7 +31,7 @@ export const generateMetadata = async ({ params }: { params: Record<string, stri
(t) => `${booking?.uid ? t("reschedule") : ""} ${title}`
);
};
export const getData = withAppDir<PageProps>(getServerSideProps);
const getData = withAppDirSsr<PageProps>(getServerSideProps);
export default WithLayout({
Page: LegacyPage,
@@ -1,9 +1,9 @@
import LegacyPage from "@pages/team/[slug]/embed";
import LegacyPage, { type PageProps, getServerSideProps } from "@pages/team/[slug]";
import { withAppDirSsr } from "app/WithAppDirSsr";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import { WithLayout } from "app/layoutHOC";
import { getData } from "../page";
const getData = withAppDirSsr<PageProps>(getServerSideProps);
const getEmbedData = withEmbedSsrAppDir(getData);
export default WithLayout({ getLayout: null, getData: getEmbedData, Page: LegacyPage })<"P">;
+11 -5
View File
@@ -1,5 +1,5 @@
import LegacyPage, { type PageProps, getServerSideProps } from "@pages/team/[slug]";
import { withAppDir } from "app/AppDirSSRHOC";
import LegacyPage, { getServerSideProps, type PageProps } from "@pages/team/[slug]";
import { withAppDirSsr } from "app/WithAppDirSsr";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { type GetServerSidePropsContext } from "next";
@@ -7,9 +7,15 @@ import { cookies, headers } from "next/headers";
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
export const generateMetadata = async ({ params }: { params: Record<string, string | string[]> }) => {
export const generateMetadata = async ({
params,
searchParams,
}: {
params: Record<string, string | string[]>;
searchParams: { [key: string]: string | string[] | undefined };
}) => {
const props = await getData(
buildLegacyCtx(headers(), cookies(), params) as unknown as GetServerSidePropsContext
buildLegacyCtx(headers(), cookies(), params, searchParams) as unknown as GetServerSidePropsContext
);
const teamName = props.team.name || "Nameless Team";
@@ -19,7 +25,7 @@ export const generateMetadata = async ({ params }: { params: Record<string, stri
);
};
export const getData = withAppDir<PageProps>(getServerSideProps);
const getData = withAppDirSsr<PageProps>(getServerSideProps);
export default WithLayout({
Page: LegacyPage,
+2
View File
@@ -54,6 +54,8 @@ import EventReservationSchema from "@components/schemas/EventReservationSchema";
export { getServerSideProps };
export type PageProps = inferSSRProps<typeof getServerSideProps>;
const stringToBoolean = z
.string()
.optional()
+1 -1
View File
@@ -4,6 +4,6 @@ import withEmbedSsr from "@lib/withEmbedSsr";
import { getServerSideProps as _getServerSideProps } from "../[type]";
export { default } from "../[type]";
export { default, type PageProps } from "../[type]";
export const getServerSideProps = withEmbedSsr(_getServerSideProps);