Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: [app-router-migration 8.6] reorganize future pages file structure #12988

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions apps/web/app/_types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export type Params = {
[param: string]: string | string[] | undefined;
};

export type SearchParams = {
[param: string]: string | string[] | undefined;
};

export type PageProps = {
params: Params;
searchParams: SearchParams;
};

export type LayoutProps = { params: Params; children: React.ReactElement };

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions apps/web/app/future/(shared-page-wrapper)/(layout)/layout.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions apps/web/app/future/(shared-page-wrapper)/(no-layout)/layout.tsx

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 3 additions & 0 deletions apps/web/app/future/apps/[slug]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { WithLayout } from "app/layoutHOC";

export default WithLayout({ getLayout: null })<"L">;
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import CategoryPage from "@pages/apps/categories/[category]";
import { Prisma } from "@prisma/client";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { notFound } from "next/navigation";
import z from "zod";

Expand All @@ -9,8 +10,6 @@ import { APP_NAME } from "@calcom/lib/constants";
import prisma from "@calcom/prisma";
import { AppCategories } from "@calcom/prisma/enums";

import PageWrapper from "@components/PageWrapperAppDir";

export const generateMetadata = async () => {
return await _generateMetadata(
() => `${APP_NAME} | ${APP_NAME}`,
Expand Down Expand Up @@ -67,13 +66,6 @@ const getPageProps = async ({ params }: { params: Record<string, string | string
};
};

export default async function Page({ params }: { params: Record<string, string | string[]> }) {
const { apps } = await getPageProps({ params });
return (
<PageWrapper getLayout={null} requiresLicense={false} nonce={undefined} themeBasis={null}>
<CategoryPage apps={apps} />
</PageWrapper>
);
}

// @ts-expect-error getData arg
export default WithLayout({ getData: getPageProps, Page: CategoryPage })<P>;
export const dynamic = "force-static";
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import LegacyPage from "@pages/apps/categories/index";
import { ssrInit } from "app/_trpc/ssrInit";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { cookies, headers } from "next/headers";

import { getAppRegistry, getAppRegistryWithCredentials } from "@calcom/app-store/_appRegistry";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { APP_NAME } from "@calcom/lib/constants";

import PageWrapper from "@components/PageWrapperAppDir";

export const generateMetadata = async () => {
return await _generateMetadata(
() => `Categories | ${APP_NAME}`,
Expand Down Expand Up @@ -43,14 +42,4 @@ async function getPageProps() {
};
}

export default async function Page() {
const props = await getPageProps();
const h = headers();
const nonce = h.get("x-nonce") ?? undefined;

return (
<PageWrapper getLayout={null} requiresLicense={false} nonce={nonce} themeBasis={null} {...props}>
<LegacyPage {...props} />
</PageWrapper>
);
}
export default WithLayout({ getData: getPageProps, Page: LegacyPage, getLayout: null })<"P">;
3 changes: 3 additions & 0 deletions apps/web/app/future/apps/installed/[category]/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { WithLayout } from "app/layoutHOC";

export default WithLayout({ getLayout: null })<"L">;
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import { ssgInit } from "app/_trpc/ssgInit";
import type { Params } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { notFound } from "next/navigation";
import type { ReactElement } from "react";
import { z } from "zod";

import { getLayout } from "@calcom/features/MainLayoutAppDir";
import { APP_NAME } from "@calcom/lib/constants";

import PageWrapper from "@components/PageWrapperAppDir";

const validStatuses = ["upcoming", "recurring", "past", "cancelled", "unconfirmed"] as const;

const querySchema = z.object({
status: z.enum(validStatuses),
});

type Props = { params: Params; children: ReactElement };

Check warning on line 18 in apps/web/app/future/bookings/[status]/layout.tsx

View workflow job for this annotation

GitHub Actions / ESLint Report Analysis

apps/web/app/future/bookings/[status]/layout.tsx#L18

[@typescript-eslint/no-unused-vars] 'Props' is defined but never used. Allowed unused vars must match /^_/u.

export const generateMetadata = async () =>
await _generateMetadata(
Expand All @@ -43,14 +42,6 @@
};
};

export default async function BookingPageLayout({ params, children }: Props) {
const props = await getData({ params });

return (
<PageWrapper requiresLicense={false} getLayout={getLayout} nonce={undefined} themeBasis={null} {...props}>
{children}
</PageWrapper>
);
}
export default WithLayout({ getLayout, getData })<"L">;

export const dynamic = "force-static";
5 changes: 5 additions & 0 deletions apps/web/app/future/event-types/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@calcom/features/MainLayoutAppDir";

export default WithLayout({ getLayout })<"L">;
5 changes: 5 additions & 0 deletions apps/web/app/future/settings/admin/apps/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";

export default WithLayout({ getLayout })<"L">;
5 changes: 5 additions & 0 deletions apps/web/app/future/settings/admin/flags/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";

export default WithLayout({ getLayout })<"L">;
5 changes: 5 additions & 0 deletions apps/web/app/future/settings/admin/impersonation/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";

export default WithLayout({ getLayout })<"L">;
3 changes: 3 additions & 0 deletions apps/web/app/future/settings/admin/oAuth/oAuthView/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { WithLayout } from "app/layoutHOC";

export default WithLayout({ getLayout: null })<"L">;
13 changes: 13 additions & 0 deletions apps/web/app/future/settings/admin/oAuth/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import LegacyPage from "@pages/settings/admin/oAuth/index";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";

export const generateMetadata = async () =>
await _generateMetadata(
() => "OAuth",
() => "Add new OAuth Clients"
);

export default WithLayout({ getLayout, Page: LegacyPage })<"P">;
5 changes: 5 additions & 0 deletions apps/web/app/future/settings/admin/organizations/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";

export default WithLayout({ getLayout })<"L">;
13 changes: 13 additions & 0 deletions apps/web/app/future/settings/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import LegacyPage from "@pages/settings/admin/index";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@components/auth/layouts/AdminLayoutAppDir";

export const generateMetadata = async () =>
await _generateMetadata(
() => "Admin",
() => "admin_description"
);

export default WithLayout({ getLayout, Page: LegacyPage })<"P">;
5 changes: 5 additions & 0 deletions apps/web/app/future/settings/admin/users/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { WithLayout } from "app/layoutHOC";

import { getLayout } from "@calcom/features/settings/layouts/SettingsLayoutAppDir";

export default WithLayout({ getLayout })<"L">;
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
import OldPage from "@pages/teams/index";
import { ssrInit } from "app/_trpc/ssrInit";
import { type Params } from "app/_types";
import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { type GetServerSidePropsContext } from "next";
import { headers, cookies } from "next/headers";
import { redirect } from "next/navigation";

import { getLayout } from "@calcom/features/MainLayoutAppDir";
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";

import { buildLegacyCtx } from "@lib/buildLegacyCtx";

import PageWrapper from "@components/PageWrapperAppDir";

export const generateMetadata = async () =>
await _generateMetadata(
(t) => t("teams"),
(t) => t("create_manage_teams_collaborative")
);

type PageProps = {
params: Params;
};

async function getData(context: Omit<GetServerSidePropsContext, "res" | "resolvedUrl">) {
const ssr = await ssrInit();
await ssr.viewer.me.prefetch();
Expand All @@ -41,24 +32,5 @@ async function getData(context: Omit<GetServerSidePropsContext, "res" | "resolve
return { dehydratedState: await ssr.dehydrate() };
}

const Page = async ({ params }: PageProps) => {
const h = headers();
const nonce = h.get("x-nonce") ?? undefined;

const legacyCtx = buildLegacyCtx(h, cookies(), params);
// @ts-expect-error `req` of type '{ headers: ReadonlyHeaders; cookies: ReadonlyRequestCookies; }' is not assignable to `req` in `GetServerSidePropsContext`
const props = await getData(legacyCtx);

return (
<PageWrapper
getLayout={getLayout}
requiresLicense={false}
nonce={nonce}
themeBasis={null}
dehydratedState={props.dehydratedState}>
<OldPage />
</PageWrapper>
);
};

export default Page;
// @ts-expect-error getData arg
export default WithLayout({ getData, getLayout, Page: OldPage })<"P">;
Loading
Loading