Skip to content

Commit

Permalink
fix: Some recently discovered type errors breaking build (not sure wh…
Browse files Browse the repository at this point in the history
…y undetected before) (calcom#18432)
  • Loading branch information
emrysal authored and MuhammadAimanSulaiman committed Feb 20, 2025
1 parent 6bed3ba commit bf6bcdb
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 21 deletions.
17 changes: 10 additions & 7 deletions apps/web/app/WithEmbedSSR.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export function createMockNextJsRequest(...args: Parameters<typeof createMocks>)
return createMocks<CustomNextApiRequest, CustomNextApiResponse>(...args);
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
const noop = () => {};

vi.mock("next/navigation", () => ({
redirect: vi.fn(),
notFound: vi.fn(),
Expand Down Expand Up @@ -86,7 +89,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);

expect(redirect).toHaveBeenCalledWith("/reschedule/embed?layout=week_view&embed=namespace1");
});
Expand All @@ -105,7 +108,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);

expect(redirect).toHaveBeenCalledWith(
"/reschedule/embed?redirectParam=1&layout=week_view&embed=namespace1"
Expand All @@ -126,7 +129,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "",
},
})
).catch(() => {});
).catch(noop);

expect(redirect).toHaveBeenCalledWith("/reschedule/embed?redirectParam=1&layout=week_view&embed=");
});
Expand All @@ -147,7 +150,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);

expect(redirect).toHaveBeenCalledWith(
"https://calcom.cal.local/owner/embed?layout=week_view&embed=namespace1"
Expand All @@ -168,7 +171,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);

expect(redirect).toHaveBeenCalledWith(
"http://calcom.cal.local/owner/embed?layout=week_view&embed=namespace1"
Expand All @@ -189,7 +192,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "namespace1",
},
})
).catch(() => {});
).catch(noop);

expect(redirect).toHaveBeenCalledWith(
"/calcom.cal.local/owner/embed?layout=week_view&embed=namespace1"
Expand Down Expand Up @@ -239,7 +242,7 @@ describe("withEmbedSsrAppDir", () => {
embed: "",
},
})
).catch(() => {});
).catch(noop);

expect(notFound).toHaveBeenCalled();
});
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/_utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const createI18nInstance = async (locale: string, ns: string) => {
return _i18n;
};

const getTranslationWithCache = async (locale: string, ns: string = "common") => {
const getTranslationWithCache = async (locale: string, ns = "common") => {
const localeWithFallback = locale ?? "en";
const i18n = await createI18nInstance(localeWithFallback, ns);
return i18n.getFixedT(localeWithFallback, ns);
Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/customer-card/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const inputSchema = z.object({
cardKeys: z.array(z.string()),
});

export async function handler(request: Request) {
async function handler(request: Request) {
const headersList = headers();
const requestBody = await request.json();

Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/bookings/[status]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PageProps } from "app/_types";
import type { PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { redirect } from "next/navigation";
Expand Down
2 changes: 0 additions & 2 deletions apps/web/app/future/org/[orgSlug]/embed/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
Expand Down
2 changes: 0 additions & 2 deletions apps/web/app/future/team/[slug]/[type]/embed/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import { getServerSideProps } from "@lib/team/[slug]/[type]/getServerSideProps";
Expand Down
3 changes: 0 additions & 3 deletions apps/web/app/future/team/[slug]/embed/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import { withAppDirSsr } from "app/WithAppDirSsr";
import withEmbedSsrAppDir from "app/WithEmbedSSR";
import type { PageProps as _PageProps } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import { getServerSideProps } from "@lib/team/[slug]/getServerSideProps";
Expand Down
1 change: 1 addition & 0 deletions apps/web/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
<script
nonce={nonce}
id="headScript"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{
__html: `
window.calNewLocale = "${locale}";
Expand Down
2 changes: 1 addition & 1 deletion apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { EmbedProps } from "app/WithEmbedSSR";
import type { GetServerSidePropsContext } from "next";
import { z } from "zod";

Expand All @@ -12,7 +13,6 @@ import { RedirectType } from "@calcom/prisma/enums";

import { getTemporaryOrgRedirect } from "@lib/getTemporaryOrgRedirect";
import type { inferSSRProps } from "@lib/types/inferSSRProps";
import type { EmbedProps } from "app/WithEmbedSSR";

export type PageProps = inferSSRProps<typeof getServerSideProps> & EmbedProps;

Expand Down
7 changes: 4 additions & 3 deletions packages/features/data-table/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Icon, TableNew, TableBody, TableCell, TableHead, TableHeader, TableRow

import { usePersistentColumnResizing } from "../lib/resizing";

export interface DataTableProps<TData, TValue> {
export type DataTableProps<TData, TValue> = {
table: ReactTableType<TData>;
tableContainerRef: React.RefObject<HTMLDivElement>;
isPending?: boolean;
Expand All @@ -26,7 +26,7 @@ export interface DataTableProps<TData, TValue> {
children?: React.ReactNode;
identifier?: string;
enableColumnResizing?: boolean;
}
};

export function DataTable<TData, TValue>({
table,
Expand Down Expand Up @@ -89,7 +89,8 @@ export function DataTable<TData, TValue>({
usePersistentColumnResizing({
enabled: Boolean(enableColumnResizing),
table,
identifier,
// TODO: Figure out why 'identifier' somehow types to string | null
identifier: identifier || undefined,
});

return (
Expand Down

0 comments on commit bf6bcdb

Please sign in to comment.